sclass LASScope { // do we use FixedVarContext instead of FlexibleVarContext settable bool useFixedVars; // variables declared in this scope, with type/value description gettable new Map<S, LASValueDescriptor> declaredVars; // optional parent scope // (we can see the parent's variables in this scope too, unless they // are redeclared) settable LASScope parentScope; // true = we may outlive the parent scope // (e.g. when we're a lambda) settable bool parentIsDetached; // sorted names when scope is finalized (resolved) S[] names; *() {} *(LASScope *parentScope) {} bool resolved() { ret names != null; } void addDeclaredVar(S name, LASValueDescriptor type) { if (resolved()) fail("Can't add variables to resolved scope"); declaredVars.put(name, type); } int resolveVar(S name) { resolve(); int idx = indexOfInSortedArray(names, name); if (idx < 0) fail("Variable not found in scope: " + name); ret idx; } void resolve { if (names != null) ret; names = empty(declaredVars) ? null : toStringArray(sortedKeys(declaredVars)); } }
Began life as a copy of #1035285
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036501 |
Snippet name: | LASScope - a variable scope created during script parsing (old) |
Eternal ID of this version: | #1036501/1 |
Text MD5: | 3267c33e0dc514264395f2761f33ef9f |
Author: | stefan |
Category: | javax / parsing |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-01-01 19:36:19 |
Source code size: | 1193 bytes / 44 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 134 / 142 |
Referenced in: | [show references] |