Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control flow analysis + more #28

Merged
merged 36 commits into from
Apr 16, 2021
Merged

Control flow analysis + more #28

merged 36 commits into from
Apr 16, 2021

Conversation

sezna
Copy link
Contributor

@sezna sezna commented Apr 9, 2021

I embarked on this branch to implement control flow analysis but, as these things go, I have run into a lot of other features to implement along the way. This branch, so far, includes:

  1. Enum expressions and instantiations (tagged sum types)
  2. Dead code and unreachable code warnings
  3. The ability to generate GraphViz for the control flow of the program
  4. Unit type annotations

Alex Hansen and others added 30 commits March 30, 2021 12:08
* begin swappnig over to resolved types

* progress in refactore

* progress on converting types

* progress in switching to resolved types

* progress in switching to resolved types

* finalize refactor to resolved types

* remove unused type variants

* fix tests
sezna and others added 6 commits April 15, 2021 11:28
* begin analysis on return paths

* refactor of files

* begin work on analyzing return paths

* basic return path graph construction done

* documentation
@sezna sezna marked this pull request as ready for review April 15, 2021 23:59
@sezna
Copy link
Contributor Author

sezna commented Apr 16, 2021

Almost all control flow analysis is done. The rest can be done piecemeal, I think we can start working on other things now.

@sezna sezna merged commit a20104f into parser_v1 Apr 16, 2021
@sezna sezna deleted the control_flow_analysis branch April 16, 2021 00:35
sezna added a commit that referenced this pull request May 8, 2021
* initial parsing work

* parse trait declarations

* import statements

* clean lexer tree; support method calls

* basic ast skeleton beginnings

* begin ast work

* checkpoint while i swap computers

* more ast parsing

* more ast parsing

* ast: function appl, func decl, var exp

* ast: literals

* add compiler binary with nice error messages

* ast: return statements, use statements

* fix error message

* ast: traits

* more friendly parse error messages

* old email

* semicolons!

* byte literals; fix tests

* parse binary and hex literals for byte and bytes32

* refactor expression parsing

* parse array exprs

* parse operator expressions

* type ascriptions

* parser: polymorphism and trait bounds

* default to u64 instead of u32

* begin work on match statements

* parse structs

* refactor

* a few program examples; parse match statements

* lex struct expressions

* parse to AST struct expressions

* compile warnings!

* assert_or_warn macro

* generic struct parameters

* parse contract/script/predicate

* improve top level failure error message

* s/ast/parse_tree

* enums

* begin semantic analysis

