Revert "thing that needs to be reverted"
This reverts commit 6dedd87260.
This commit is contained in:
@@ -1 +0,0 @@
|
||||
{}
|
||||
+1
-1
@@ -1078,7 +1078,7 @@ class Checker {
|
||||
return et;
|
||||
default:
|
||||
}
|
||||
case EFor(k, v, it, e):
|
||||
case EFor(v, it, e):
|
||||
var locals = saveLocals();
|
||||
var itt = typeExpr(it, Value);
|
||||
var vt = switch( follow(itt) ) {
|
||||
|
||||
+1
-2
@@ -54,7 +54,7 @@ enum Expr {
|
||||
ECall( e : Expr, params : Array<Expr> );
|
||||
EIf( cond : Expr, e1 : Expr, ?e2 : Expr );
|
||||
EWhile( cond : Expr, e : Expr );
|
||||
EFor( k : String, v : String, it : Expr, e : Expr );
|
||||
EFor( v : String, it : Expr, e : Expr );
|
||||
EBreak;
|
||||
EContinue;
|
||||
EFunction( args : Array<Argument>, e : Expr, ?name : String, ?ret : CType );
|
||||
@@ -115,7 +115,6 @@ enum Error {
|
||||
EInvalidPreprocessor( msg : String );
|
||||
EUnknownVariable( v : String );
|
||||
EInvalidIterator( v : String );
|
||||
EInvalidKeyValueIterator( v : String );
|
||||
EInvalidOp( op : String );
|
||||
EInvalidAccess( f : String );
|
||||
ECustom( msg : String );
|
||||
|
||||
+14
-55
@@ -172,7 +172,6 @@ class Interp {
|
||||
if (Type.typeof(scriptObject) == TObject) {
|
||||
Reflect.setField(scriptObject, id, v);
|
||||
} else {
|
||||
#if !web
|
||||
if (__instanceFields.contains(id)) {
|
||||
Reflect.setProperty(scriptObject, id, v);
|
||||
} else if (__instanceFields.contains('set_$id')) { // setter
|
||||
@@ -180,13 +179,6 @@ class Interp {
|
||||
} else {
|
||||
setVar(id, v);
|
||||
}
|
||||
#else
|
||||
try {
|
||||
Reflect.setProperty(scriptObject, id, v);
|
||||
} catch(e) {
|
||||
setVar(id, v);
|
||||
}
|
||||
#end
|
||||
}
|
||||
} else {
|
||||
setVar(id, v);
|
||||
@@ -227,7 +219,6 @@ class Interp {
|
||||
var l = locals.get(id);
|
||||
v = fop(expr(e1), expr(e2));
|
||||
if (l == null) {
|
||||
#if !web
|
||||
if (__instanceFields.contains(id)) {
|
||||
Reflect.setProperty(scriptObject, id, v);
|
||||
} else if (__instanceFields.contains('set_$id')) { // setter
|
||||
@@ -235,13 +226,6 @@ class Interp {
|
||||
} else {
|
||||
setVar(id, v);
|
||||
}
|
||||
#else
|
||||
try {
|
||||
Reflect.setProperty(scriptObject, id, v);
|
||||
} catch(e) {
|
||||
setVar(id, v);
|
||||
}
|
||||
#end
|
||||
}
|
||||
else
|
||||
l.r = v;
|
||||
@@ -346,7 +330,7 @@ class Interp {
|
||||
return v;
|
||||
}
|
||||
} catch(e) {
|
||||
error(ECustom('${Std.string(e)}'));
|
||||
error(ECustom('${e.toString()}'));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -526,8 +510,8 @@ class Interp {
|
||||
case EDoWhile(econd, e):
|
||||
doWhileLoop(econd, e);
|
||||
return null;
|
||||
case EFor(k, v, it, e):
|
||||
forLoop(k, v, it, e);
|
||||
case EFor(v, it, e):
|
||||
forLoop(v, it, e);
|
||||
return null;
|
||||
case EBreak:
|
||||
throw SBreak;
|
||||
@@ -767,47 +751,24 @@ class Interp {
|
||||
|
||||
function makeIterator(v:Dynamic):Iterator<Dynamic> {
|
||||
#if ((flash && !flash9) || (php && !php7 && haxe_ver < '4.0.0'))
|
||||
if (v.keyValueIterator != null)
|
||||
v = v.keyValueIterator();
|
||||
if (v.iterator != null)
|
||||
v = v.iterator();
|
||||
#else
|
||||
try
|
||||
v = v.keyValueIterator()
|
||||
v = v.iterator()
|
||||
catch (e:Dynamic) {};
|
||||
#end
|
||||
if (v.hasNext == null || v.next == null) {
|
||||
#if ((flash && !flash9) || (php && !php7 && haxe_ver < '4.0.0'))
|
||||
if (v.iterator != null)
|
||||
v = v.iterator();
|
||||
#else
|
||||
try
|
||||
v = v.iterator()
|
||||
catch (e:Dynamic) {};
|
||||
#end
|
||||
}
|
||||
if (v.hasNext == null || v.next == null)
|
||||
error(EInvalidIterator(v));
|
||||
return v;
|
||||
}
|
||||
|
||||
function forLoop(k, n, it, e) {
|
||||
function forLoop(n, it, e) {
|
||||
var old = declared.length;
|
||||
if (k != null) declared.push({n: k, old: locals.get(k), depth: depth});
|
||||
declared.push({n: n, old: locals.get(n), depth: depth});
|
||||
var it = makeIterator(expr(it));
|
||||
while (it.hasNext()) {
|
||||
var next = it.next();
|
||||
|
||||
if (k != null) {
|
||||
if (next != null && next is Dynamic && Reflect.hasField(next, "key") && Reflect.hasField(next, "value")) {
|
||||
trace("is key iterator");
|
||||
locals.set(k, {r: next.key, depth: depth});
|
||||
locals.set(n, {r: next.value, depth: depth});
|
||||
} else {
|
||||
error(EInvalidKeyValueIterator(Std.string(it)));
|
||||
return;
|
||||
}
|
||||
} else
|
||||
locals.set(n, {r: next, depth: depth});
|
||||
locals.set(n, {r: it.next(), depth: depth});
|
||||
try {
|
||||
expr(e);
|
||||
} catch (err:Stop) {
|
||||
@@ -835,8 +796,8 @@ class Interp {
|
||||
cast(map, haxe.Constraints.IMap<Dynamic, Dynamic>).set(key, value);
|
||||
}
|
||||
|
||||
public static var getRedirects:Map<String, (Dynamic->String->Dynamic)> = [];
|
||||
public static var setRedirects:Map<String, (Dynamic->String->Dynamic->Dynamic)> = [];
|
||||
public static var getRedirects:Map<String, Dynamic->String->Dynamic> = [];
|
||||
public static var setRedirects:Map<String, Dynamic->String->Dynamic->Dynamic> = [];
|
||||
|
||||
function get(o:Dynamic, f:String):Dynamic {
|
||||
if (o == null)
|
||||
@@ -855,13 +816,12 @@ class Interp {
|
||||
case _:
|
||||
null;
|
||||
};
|
||||
var cla = Type.getClass(o);
|
||||
if (cla != null && getRedirects.exists(cl = Type.getClassName(cla)) && (redirect = getRedirects[cl]) != null) {
|
||||
if (getRedirects.exists(cl = Type.getClassName(Type.getClass(o))) && (redirect = getRedirects[cl]) != null) {
|
||||
return redirect(o, f);
|
||||
} else {
|
||||
var v = null;
|
||||
if ((v = Reflect.getProperty(o, f)) == null && cla != null)
|
||||
v = Reflect.getProperty(cla, f);
|
||||
if ((v = Reflect.getProperty(o, f)) == null)
|
||||
v = Reflect.getProperty(Type.getClass(o), f);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
@@ -884,8 +844,7 @@ class Interp {
|
||||
case _:
|
||||
null;
|
||||
};
|
||||
var cla = Type.getClass(o);
|
||||
if (cla != null && setRedirects.exists(cl = Type.getClassName(cla)) && (redirect = setRedirects[cl]) != null)
|
||||
if (setRedirects.exists(cl = Type.getClassName(Type.getClass(o))) && (redirect = setRedirects[cl]) != null)
|
||||
return redirect(o, f, v);
|
||||
|
||||
Reflect.setProperty(o, f, v);
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ class Macro {
|
||||
EWhile(convert(c), convert(e), true);
|
||||
case EDoWhile(c, e):
|
||||
EWhile(convert(c), convert(e), false);
|
||||
case EFor(k, v, it, efor):
|
||||
case EFor(v, it, efor):
|
||||
#if (haxe_ver >= 4)
|
||||
var p = #if hscriptPos { file : p.file, min : e.pmin, max : e.pmax } #else p #end;
|
||||
EFor({ expr : EBinop(OpIn,{ expr : EConst(CIdent(v)), pos : p },convert(it)), pos : p }, convert(efor));
|
||||
|
||||
+5
-16
@@ -283,7 +283,7 @@ class Parser {
|
||||
case EUnop(_,prefix,e): !prefix && isBlock(e);
|
||||
case EWhile(_,e): isBlock(e);
|
||||
case EDoWhile(_,e): isBlock(e);
|
||||
case EFor(_,_,_,e): isBlock(e);
|
||||
case EFor(_,_,e): isBlock(e);
|
||||
case EReturn(e): e != null && isBlock(e);
|
||||
case ETry(_, _, _, e): isBlock(e);
|
||||
case EMeta(_, _, e): isBlock(e);
|
||||
@@ -534,8 +534,8 @@ class Parser {
|
||||
function mapCompr( tmp : String, e : Expr ) {
|
||||
if( e == null ) return null;
|
||||
var edef = switch( expr(e) ) {
|
||||
case EFor(k, v, it, e2):
|
||||
EFor(k, v, it, mapCompr(tmp, e2));
|
||||
case EFor(v, it, e2):
|
||||
EFor(v, it, mapCompr(tmp, e2));
|
||||
case EWhile(cond, e2):
|
||||
EWhile(cond, mapCompr(tmp, e2));
|
||||
case EDoWhile(cond, e2):
|
||||
@@ -636,22 +636,11 @@ class Parser {
|
||||
case "for":
|
||||
ensure(TPOpen);
|
||||
var vname = getIdent();
|
||||
var key:String = null;
|
||||
var tk = token();
|
||||
switch(tk) {
|
||||
case TOp("=>"):
|
||||
key = vname;
|
||||
vname = getIdent();
|
||||
ensureToken(TId("in"));
|
||||
case TId("in"):
|
||||
|
||||
default:
|
||||
unexpected(tk);
|
||||
}
|
||||
ensureToken(TId("in"));
|
||||
var eiter = parseExpr();
|
||||
ensure(TPClose);
|
||||
var e = parseExpr();
|
||||
mk(EFor(key, vname,eiter,e),p1,pmax(e));
|
||||
mk(EFor(vname,eiter,e),p1,pmax(e));
|
||||
case "break": mk(EBreak);
|
||||
case "continue": mk(EContinue);
|
||||
case "else": unexpected(TId(id));
|
||||
|
||||
+2
-6
@@ -200,11 +200,8 @@ class Printer {
|
||||
add(" while ( ");
|
||||
expr(cond);
|
||||
add(" )");
|
||||
case EFor(k, v, it, e):
|
||||
if (k != null)
|
||||
add('for($k=>$v in ');
|
||||
else
|
||||
add('for($v in ');
|
||||
case EFor(v, it, e):
|
||||
add("for( "+v+" in ");
|
||||
expr(it);
|
||||
add(" ) ");
|
||||
expr(e);
|
||||
@@ -343,7 +340,6 @@ class Printer {
|
||||
case EInvalidPreprocessor(str): "Invalid preprocessor (" + str + ")";
|
||||
case EUnknownVariable(v): "Unknown variable: "+v;
|
||||
case EInvalidIterator(v): "Invalid iterator: "+v;
|
||||
case EInvalidKeyValueIterator(v): "Invalid key-value iterator: "+v;
|
||||
case EInvalidOp(op): "Invalid operator: "+op;
|
||||
case EInvalidAccess(f): "Invalid access to field " + f;
|
||||
case ECustom(msg): msg;
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ class Tools {
|
||||
case EIf(c, e1, e2): f(c); f(e1); if( e2 != null ) f(e2);
|
||||
case EWhile(c, e): f(c); f(e);
|
||||
case EDoWhile(c, e): f(c); f(e);
|
||||
case EFor(_, _, it, e): f(it); f(e);
|
||||
case EFor(_, it, e): f(it); f(e);
|
||||
case EBreak,EContinue:
|
||||
case EFunction(_, e, _, _): f(e);
|
||||
case EReturn(e): if( e != null ) f(e);
|
||||
@@ -75,7 +75,7 @@ class Tools {
|
||||
case EIf(c, e1, e2): EIf(f(c),f(e1),if( e2 != null ) f(e2) else null);
|
||||
case EWhile(c, e): EWhile(f(c),f(e));
|
||||
case EDoWhile(c, e): EDoWhile(f(c),f(e));
|
||||
case EFor(k, v, it, e): EFor(k, v, f(it), f(e));
|
||||
case EFor(v, it, e): EFor(v, f(it), f(e));
|
||||
case EFunction(args, e, name, t): EFunction(args, f(e), name, t);
|
||||
case EReturn(e): EReturn(if( e != null ) f(e) else null);
|
||||
case EArray(e, i): EArray(f(e),f(i));
|
||||
|
||||
Reference in New Issue
Block a user