Commit graph

278 commits

Author SHA1 Message Date
Emily Herbert
133ec9be3d
operators (#1783) 2022-05-31 21:26:59 -05:00
mitchmindtree
d2356220cb
Separate parsing, type-checking and control flow analysis into distinct phases (#1712)
* Rename `sway_parse::Program` to `sway_parse::Module`

As a part of a larger refactor to introduce the concept of a `Program`
at a higher level, where a `Program` contains the root module along with
the set of entry points (main function or contract ABI).

* Refactor `sway_core::SwayParseTree` to `ParseProgram`

Introduces a `ParseProgram` type that represents the entire program in
its parsed state with a `ParseTree` for each module, ready for
type-checking to begin.

Also moves `ParseTree` and related types out of the crate root and into
the existing `parse_tree.rs` module.

* Introduce `TypedProgram`, `TypedModule` and related types

By introducing a `TypedProgram` type, we can more accurately represent
the resuling typed program and include the full module tree.

The new `TypedModule` type should be used instead of the old
`TypedParseTree` type.

* Type-check submodules within the new `TypedProgram` structure

Replaces the need for the old `import_new_file` and
`compile_inner_dependency` functions.

* Perform all control flow analysis after type checking

* Remove build_config and dead_code_graph from type checking

Previously these were necessary during type checking as we only had
access to the parsed, type-checked submodules during type checking. Now
that we parse all modules before type checking, and perform control flow
analysis after type checking, we can safely remove these unnecessary
arguments throughout type checking.

* Fix incorrect root module path from buildconfig during parsing

* Address clippy nits

* Update forc lock file for dirty match expression test

* Move `ParseModule`, `ParseProgram` into their own modules

Also moves some related types into their respective modules.

* Move `TypedProgram` and `TypedModule` into their own submodules

This removes `syntax_tree.rs` previously associated with the no longer
necessary `TypedParseTree` in favour of dedicated modules for each of
the `TypedProgram` and `TypedModule` types.

Related types and logic have been moved into their respective modules.

* Fix incorrect path handling in BuildConfig constructor

* Update sway-lsp for change from `TypedParseTree` to `TypedProgram`
2022-06-01 11:24:39 +10:00
Mohammad Fawaz
b067a7dd64
bump to v0.14.4 (#1753) 2022-05-28 14:52:01 -04:00
Mohammad Fawaz
17f856bfa0
bump to 0.14.3 (#1749) 2022-05-28 14:07:02 -04:00
Emily Herbert
6fc5c69f29
v0.14.2 (#1737) 2022-05-27 14:03:29 -05:00
Alex Hansen
02ef7d10b6
v0.14.1 (#1715) 2022-05-26 22:58:56 -07:00
John Adler
953dad9cad
Bump to v0.14.0. (#1714) 2022-05-26 21:12:03 -07:00
Mohammad Fawaz
11a342814c
New intrinsic for generating a unique b256 key (#1688)
* New intrinsic for generating a b256 seed

* updating some names and adding a test

* Add some more tests and fix a few things
2022-05-26 22:19:16 -04:00
Mohammad Fawaz
dac1b96419
bump to v0.13.2 (#1668) 2022-05-25 18:01:21 -04:00
Andrew Cann
9c331df4ce
Parsing precedence fixes (#1660)
* fix precedence for block-parsing

* fix precedence of args to comparison operators
2022-05-25 09:30:18 -07:00
Emily Herbert
1f501c30c0
Add booleans to the keywords in the parser (#1647)
* Add booleans to intrinsics.

* WIP
2022-05-25 08:41:13 -05:00
Emily Herbert
5984e295bd
Move match expression desugaring from parsing to type checking (#1596)
* Refactor namespace and enums.

* clippy

* clippy

* Improvements to namespace API and declaration ABI.

* Introduce the  trait and the  type.

* More instances.

* Introduce the CreateTypeId trait.

* Introduce the MonomorphizeHelper trait.

* Improvements to monomorphization.

* Fix bug with node dependencies.

* Combine Unit Scruntinee and Tuple Scrutinee.

* Improve the MatcherResult type.

* Add recursive catchall pattern.

* Move match expression desugaring from parsing to type checking.

* Use some of the new methods.

* clippy

* Rename function.

* Add purity check back in.

* PR feedback.
2022-05-24 11:04:14 -05:00
Alex Hansen
38a857f83c
v0.13.1 (#1651)
* v0.13.1

* update lockfile
2022-05-24 06:45:53 -07:00
Mohammad Fawaz
78f15a2477
Finish parsing where clauses (#1595)
* parsing `where` clauses

* name -> call_path

* fmt
2022-05-20 12:59:34 -04:00
Mohammad Fawaz
6eef7ab750
Bump to v0.13.0 (#1587)
* Bump to v0.13.0

* fixing deps in sway-fmt-v2

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
2022-05-19 10:03:42 -04:00
Andrew Cann
6a974d282a
Parse tuple field reassignments (#1558)
* allow parsing tuple index reassignments

* handle tuple field reassignments in convert_parse_tree
2022-05-19 18:37:13 +08:00
Toby Hutton
b1c9514d59
Replace the impure keyword with #[storage(...)] annotations. (#1518)
* Replace the `impure` keyword with `#[storage(...)]` annotations.

* Ugh, that's the last time I try to resolve a merge conflict in the GitHub web editor.  :(

* Update use of parse `Item`.
2022-05-19 15:27:55 +10:00
Chris O'Brien
266f5800a4
Added foundation for sway-fmt v2 (#1425) 2022-05-18 21:37:35 -05:00
Andrew Cann
045faad4cb
Add a Spanned trait to the parser (#1559)
* remove unused, accidentally committed file

* add Spanned trait for types that have a span

* Move the `Spanned` trait from `sway-parse` to `sway-types` next to the `Span` declaration.

Co-authored-by: Toby Hutton <toby@grusly.com>
2022-05-18 07:25:41 +10:00
Alex Hansen
d8c5e5e53c
Use __ as a prefix for compiler intrinsics (#1536)
* Disallow functions that begin with a double underscore.
2022-05-14 06:04:03 -07:00
Mohammad Fawaz
2b6e9384f0
bump to 0.12.2 (#1528) 2022-05-12 11:16:00 -04:00
Toby Hutton
dab7bc8f7f
Add declaration attributes to the parser. (#1488)
* Add declaration attributes to the parser.

These will parse Rust-like attributes for any top-level item.
E.g., `#[attrib(arg0, arg1)]`

They are ignored by the rest of the compiler at this stage.

* Small post-PR changes to attributes parser.
2022-05-10 11:41:54 +10:00
Mohammad Fawaz
a03a5d1c06
bump to 0.12.1 (#1473) 2022-05-04 12:31:40 -04:00
Mohammad Fawaz
489f0ca961
Bump to 0.12.0 (#1457)
* bump to v0.11.1

* bump to v0.12.0 instead due to breaking changes
2022-05-03 12:34:07 -04:00
Andrew Cann
88cc74b920
parse patterns in function-parameter position (#1421) 2022-05-01 16:28:12 -07:00
Alex Hansen
95816e4e41
v0.11.0 (#1402)
* v0.10.4

* v0.11.0

Co-authored-by: Alexander Hansen <alexanderhansen@AlexandersMBP2.home>
2022-04-26 11:35:42 -07:00
Alex Hansen
4a21886e75
Allow type arguments in struct call paths (#1388)
* Allow type arguments in struct call paths

* add longer call path for test

* allow side effects in code blocks

Co-authored-by: Alexander Hansen <alexanderhansen@AlexandersMBP2.home>
2022-04-26 07:25:43 -07:00
Andrew Cann
6b8a46b8c0
sway-parse initial PR (#1286)
* remove pest::Span from sway_types::Span

* Add new parser implementation

* use new parser in sway-core

* Proper error handling in convert_parse_tree

* rename new-parser-again to sway-parse

* remove redundant test bin from sway-parse

* fix dependencies in sway-parse

* fix clippy lints

* put dependencies in alphabetical order

* run rustfmt

* record full span in TokenStream

* remove an unused function

* alphabetically sort workspace members

* add --use-orig-parser cli option

* rust rustfmt

* update crate metadata for sway-parse

* update forc docs for --use-orig-parser
2022-04-21 12:09:00 +08:00