Refactor Module into a single record type and fix system globals (#1383)
This commit is contained in:
1 parent
d681cb4c54
commit
a60bc386cb
20 files changed
+279
-215
No files matched your search
@@ -108,7 +108,7 @@ public class ControlFlow {
|
||||
LazyValue _trace = c.getVariable("_trace");
|
||||
c.setVariable("_trace", (__c, __t) -> MapValue.wrap(Map.of(
|
||||
StringValue.of("stack"), ListValue.wrap(ret.stack.stream().map(f -> ListValue.of(
|
||||
StringValue.of(f.getModule().getName()),
|
||||
StringValue.of(f.getModule().name()),
|
||||
StringValue.of(f.getString()),
|
||||
NumericValue.of(f.getToken().lineno+1),
|
||||
NumericValue.of(f.getToken().linepos+1)
|
||||
|
||||
@@ -431,15 +431,15 @@ public class Sys {
|
||||
{
|
||||
if (lv.size() == 0) throw new InternalExpressionException("'system_variable_get' expects at least a key to be fetched");
|
||||
Value key = lv.get(0).evalValue(c);
|
||||
if (lv.size() > 1) ScriptHost.systemGlobals.computeIfAbsent(key, k -> lv.get(1).evalValue(c));
|
||||
Value res = ScriptHost.systemGlobals.get(key);
|
||||
if (lv.size() > 1) c.host.scriptServer().systemGlobals.computeIfAbsent(key, k -> lv.get(1).evalValue(c));
|
||||
Value res = c.host.scriptServer().systemGlobals.get(key);
|
||||
if (res!=null) return (cc, tt) -> res;
|
||||
return LazyValue.NULL;
|
||||
});
|
||||
|
||||
expression.addBinaryFunction("system_variable_set", (key, value) ->
|
||||
expression.addContextFunction("system_variable_set", 2, (c, t, lv) ->
|
||||
{
|
||||
Value res = ScriptHost.systemGlobals.put(key, value);
|
||||
Value res = c.host.scriptServer().systemGlobals.put(lv.get(0), lv.get(1));
|
||||
if (res!=null) return res;
|
||||
return Value.NULL;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user