* begin work on type checking, inferencing, and semantics checking (#11)

* begin work on type checking, inferencing, and semantics checking

* fmt

* WIP; laptop dying

* match branch types

* wip type code blocks

* build failure

* operator parsing; no precedence

* compile fn

* run compile instead of parse from hllc

* begin trait declarations in ast

* return statements in AST

* allow code blocks

* handle implicit returns in code blocks

* type checking is taking shape

* generic type checking

* return multiple errors

* proper operator precedence

* add fn params to namespace when typechecking

* contextual error messages

* remove todo panics

* toml update

* small error msg tweak

* Refactor error and warning handling (#12)

* begin refactor of error/warnings

* finish refactor

* type check predicates

* limit number of script main functions

* parse generic types for traits

* grammar for reassignments and while loops

* variable reassignments; while loops

* check generic type params in function declarations

* fix tests

* grammar for inline asm

* Asm expressions (#13)

* begin implementing asm expressions

* WIP asm parsing

* fix up spans; unused value warning

* progress on trait impl

* impl traits

* big refactor

* fix asm op parsing error

* parsing for method applications

* struct expressions and declarations: type inference

* WIP subfield exprs

* subfield expressions

* baaasic method invocations

* impl self; better struct declarations

* begin package manager work

* begin work on package manager

* WIP checkpoint

* forc build MVP implemenation

* dependency resolution v1

* Namespace refactor (#22)

* begin namespace refactor

* move all hashmaps to namespace type

* compiles imported dependencies

* method not found error

* resolve some warnings

* fix Self type in trait implementations

* fix all warnings

* fix todo error messages

* introduce differentiation between generic and struct types

* refactor struct expression typing to use declarations

* fix lack of self type in trait implementation

* refactor typed expressions

* fix impl self namespace bug

* fix implicit return typechecking bug

* re-introduce function applications

* type check function return statements

* remove hllc

* fix only last expr having type annotation; if branch enforcement of having an else

* Control flow analysis + more (#28)

* begin documentation of control flow analysis algorithm

* begin graph construction

* begin graph construction

* generate graphs; further control flow work

* some improvements in control flow; still need to wire up imports into the control flow graph

* control flow graph improvements

* fix up implicit return printing in control flow graph

* organize graph code

* find dead code

* unreachable code warnings

* parse unit type as type info

* start enum expressions

* fix enum lookup bug

* type check all enum instantiations

* Resolved types (#29)

* begin swappnig over to resolved types

* progress in refactore

* progress on converting types

* progress in switching to resolved types

* progress in switching to resolved types

* finalize refactor to resolved types

* remove unused type variants

* fix tests

* enum variant construction code analysis

* resolve warnings

* missing enum instantiator error

* trait declarations control flow

* fix trait type mismatch error message

* individual method dead code warnings

* fix method call bug

* respect public visibility modifiers; control flow analysis on libraries

* add public traits

* move ident file

* begin analysis on return paths

* refactor of files

* begin work on analyzing return paths

* basic return path graph construction done

* documentation

* Return path analysis (#30)

* begin analysis on return paths

* refactor of files

* begin work on analyzing return paths

* basic return path graph construction done

* documentation

* fix code block type parsing

* control flow analysis on if and code blocks

* struct fields in graph

* individual struct field warnings

* add line_col method for errors and warnings

* Generate Assembly (#31)

* begin generating assembly

* add unique registers counter to asm expressions

* sketch out asm generation with todo! macros everywhere

* begin while loop assembly

* rework compile fn for asm

* have to commit to save my progress as i boot into windows for fortnite

* make progress in expression generation

* WIP: return statements

* asm expressions and asm refactor

* very basic bytecode compilation

* first asm!

* ASM: While loops and reassignments

* remove subsequent jumps

* reuse data section values for duplicate literals

* struct expressions

* fix SW order

* stashing checkpoint

* forgotten add

* asm for enum instantiations

* if expression assembly generation

* code block asm generation

* remove TODO in code analysis

* remove some panics

* remove a bunch of todo panics

Co-authored-by: Alexander Hansen <alexanderhansen@Alexanders-MacBook-Pro.local>

* move license; clean warnings

* Update forc/src/cli/build.rs

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update forc/src/cli/build.rs

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* code review feedback

* Update forc/src/manifest.rs

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Update parser/src/control_flow_analysis/analyze_return_paths.rs

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* more PR feedback

* rename parser to core_lang

* add minimum supported version

* Update README.md

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* check that struct size in words fits in a u32 gracefully

* forgotten import

Co-authored-by: Alexander Hansen <alexanderhansen@Alexanders-MacBook-Pro.local>
Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
@adlerjohn adlerjohn added the compiler General compiler. Should eventually become more specific as the issue is triaged label May 12, 2021
leviathanbeak added a commit that referenced this pull request May 21, 2021
* initial parsing work

* parse trait declarations

* import statements

* clean lexer tree; support method calls

* basic ast skeleton beginnings

* begin ast work

* checkpoint while i swap computers

* more ast parsing

* more ast parsing

* ast: function appl, func decl, var exp

* ast: literals

* add compiler binary with nice error messages

* ast: return statements, use statements

* fix error message

* ast: traits

* more friendly parse error messages

* old email

* semicolons!

* byte literals; fix tests

* parse binary and hex literals for byte and bytes32

* refactor expression parsing

* parse array exprs

* parse operator expressions

* type ascriptions

* parser: polymorphism and trait bounds

* default to u64 instead of u32

* begin work on match statements

* parse structs

* refactor

* a few program examples; parse match statements

* lex struct expressions

* parse to AST struct expressions

* compile warnings!

* assert_or_warn macro

* generic struct parameters

* parse contract/script/predicate

* improve top level failure error message

* s/ast/parse_tree

* enums

* begin semantic analysis

* begin work on type checking, inferencing, and semantics checking (#11)

* begin work on type checking, inferencing, and semantics checking

* fmt

* WIP; laptop dying

* match branch types

* wip type code blocks

* build failure

* operator parsing; no precedence

* compile fn

* run compile instead of parse from hllc

* begin trait declarations in ast

* return statements in AST

* allow code blocks

* handle implicit returns in code blocks

* type checking is taking shape

* generic type checking

* return multiple errors

* proper operator precedence

* add fn params to namespace when typechecking

* contextual error messages

* remove todo panics

* toml update

* small error msg tweak

* Refactor error and warning handling (#12)

* begin refactor of error/warnings

* finish refactor

* type check predicates

* limit number of script main functions

* parse generic types for traits

* grammar for reassignments and while loops

* variable reassignments; while loops

* check generic type params in function declarations

* fix tests

* grammar for inline asm

* Asm expressions (#13)

* begin implementing asm expressions

* WIP asm parsing

* fix up spans; unused value warning

* progress on trait impl

* impl traits

* big refactor

* fix asm op parsing error

* parsing for method applications

* struct expressions and declarations: type inference

* WIP subfield exprs

* subfield expressions

* baaasic method invocations

* impl self; better struct declarations

* begin package manager work

* begin work on package manager

* WIP checkpoint

* forc build MVP implemenation

* dependency resolution v1

* Namespace refactor (#22)

* begin namespace refactor

* move all hashmaps to namespace type

* compiles imported dependencies

* method not found error

* resolve some warnings

* fix Self type in trait implementations

* fix all warnings

* fix todo error messages

* introduce differentiation between generic and struct types

* refactor struct expression typing to use declarations

* fix lack of self type in trait implementation

* refactor typed expressions

* fix impl self namespace bug

* fix implicit return typechecking bug

* re-introduce function applications

* type check function return statements

* remove hllc

* fix only last expr having type annotation; if branch enforcement of having an else

* Control flow analysis + more (#28)

* begin documentation of control flow analysis algorithm

* begin graph construction

* begin graph construction

* generate graphs; further control flow work

* some improvements in control flow; still need to wire up imports into the control flow graph

* control flow graph improvements

* fix up implicit return printing in control flow graph

* organize graph code

* find dead code

* unreachable code warnings

* parse unit type as type info

* start enum expressions

* fix enum lookup bug

* type check all enum instantiations

* Resolved types (#29)

* begin swappnig over to resolved types

* progress in refactore

* progress on converting types

* progress in switching to resolved types

* progress in switching to resolved types

* finalize refactor to resolved types

* remove unused type variants

* fix tests

* enum variant construction code analysis

* resolve warnings

* missing enum instantiator error

* trait declarations control flow

* fix trait type mismatch error message

* individual method dead code warnings

* fix method call bug

* respect public visibility modifiers; control flow analysis on libraries

* add public traits

* move ident file

* begin analysis on return paths

* refactor of files

* begin work on analyzing return paths

* basic return path graph construction done

* documentation

* Return path analysis (#30)

* begin analysis on return paths

* refactor of files

* begin work on analyzing return paths

* basic return path graph construction done

* documentation

* fix code block type parsing

* control flow analysis on if and code blocks

* struct fields in graph

* individual struct field warnings

* added ignore vscode local settings

* added forc commands and restructured files

* format code

* ignore node modules

* added syntax highlighting in vscode-forc

* rename to snippets

* change to fume

* added fume-server as a member

* updated .gitignore with ts files

* added vscode client

* update package.json

* added initial fume-server

* add line_col method for errors and warnings

* adding capabilities

* installed ropey

* update to new structure

* perform diagnostic

* added text_document

* remove unused

* cargo fmt

* clean up

* introduce better document state managment

* added hover and completion

* fixed ranges

* added semantic tokens, go to defnition

* remove other go_tos

* clean up

* update merging with master

* added clear names

* move to token references

* rename to get_diagnostics

* fix master conflicts

* make public fields

* use core_lang instead of parser

* adjust to new parse result

* update plugin start instructions

* fix typo

* clear both lines and values hashmaps

* remove unused enum fields

* move settings.json ignore to git/info/exclude

* re-added appache license

* added MANIFEST_FILE_NAME

* formatted toml files

* fromatted launch.json

* add static values for token types

* format

* fix typo

Co-authored-by: Alex <alex@42layers.io>
Co-authored-by: Alex Hansen <alex@alex-hansen.com>
@sezna sezna mentioned this pull request May 4, 2022
26 tasks
kayagokalp pushed a commit that referenced this pull request Aug 3, 2023
It looks like my previous rust-overlay update in #23 was a little early
and didn't include 1.64 yet. #23 didn't show any issues yet as none of
the packages at the time of that commit were released after 2022-09-23,
and so we didn't hit the error until the latest nightlies merged into
`master` with #27 which also didn't show any issues as it was was opened
before #23 was merged :')

This should fix it! It's probably worth enabling the same branch
protection we have on the Sway repo where merging a PR requires it's up
to date with `master` to avoid cases like this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler General compiler. Should eventually become more specific as the issue is triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants