Skip to content

Commit 4d1fee6

Browse files
committed
Public var
1 parent ddd88dd commit 4d1fee6

3 files changed

Lines changed: 22 additions & 7 deletions

File tree

rulescript/RuleScriptInterp.hx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,24 @@ class RuleScriptInterp extends hscript.Interp
169169
usings.set(name, t);
170170
case EMeta(name, args, e) if (onMeta != null):
171171
return onMeta(name, args, e);
172-
case EProp(n, g, s, type, e):
173-
declared.push({n: n, old: locals.get(n)});
172+
case EVar(n, _, e, global):
173+
if (global)
174+
variables.set(n, (e == null) ? null : this.expr(e));
175+
else
176+
{
177+
declared.push({n: n, old: locals.get(n)});
178+
locals.set(n, {r: (e == null) ? null : this.expr(e)});
179+
}
180+
return null;
181+
case EProp(n, g, s, type, e, global):
174182
var prop = createScriptProperty(n, g, s, type);
175-
locals.set(n, {r: prop});
183+
if (global)
184+
variables.set(n, prop);
185+
else
186+
{
187+
declared.push({n: n, old: locals.get(n)});
188+
locals.set(n, {r: prop});
189+
}
176190
if (e != null)
177191
prop._lazyValue = () -> this.expr(e);
178192
return null;

rulescript/Tools.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ class Tools
103103
case KVar(v):
104104
if (v.get == null && v.set == null)
105105
{
106-
pushExpr(EVar(field.name, v.type, v.expr));
106+
pushExpr(EVar(field.name, v.type, v.expr, field.access.contains(APublic)));
107107
}
108108
else
109109
{
110-
pushExpr(EProp(field.name, v.get, v.set, v.type, v.expr));
110+
pushExpr(EProp(field.name, v.get, v.set, v.type, v.expr, field.access.contains(APublic)));
111111
}
112112
}
113113
}

rulescript/macro/ExprMacro.hx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ExprMacro
1515
var pos = Context.currentPos();
1616

1717
for (field in fields)
18-
if (field.name == 'EFor')
18+
if (field.name == 'EFor' || field.name == 'EVar')
1919
fields.remove(field);
2020

2121
var newFields:Map<String, Expr> = [
@@ -24,7 +24,8 @@ class ExprMacro
2424
'EImport' => macro function(name:String, star:Bool, alias:String, func:String) {},
2525
'EUsing' => macro function(name:String) {},
2626

27-
'EProp' => macro function(n:String, g:String, s:String, ?t:CType, ?e:Expr) {},
27+
'EVar' => macro function(n:String, ?t:CType, ?e:Expr, ?global:Bool) {},
28+
'EProp' => macro function(n:String, g:String, s:String, ?t:CType, ?e:Expr, ?global:Bool) {},
2829

2930
'EFor' => macro function(key:String, it:Expr, e:Expr, ?value:String) {}
3031
];

0 commit comments

Comments
 (0)