-
-
Notifications
You must be signed in to change notification settings - Fork 48
Refactor typechecker #995
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
Merged
Merged
Refactor typechecker #995
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
f54847b
Simplify semantic warnings
WardBrian 8009764
Remove unused functions
WardBrian bb4a577
New typechecker
WardBrian 2b539db
Remove old semantic_error and reorganize
WardBrian 6c44bc4
Merge master
WardBrian d8a52b8
Also move warnings back to frontend
WardBrian 3f8efee
Merge branch 'master' into rewrite-typechecker
WardBrian 6cd7d34
Fix stan2tfp test output
WardBrian 5d0c2d9
Merge branch 'master' into rewrite-typechecker
WardBrian 735de86
Changes per review
WardBrian 92ce1a8
Clean up distribution suffix logic
WardBrian 00811c6
Changes per review
WardBrian 17c5318
Changes per review
WardBrian 067d664
Don't directly print warnings
WardBrian f995407
Merge branch 'master' into rewrite-typechecker
WardBrian b645b7f
Remove broken test
WardBrian 6e614c9
Update information flow graphic
WardBrian ab081ad
Update readme
WardBrian d7e0910
Merge branch 'master' into rewrite-typechecker
WardBrian b71724d
Merge branch 'master' into rewrite-typechecker
WardBrian 603f48c
Merge branch 'master' into rewrite-typechecker
WardBrian 31e04c1
Updates per latest review
WardBrian cc4cf50
Merge branch 'master' into rewrite-typechecker
WardBrian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| open Core_kernel | ||
| open Middle | ||
|
|
||
| (** Origin blocks, to keep track of where variables are declared *) | ||
| type originblock = | ||
| | MathLibrary | ||
| | Functions | ||
| | Data | ||
| | TData | ||
| | Param | ||
| | TParam | ||
| | Model | ||
| | GQuant | ||
| [@@deriving sexp] | ||
|
|
||
| type varinfo = {origin: originblock; global: bool; readonly: bool} | ||
| [@@deriving sexp] | ||
|
|
||
| type info = | ||
| { type_: UnsizedType.t | ||
| ; kind: | ||
| [ `Variable of varinfo | ||
| | `UserDeclared of Location_span.t | ||
| | `StanMath | ||
| | `UserDefined ] } | ||
| [@@deriving sexp] | ||
|
|
||
| type t = info list String.Map.t | ||
|
|
||
| let create () = | ||
| let functions = | ||
| Hashtbl.to_alist Stan_math_signatures.stan_math_signatures | ||
| |> List.map ~f:(fun (key, values) -> | ||
| ( key | ||
| , List.map | ||
| ~f:(fun (rt, args, mem) -> | ||
| let type_ = | ||
| UnsizedType.UFun (args, rt, Fun_kind.FnPlain, mem) | ||
| in | ||
| {type_; kind= `StanMath} ) | ||
| values ) ) | ||
WardBrian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| |> String.Map.of_alist_exn | ||
| in | ||
| functions | ||
|
|
||
| let add env key type_ kind = Map.add_multi env ~key ~data:{type_; kind} | ||
|
|
||
| let add_all_raw env key data = | ||
| let env = Map.remove env key in | ||
| List.fold ~init:env ~f:(fun env data -> Map.add_multi env ~key ~data) data | ||
WardBrian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| let find env key = Map.find_multi env key | ||
| let mem env key = Map.mem env key | ||
| let iter env f = Map.iter env ~f | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| open Middle | ||
WardBrian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| type originblock = | ||
| | MathLibrary | ||
| | Functions | ||
| | Data | ||
| | TData | ||
| | Param | ||
| | TParam | ||
| | Model | ||
| | GQuant | ||
| [@@deriving sexp] | ||
|
|
||
| type varinfo = {origin: originblock; global: bool; readonly: bool} | ||
| [@@deriving sexp] | ||
|
|
||
| type info = | ||
| { type_: UnsizedType.t | ||
| ; kind: | ||
| [ `Variable of varinfo | ||
| | `UserDeclared of Location_span.t | ||
| | `StanMath | ||
| | `UserDefined ] } | ||
| [@@deriving sexp] | ||
|
|
||
| type t | ||
|
|
||
| val create : unit -> t | ||
| val find : t -> string -> info list | ||
|
|
||
| val add : | ||
| t | ||
| -> string | ||
| -> Middle.UnsizedType.t | ||
| -> [ `UserDeclared of Location_span.t | ||
| | `StanMath | ||
| | `UserDefined | ||
| | `Variable of varinfo ] | ||
| -> t | ||
|
|
||
| val add_all_raw : t -> string -> info list -> t | ||
| val mem : t -> string -> bool | ||
| val iter : t -> (info list -> unit) -> unit | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.