-
Notifications
You must be signed in to change notification settings - Fork 424
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
split initialization on param, type, and refs #14565
Comments
mppf
added a commit
that referenced
this issue
Dec 12, 2019
Split initialization This PR adds support for split initialization of Chapel variables. Resolves #14271 which contains design discussion. When a variable is declared without an initialization expression (including possibly without a type), the compiler will search for a following assignment and make that assignment initialize the variable. The following assignment must be the first usage of the variable on that control path. It can be contained in a nested block or a conditional but not in a loop, begin, on statement, or function. For example: ``` chapel var a; a = 2; // equivalent to `var a = 2` const r: MyGenericRecord; r = new MyGenericRecord(1); // equivalent to // const r:MyGenericRecord = new MyGenericRecord(1) ``` The implementation approach in the compiler is to adjust the normalization of variable initialization. Additionally, at parse time, mark variables that are declared without a type and without an initialization expression as requiring split initialization. At normalization time, the compiler searches for applicable assignment statements (called with `findInitPoints`). If these are found, it normalizes the declaration into `PRIM_INIT_VAR_SPLIT_DECL` and the assignment statements into `PRIM_INIT_VAR_SPLIT_INIT`. Function resolution then handles these. This PR also includes some changes to misc.cpp for reporting instantiations. In particular, the code previously stored an `FnSymbol*` for the last function for which an error was printed. That can go wrong if this function is deleted in the meantime. So, it now uses integer ids instead. Additionally, this PR includes changes to the representation of `on` statements for local compilation. These are now represented with `PRIM_BLOCK_ELIDED_ON` and changed into regular blocks in createTaskFunctions. PR #14594 contains the spec changes for this feature. Future Work: * split initialization for `param`, `type`, `const ref`, and `ref` #14565 * issue #14621 discusses the interaction between split initialization and nested functions Reviewed by @vasslitvinov - thanks! - [x] full local testing - [x] primers pass with GASNet - [x] primers pass with numa locale model
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
PR #14564 adds split initialization for
var
andconst
declarations.This issue tracks the feature request to add it for
param
,type
,ref
, andconst ref
declarations.The text was updated successfully, but these errors were encountered: