Skip to content

Commit 2c54dd7

Browse files
committed
Imported function alias + README.md update
1 parent 2f112f1 commit 2c54dd7

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var map = new StrMap();
2626
map.set("Hello","World");
2727
trace(map.get("Hello")); // World
2828
```
29-
You also can use `in` keyword.
3029
```haxe
3130
import haxe.ds.StringMap in StrMap;
3231

rulescript/RuleScriptInterp.hx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class RuleScriptInterp extends hscript.Interp
66
{
77
public var scriptPackage:String = '';
88

9-
public var imports:Array<Dynamic> = [];
10-
public var usings:Array<Dynamic> = [];
9+
public var imports:Map<String, Dynamic> = [];
10+
public var usings:Map<String, Dynamic> = [];
1111

1212
override private function resetVariables()
1313
{
@@ -62,14 +62,19 @@ class RuleScriptInterp extends hscript.Interp
6262
error(ECustom('Type not found : $path'));
6363

6464
if (func != null && t is Class)
65-
variables.set(func, Reflect.getProperty(t, func));
65+
{
66+
var tag:String = alias ?? func;
67+
imports.set(tag, (variables[tag] = Reflect.getProperty(t, func)));
68+
}
6669
else
70+
{
6771
variables.set(name, t);
72+
}
6873
}
6974
case EUsing(name):
7075
var t:Dynamic = Type.resolveClass(name);
7176
if (t != null)
72-
usings.push(t);
77+
usings.set(name, t);
7378
default:
7479
return super.expr(expr);
7580
}

test/src/Main.hx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,26 @@ class Main
7171
return AliasReflect.getProperty(a,"hello");
7272
');
7373

74+
runScript('
75+
import Reflect.getProperty;
76+
77+
var a = {
78+
"hello":"world"
79+
};
80+
81+
return getProperty(a,"hello");
82+
');
83+
84+
runScript('
85+
import Reflect.getProperty as get;
86+
87+
var a = {
88+
"hello":"world"
89+
};
90+
91+
return get(a,"hello");
92+
');
93+
7494
runScript('
7595
using Reflect;
7696

0 commit comments

Comments
 (0)