Compare commits
28
Commits
@@ -22,7 +22,6 @@ or set this in build.hxml
|
|||||||
|
|
||||||
Current Custom Class Limitations :
|
Current Custom Class Limitations :
|
||||||
|
|
||||||
- For now, you can only override functions from the current class, not from the extended part, like you cant override update in FlxText because FlxText doesnt have a update function overriden.
|
|
||||||
- You cannot create custom classes that extends a typed class (those ones that has `<T>`), this will be implemented in the future.
|
- You cannot create custom classes that extends a typed class (those ones that has `<T>`), this will be implemented in the future.
|
||||||
|
|
||||||
-----------
|
-----------
|
||||||
|
|||||||
+12
-12
@@ -55,7 +55,7 @@ class Async {
|
|||||||
- object access such obj.bar(a,b,c) are translated to obj.a_bar(function(r) ...rest, a, b, c)
|
- object access such obj.bar(a,b,c) are translated to obj.a_bar(function(r) ...rest, a, b, c)
|
||||||
- @async expr will execute the expression but continue without waiting for it to finish
|
- @async expr will execute the expression but continue without waiting for it to finish
|
||||||
- @split [ e1, e2, e3 ] is transformed to split(function(_) ...rest, [e1, e2, e3]) which
|
- @split [ e1, e2, e3 ] is transformed to split(function(_) ...rest, [e1, e2, e3]) which
|
||||||
should execute asynchronously all expressions - until they return - before continuing the execution
|
should execute asynchronously all expressions - until they return - before continuing the execution
|
||||||
- for(i in v) block; loops are translated to the following:
|
- for(i in v) block; loops are translated to the following:
|
||||||
var _i = makeIterator(v);
|
var _i = makeIterator(v);
|
||||||
function _loop() {
|
function _loop() {
|
||||||
@@ -170,7 +170,7 @@ class Async {
|
|||||||
return mk(EField(e, f), inf);
|
return mk(EField(e, f), inf);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function binop(op, e1, e2, inf) {
|
inline function binop(op:Binop, e1, e2, inf) {
|
||||||
return mk(EBinop(op, e1, e2), inf);
|
return mk(EBinop(op, e1, e2), inf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +294,7 @@ class Async {
|
|||||||
var efor = block([
|
var efor = block([
|
||||||
mk(EVar("_i" + id, call(ident("makeIterator",eit),[eit],eit)),eit),
|
mk(EVar("_i" + id, call(ident("makeIterator",eit),[eit],eit)),eit),
|
||||||
fun("_", block([
|
fun("_", block([
|
||||||
mk(EIf(mk(EUnop("!", true, call( field(it, "hasNext", it), [], it)),it), currentBreak(it)),it),
|
mk(EIf(mk(EUnop(Unop.OpNot, true, call( field(it, "hasNext", it), [], it)),it), currentBreak(it)),it),
|
||||||
mk(EVar(v, call(field(it, "next",it), [], it)), it),
|
mk(EVar(v, call(field(it, "next",it), [], it)), it),
|
||||||
toCps(eloop, loop, exit),
|
toCps(eloop, loop, exit),
|
||||||
], it),"_loop" + id),
|
], it),"_loop" + id),
|
||||||
@@ -303,11 +303,11 @@ class Async {
|
|||||||
currentLoop = oldLoop;
|
currentLoop = oldLoop;
|
||||||
currentBreak = oldBreak;
|
currentBreak = oldBreak;
|
||||||
return efor;
|
return efor;
|
||||||
case EUnop(op = "!", prefix, eop):
|
case EUnop(op = Unop.OpNot, prefix, eop):
|
||||||
return toCps(eop, fun("_r",call(rest, [mk(EUnop(op, prefix, ident("_r",e)),e)], e)), exit);
|
return toCps(eop, fun("_r",call(rest, [mk(EUnop(op, prefix, ident("_r",e)),e)], e)), exit);
|
||||||
case EBinop(op, e1, e2):
|
case EBinop(op, e1, e2):
|
||||||
switch( op ) {
|
switch( op ) {
|
||||||
case "=", "+=", "-=", "/=", "*=", "%=", "&=", "|=", "^=":
|
case OpAssign, OpAddAssign, OpSubAssign, OpDivAssign, OpMultAssign, OpModAssign, OpAndAssign, OpOrAssign, OpXorAssign:
|
||||||
switch( expr(e1) ) {
|
switch( expr(e1) ) {
|
||||||
case EIdent(_):
|
case EIdent(_):
|
||||||
var id = "_r" + uid++;
|
var id = "_r" + uid++;
|
||||||
@@ -326,14 +326,14 @@ class Async {
|
|||||||
default:
|
default:
|
||||||
throw "assert " + e1;
|
throw "assert " + e1;
|
||||||
}
|
}
|
||||||
case "||":
|
case OpBoolOr:
|
||||||
var id1 = "_r" + uid++;
|
var id1 = "_r" + uid++;
|
||||||
var id2 = "_r" + uid++;
|
var id2 = "_r" + uid++;
|
||||||
return toCps(e1, fun(id1, mk(EIf(binop("==", ident(id1,e1), ident("true",e1), e1),call(rest,[ident("true",e1)],e1),toCps(e2, rest, exit)),e)), exit);
|
return toCps(e1, fun(id1, mk(EIf(binop(OpEq, ident(id1,e1), ident("true",e1), e1),call(rest,[ident("true",e1)],e1),toCps(e2, rest, exit)),e)), exit);
|
||||||
case "&&":
|
case OpBoolAnd:
|
||||||
var id1 = "_r" + uid++;
|
var id1 = "_r" + uid++;
|
||||||
var id2 = "_r" + uid++;
|
var id2 = "_r" + uid++;
|
||||||
return toCps(e1, fun(id1, mk(EIf(binop("!=", ident(id1,e1), ident("true",e1), e1),call(rest,[ident("false",e1)],e1),toCps(e2, rest, exit)),e)), exit);
|
return toCps(e1, fun(id1, mk(EIf(binop(OpNeq, ident(id1,e1), ident("true",e1), e1),call(rest,[ident("false",e1)],e1),toCps(e2, rest, exit)),e)), exit);
|
||||||
default:
|
default:
|
||||||
var id1 = "_r" + uid++;
|
var id1 = "_r" + uid++;
|
||||||
var id2 = "_r" + uid++;
|
var id2 = "_r" + uid++;
|
||||||
@@ -364,7 +364,7 @@ class Async {
|
|||||||
fields.reverse();
|
fields.reverse();
|
||||||
for( f in fields )
|
for( f in fields )
|
||||||
rest = toCps(f.e, fun("_r", block([
|
rest = toCps(f.e, fun("_r", block([
|
||||||
binop("=", mk(EField(ident(id,f.e), f.name),f.e), ident("_r",f.e), f.e),
|
binop(OpAssign, mk(EField(ident(id,f.e), f.name),f.e), ident("_r",f.e), f.e),
|
||||||
rest,
|
rest,
|
||||||
],f.e)),exit);
|
],f.e)),exit);
|
||||||
return block([
|
return block([
|
||||||
@@ -378,7 +378,7 @@ class Async {
|
|||||||
while( i >= 0 ) {
|
while( i >= 0 ) {
|
||||||
var e = el[i];
|
var e = el[i];
|
||||||
rest = toCps(e, fun("_r", block([
|
rest = toCps(e, fun("_r", block([
|
||||||
binop("=", mk(EArray(ident(id,e), mk(EConst(CInt(i)),e)),e), ident("_r",e), e),
|
binop(OpAssign, mk(EArray(ident(id,e), mk(EConst(CInt(i)),e)),e), ident("_r",e), e),
|
||||||
rest,
|
rest,
|
||||||
],e)), exit);
|
],e)), exit);
|
||||||
i--;
|
i--;
|
||||||
@@ -396,7 +396,7 @@ class Async {
|
|||||||
return block([e, retNull(rest, e)], e);
|
return block([e, retNull(rest, e)], e);
|
||||||
return block([
|
return block([
|
||||||
mk(EVar(v, t),e),
|
mk(EVar(v, t),e),
|
||||||
toCps(ev, fun("_r", block([binop("=", ident(v,e), ident("_r",e), e), retNull(rest,e)], e)), exit),
|
toCps(ev, fun("_r", block([binop(OpAssign, ident(v,e), ident("_r",e), e), retNull(rest,e)], e)), exit),
|
||||||
],e);
|
],e);
|
||||||
case EConst(_), EIdent(_), EUnop(_), EField(_):
|
case EConst(_), EIdent(_), EUnop(_), EField(_):
|
||||||
return call(rest, [e], e);
|
return call(rest, [e], e);
|
||||||
|
|||||||
+4
-4
@@ -156,11 +156,11 @@ class Bytes {
|
|||||||
doEncode(e);
|
doEncode(e);
|
||||||
doEncodeString(f);
|
doEncodeString(f);
|
||||||
case EBinop(op,e1,e2):
|
case EBinop(op,e1,e2):
|
||||||
doEncodeString(op);
|
doEncodeString(op.toString());
|
||||||
doEncode(e1);
|
doEncode(e1);
|
||||||
doEncode(e2);
|
doEncode(e2);
|
||||||
case EUnop(op,prefix,e):
|
case EUnop(op,prefix,e):
|
||||||
doEncodeString(op);
|
doEncodeString(op.toString()); // maybe doEncodeInt
|
||||||
bout.addByte(prefix?1:0);
|
bout.addByte(prefix?1:0);
|
||||||
doEncode(e);
|
doEncode(e);
|
||||||
case ECall(e,el):
|
case ECall(e,el):
|
||||||
@@ -278,11 +278,11 @@ class Bytes {
|
|||||||
var e = doDecode();
|
var e = doDecode();
|
||||||
EField(e,doDecodeString());
|
EField(e,doDecodeString());
|
||||||
case 6:
|
case 6:
|
||||||
var op = doDecodeString();
|
var op = Binop.fromString(doDecodeString());
|
||||||
var e1 = doDecode();
|
var e1 = doDecode();
|
||||||
EBinop(op,e1,doDecode());
|
EBinop(op,e1,doDecode());
|
||||||
case 7:
|
case 7:
|
||||||
var op = doDecodeString();
|
var op = Unop.fromString(doDecodeString());
|
||||||
var prefix = bin.get(pin++) != 0;
|
var prefix = bin.get(pin++) != 0;
|
||||||
EUnop(op,prefix,doDecode());
|
EUnop(op,prefix,doDecode());
|
||||||
case 8:
|
case 8:
|
||||||
|
|||||||
+30
-16
@@ -1073,10 +1073,10 @@ class Checker {
|
|||||||
case EUnop(op, _, e):
|
case EUnop(op, _, e):
|
||||||
var et = typeExpr(e, Value);
|
var et = typeExpr(e, Value);
|
||||||
switch( op ) {
|
switch( op ) {
|
||||||
case "++", "--", "-":
|
case OpIncrement | OpDecrement | OpNeg:
|
||||||
unify(et,TInt,e);
|
unify(et,TInt,e);
|
||||||
return et;
|
return et;
|
||||||
case "!":
|
case OpNot:
|
||||||
unify(et,TBool,e);
|
unify(et,TBool,e);
|
||||||
return et;
|
return et;
|
||||||
default:
|
default:
|
||||||
@@ -1113,11 +1113,11 @@ class Checker {
|
|||||||
return TVoid;
|
return TVoid;
|
||||||
case EBinop(op, e1, e2):
|
case EBinop(op, e1, e2):
|
||||||
switch( op ) {
|
switch( op ) {
|
||||||
case "&", "|", "^", ">>", ">>>", "<<":
|
case OpAnd, OpOr, OpXor, OpShr, OpUshr, OpShl:
|
||||||
typeExprWith(e1,TInt);
|
typeExprWith(e1,TInt);
|
||||||
typeExprWith(e2,TInt);
|
typeExprWith(e2,TInt);
|
||||||
return TInt;
|
return TInt;
|
||||||
case "=":
|
case OpAssign:
|
||||||
if( allowDefine ) {
|
if( allowDefine ) {
|
||||||
switch( edef(e1) ) {
|
switch( edef(e1) ) {
|
||||||
case EIdent(i) if( !locals.exists(i) && !globals.exists(i) ):
|
case EIdent(i) if( !locals.exists(i) && !globals.exists(i) ):
|
||||||
@@ -1133,7 +1133,7 @@ class Checker {
|
|||||||
}
|
}
|
||||||
typeExprWith(e2,vt);
|
typeExprWith(e2,vt);
|
||||||
return vt;
|
return vt;
|
||||||
case "+":
|
case OpAdd:
|
||||||
var t1 = typeExpr(e1,WithType(TInt));
|
var t1 = typeExpr(e1,WithType(TInt));
|
||||||
var t2 = typeExpr(e2,WithType(t1));
|
var t2 = typeExpr(e2,WithType(t1));
|
||||||
tryUnify(t1,t2);
|
tryUnify(t1,t2);
|
||||||
@@ -1150,14 +1150,14 @@ class Checker {
|
|||||||
unify(t1, TFloat, e1);
|
unify(t1, TFloat, e1);
|
||||||
unify(t2, TFloat, e2);
|
unify(t2, TFloat, e2);
|
||||||
}
|
}
|
||||||
case "-", "*", "/", "%":
|
case OpSub, OpMult, OpDiv, OpMod:
|
||||||
var t1 = typeExpr(e1,WithType(TInt));
|
var t1 = typeExpr(e1,WithType(TInt));
|
||||||
var t2 = typeExpr(e2,WithType(t1));
|
var t2 = typeExpr(e2,WithType(t1));
|
||||||
if( !tryUnify(t1,t2) )
|
if( !tryUnify(t1,t2) )
|
||||||
unify(t2,t1,e2);
|
unify(t2,t1,e2);
|
||||||
switch( [follow(t1), follow(t2)]) {
|
switch( [follow(t1), follow(t2)]) {
|
||||||
case [TInt, TInt]:
|
case [TInt, TInt]:
|
||||||
if( op == "/" ) return TFloat;
|
if( op == OpDiv ) return TFloat;
|
||||||
return TInt;
|
return TInt;
|
||||||
case [TFloat|TDynamic, TInt|TDynamic], [TInt|TDynamic, TFloat|TDynamic], [TFloat, TFloat]:
|
case [TFloat|TDynamic, TInt|TDynamic], [TInt|TDynamic, TFloat|TDynamic], [TFloat, TFloat]:
|
||||||
return TFloat;
|
return TFloat;
|
||||||
@@ -1165,21 +1165,21 @@ class Checker {
|
|||||||
unify(t1, TFloat, e1);
|
unify(t1, TFloat, e1);
|
||||||
unify(t2, TFloat, e2);
|
unify(t2, TFloat, e2);
|
||||||
}
|
}
|
||||||
case "&&", "||":
|
case OpBoolAnd, OpBoolOr:
|
||||||
typeExprWith(e1,TBool);
|
typeExprWith(e1,TBool);
|
||||||
typeExprWith(e2,TBool);
|
typeExprWith(e2,TBool);
|
||||||
return TBool;
|
return TBool;
|
||||||
case "...":
|
case OpInterval:
|
||||||
typeExprWith(e1,TInt);
|
typeExprWith(e1,TInt);
|
||||||
typeExprWith(e2,TInt);
|
typeExprWith(e2,TInt);
|
||||||
return makeIterator(TInt);
|
return makeIterator(TInt);
|
||||||
case "==", "!=":
|
case OpEq, OpNeq:
|
||||||
var t1 = typeExpr(e1,Value);
|
var t1 = typeExpr(e1,Value);
|
||||||
var t2 = typeExpr(e2,WithType(t1));
|
var t2 = typeExpr(e2,WithType(t1));
|
||||||
if( !tryUnify(t1,t2) )
|
if( !tryUnify(t1,t2) )
|
||||||
unify(t2,t1,e2);
|
unify(t2,t1,e2);
|
||||||
return TBool;
|
return TBool;
|
||||||
case ">", "<", ">=", "<=":
|
case OpGt, OpLt, OpGte, OpLte:
|
||||||
var t1 = typeExpr(e1,Value);
|
var t1 = typeExpr(e1,Value);
|
||||||
var t2 = typeExpr(e2,WithType(t1));
|
var t2 = typeExpr(e2,WithType(t1));
|
||||||
if( !tryUnify(t1,t2) )
|
if( !tryUnify(t1,t2) )
|
||||||
@@ -1190,12 +1190,26 @@ class Checker {
|
|||||||
error("Cannot compare "+typeStr(t1), expr);
|
error("Cannot compare "+typeStr(t1), expr);
|
||||||
}
|
}
|
||||||
return TBool;
|
return TBool;
|
||||||
|
case OpAddAssign, OpSubAssign, OpMultAssign, OpDivAssign, OpModAssign, OpAndAssign, OpOrAssign, OpXorAssign, OpShlAssign, OpShrAssign, OpUshrAssign, OpNcoalAssign:
|
||||||
|
var baseOp = switch(op) {
|
||||||
|
case OpAddAssign: OpAdd;
|
||||||
|
case OpSubAssign: OpSub;
|
||||||
|
case OpMultAssign: OpMult;
|
||||||
|
case OpDivAssign: OpDiv;
|
||||||
|
case OpModAssign: OpMod;
|
||||||
|
case OpAndAssign: OpAnd;
|
||||||
|
case OpOrAssign: OpOr;
|
||||||
|
case OpXorAssign: OpXor;
|
||||||
|
case OpShlAssign: OpShl;
|
||||||
|
case OpShrAssign: OpShr;
|
||||||
|
case OpUshrAssign: OpUshr;
|
||||||
|
case OpNcoalAssign: OpNcoal;
|
||||||
|
default: op;
|
||||||
|
};
|
||||||
|
var t = typeExpr(mk(EBinop(baseOp,e1,e2),expr),withType);
|
||||||
|
return typeExpr(mk(EBinop(OpAssign,e1,e2),expr), withType);
|
||||||
default:
|
default:
|
||||||
if( op.charCodeAt(op.length-1) == "=".code ) {
|
error("Unsupported operation "+op.toString(), expr);
|
||||||
var t = typeExpr(mk(EBinop(op.substr(0,op.length-1),e1,e2),expr),withType);
|
|
||||||
return typeExpr(mk(EBinop("=",e1,e2),expr), withType);
|
|
||||||
}
|
|
||||||
error("Unsupported operation "+op, expr);
|
|
||||||
}
|
}
|
||||||
case ETry(etry, v, et, ecatch):
|
case ETry(etry, v, et, ecatch):
|
||||||
var vt = typeExpr(etry, withType);
|
var vt = typeExpr(etry, withType);
|
||||||
|
|||||||
@@ -21,4 +21,9 @@ class Config {
|
|||||||
public static final DISALLOW_ABSTRACT_AND_ENUM = [
|
public static final DISALLOW_ABSTRACT_AND_ENUM = [
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@:unreflective
|
||||||
|
public static final IMPORT_BLACKLIST:Array<String> = [
|
||||||
|
// "flixel.FlxG"
|
||||||
|
];
|
||||||
}
|
}
|
||||||
+13
-9
@@ -13,7 +13,6 @@ using Lambda;
|
|||||||
* @author Jamextreme140
|
* @author Jamextreme140
|
||||||
*/
|
*/
|
||||||
@:access(hscript.CustomClassHandler)
|
@:access(hscript.CustomClassHandler)
|
||||||
@:access(hscript.Property)
|
|
||||||
class CustomClass implements IHScriptCustomClassBehaviour {
|
class CustomClass implements IHScriptCustomClassBehaviour {
|
||||||
public var className(get, never):String;
|
public var className(get, never):String;
|
||||||
|
|
||||||
@@ -153,8 +152,12 @@ class CustomClass implements IHScriptCustomClassBehaviour {
|
|||||||
|
|
||||||
if (fn != null && Reflect.isFunction(fn))
|
if (fn != null && Reflect.isFunction(fn))
|
||||||
return UnsafeReflect.callMethodUnsafe(null, fn, (args == null) ? [] : args);
|
return UnsafeReflect.callMethodUnsafe(null, fn, (args == null) ? [] : args);
|
||||||
else
|
|
||||||
__interp.error(ECustom('$name doesn\'t exists or is not a function'));
|
// If not found in current class, try parent class recursively
|
||||||
|
if (__superClass != null && __superClass is CustomClass)
|
||||||
|
return cast(__superClass, CustomClass).call(name, args, toSuper);
|
||||||
|
|
||||||
|
__interp.error(ECustom('$name doesn\'t exists or is not a function'));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,9 +173,9 @@ class CustomClass implements IHScriptCustomClassBehaviour {
|
|||||||
var f = __interp.variables.get(name);
|
var f = __interp.variables.get(name);
|
||||||
if (f != null && allowProperty && f is Property) {
|
if (f != null && allowProperty && f is Property) {
|
||||||
var prop:Property = cast f;
|
var prop:Property = cast f;
|
||||||
prop.__allowSetGet = this.__allowSetGet;
|
//prop.__allowSetGet = this.__allowSetGet;
|
||||||
var r = prop.callGetter(name);
|
var r = prop.get(!__allowSetGet);
|
||||||
prop.__allowSetGet = null;
|
//prop.__allowSetGet = true;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
@@ -182,9 +185,9 @@ class CustomClass implements IHScriptCustomClassBehaviour {
|
|||||||
var f = getField(name, false);
|
var f = getField(name, false);
|
||||||
if (f != null && f is Property) {
|
if (f != null && f is Property) {
|
||||||
var prop:Property = cast f;
|
var prop:Property = cast f;
|
||||||
prop.__allowSetGet = this.__allowSetGet;
|
//prop.__allowSetGet = this.__allowSetGet;
|
||||||
var r = prop.callSetter(name, val);
|
var r = prop.set(val, !__allowSetGet);
|
||||||
prop.__allowSetGet = null;
|
//prop.__allowSetGet = true;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
__interp.variables.set(name, val);
|
__interp.variables.set(name, val);
|
||||||
@@ -350,6 +353,7 @@ class CustomClass implements IHScriptCustomClassBehaviour {
|
|||||||
return cls;
|
return cls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: scriptable "toString" function
|
||||||
public function toString():String
|
public function toString():String
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,23 +60,19 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip
|
|||||||
if(!__interp.variables.exists(f))
|
if(!__interp.variables.exists(f))
|
||||||
__interp.variables.set(f, v);
|
__interp.variables.set(f, v);
|
||||||
|
|
||||||
for(e in fields.copy()) {
|
for(i => e in fields.copy()) {
|
||||||
var validField:Bool = false;
|
var isValid:Bool = false;
|
||||||
var staticField:Bool = false;
|
var staticField:Bool = false;
|
||||||
var fieldName:String = "";
|
var fieldName:String = null;
|
||||||
switch (Tools.expr(e)) {
|
switch (Tools.expr(e)) {
|
||||||
case EVar(n, _, _, _, isStatic):
|
case EVar(n, _, _, _, isStatic) | EFunction(_, _, n, _, _, isStatic):
|
||||||
validField = true;
|
isValid = true;
|
||||||
staticField = isStatic;
|
|
||||||
fieldName = n;
|
|
||||||
case EFunction(_, _, n, _, _, isStatic, _, _, _, _):
|
|
||||||
validField = true;
|
|
||||||
staticField = isStatic;
|
staticField = isStatic;
|
||||||
fieldName = n;
|
fieldName = n;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
if(staticField && validField) {
|
if(staticField && isValid) {
|
||||||
__interp.exprReturn(e);
|
__interp.exprReturn(e);
|
||||||
__staticFields.push(fieldName);
|
__staticFields.push(fieldName);
|
||||||
fields.remove(e);
|
fields.remove(e);
|
||||||
@@ -88,7 +84,7 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip
|
|||||||
return new CustomClass(this, args);
|
return new CustomClass(this, args);
|
||||||
|
|
||||||
@:allow(hscript.Interp)
|
@:allow(hscript.Interp)
|
||||||
function hasField(name:String) {
|
inline function hasField(name:String) {
|
||||||
return __staticFields.contains(name);
|
return __staticFields.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,9 +92,9 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip
|
|||||||
var f = __interp.variables.get(name);
|
var f = __interp.variables.get(name);
|
||||||
if(f is Property && allowProperty) {
|
if(f is Property && allowProperty) {
|
||||||
var prop:Property = cast f;
|
var prop:Property = cast f;
|
||||||
prop.__allowSetGet = this.__allowSetGet;
|
//prop.__allowSetGet = this.__allowSetGet;
|
||||||
var r = prop.callGetter(name);
|
var r = prop.get(!__allowSetGet);
|
||||||
prop.__allowSetGet = null;
|
//prop.__allowSetGet = true;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
@@ -108,9 +104,9 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip
|
|||||||
var f = getField(name, false);
|
var f = getField(name, false);
|
||||||
if(f is Property) {
|
if(f is Property) {
|
||||||
var prop:Property = cast f;
|
var prop:Property = cast f;
|
||||||
prop.__allowSetGet = this.__allowSetGet;
|
//prop.__allowSetGet = this.__allowSetGet;
|
||||||
var r = prop.callSetter(name, val);
|
var r = prop.set(val, !__allowSetGet);
|
||||||
prop.__allowSetGet = null;
|
//prop.__allowSetGet = true;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
__interp.variables.set(name, val);
|
__interp.variables.set(name, val);
|
||||||
@@ -119,10 +115,9 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip
|
|||||||
|
|
||||||
public function hget(name:String):Dynamic {
|
public function hget(name:String):Dynamic {
|
||||||
if(name == 'new') {
|
if(name == 'new') {
|
||||||
var __constructor = Reflect.makeVarArgs(function(args:Array<Dynamic>) {
|
return Reflect.makeVarArgs(function(args:Array<Dynamic>):Dynamic {
|
||||||
return this.hnew(args);
|
return inline this.hnew(args);
|
||||||
});
|
});
|
||||||
return __constructor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasField(name)) {
|
if(hasField(name)) {
|
||||||
|
|||||||
+161
-2
@@ -28,6 +28,163 @@ typedef Int64 = #if cpp cpp.Int64 #elseif java java.Int64 #elseif cs cs.Int64 #e
|
|||||||
|
|
||||||
typedef UInt8 = #if cpp cpp.UInt8 #elseif cs cs.UInt8 #else Int #end;
|
typedef UInt8 = #if cpp cpp.UInt8 #elseif cs cs.UInt8 #else Int #end;
|
||||||
typedef UInt16 = #if cpp cpp.UInt16 #elseif cs cs.UInt16 #else Int #end;
|
typedef UInt16 = #if cpp cpp.UInt16 #elseif cs cs.UInt16 #else Int #end;
|
||||||
|
|
||||||
|
enum abstract Binop(Int) from Int to Int {
|
||||||
|
var OpAdd = 0;
|
||||||
|
var OpSub = 1;
|
||||||
|
var OpMult = 2;
|
||||||
|
var OpDiv = 3;
|
||||||
|
var OpMod = 4;
|
||||||
|
var OpAnd = 5;
|
||||||
|
var OpOr = 6;
|
||||||
|
var OpXor = 7;
|
||||||
|
var OpShl = 8;
|
||||||
|
var OpShr = 9;
|
||||||
|
var OpUshr = 10;
|
||||||
|
var OpEq = 11;
|
||||||
|
var OpNeq = 12;
|
||||||
|
var OpGte = 13;
|
||||||
|
var OpLte = 14;
|
||||||
|
var OpGt = 15;
|
||||||
|
var OpLt = 16;
|
||||||
|
var OpBoolOr = 17;
|
||||||
|
var OpBoolAnd = 18;
|
||||||
|
var OpIs = 19;
|
||||||
|
var OpAssign = 20;
|
||||||
|
var OpNcoal = 21;
|
||||||
|
var OpInterval = 22;
|
||||||
|
var OpArrow = 23;
|
||||||
|
var OpAddAssign = 24;
|
||||||
|
var OpSubAssign = 25;
|
||||||
|
var OpMultAssign = 26;
|
||||||
|
var OpDivAssign = 27;
|
||||||
|
var OpModAssign = 28;
|
||||||
|
var OpAndAssign = 29;
|
||||||
|
var OpOrAssign = 30;
|
||||||
|
var OpXorAssign = 31;
|
||||||
|
var OpShlAssign = 32;
|
||||||
|
var OpShrAssign = 33;
|
||||||
|
var OpUshrAssign = 34;
|
||||||
|
var OpNcoalAssign = 35;
|
||||||
|
var OpArrowFn = 36;
|
||||||
|
|
||||||
|
public static inline function fromString(s:String):Binop {
|
||||||
|
return switch(s) {
|
||||||
|
case "+": OpAdd;
|
||||||
|
case "-": OpSub;
|
||||||
|
case "*": OpMult;
|
||||||
|
case "/": OpDiv;
|
||||||
|
case "%": OpMod;
|
||||||
|
case "&": OpAnd;
|
||||||
|
case "|": OpOr;
|
||||||
|
case "^": OpXor;
|
||||||
|
case "<<": OpShl;
|
||||||
|
case ">>": OpShr;
|
||||||
|
case ">>>": OpUshr;
|
||||||
|
case "==": OpEq;
|
||||||
|
case "!=": OpNeq;
|
||||||
|
case ">=": OpGte;
|
||||||
|
case "<=": OpLte;
|
||||||
|
case ">": OpGt;
|
||||||
|
case "<": OpLt;
|
||||||
|
case "||": OpBoolOr;
|
||||||
|
case "&&": OpBoolAnd;
|
||||||
|
case "is": OpIs;
|
||||||
|
case "=": OpAssign;
|
||||||
|
case "??": OpNcoal;
|
||||||
|
case "...": OpInterval;
|
||||||
|
case "->": OpArrow;
|
||||||
|
case "=>": OpArrowFn;
|
||||||
|
case "+=": OpAddAssign;
|
||||||
|
case "-=": OpSubAssign;
|
||||||
|
case "*=": OpMultAssign;
|
||||||
|
case "/=": OpDivAssign;
|
||||||
|
case "%=": OpModAssign;
|
||||||
|
case "&=": OpAndAssign;
|
||||||
|
case "|=": OpOrAssign;
|
||||||
|
case "^=": OpXorAssign;
|
||||||
|
case "<<=": OpShlAssign;
|
||||||
|
case ">>=": OpShrAssign;
|
||||||
|
case ">>>=": OpUshrAssign;
|
||||||
|
case _ if (s == "??" + "="): OpNcoalAssign;
|
||||||
|
default: -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public inline function toString():String {
|
||||||
|
return switch(this) {
|
||||||
|
case OpAdd: "+";
|
||||||
|
case OpSub: "-";
|
||||||
|
case OpMult: "*";
|
||||||
|
case OpDiv: "/";
|
||||||
|
case OpMod: "%";
|
||||||
|
case OpAnd: "&";
|
||||||
|
case OpOr: "|";
|
||||||
|
case OpXor: "^";
|
||||||
|
case OpShl: "<<";
|
||||||
|
case OpShr: ">>";
|
||||||
|
case OpUshr: ">>>";
|
||||||
|
case OpEq: "==";
|
||||||
|
case OpNeq: "!=";
|
||||||
|
case OpGte: ">=";
|
||||||
|
case OpLte: "<=";
|
||||||
|
case OpGt: ">";
|
||||||
|
case OpLt: "<";
|
||||||
|
case OpBoolOr: "||";
|
||||||
|
case OpBoolAnd: "&&";
|
||||||
|
case OpIs: "is";
|
||||||
|
case OpAssign: "=";
|
||||||
|
case OpNcoal: "??";
|
||||||
|
case OpInterval: "...";
|
||||||
|
case OpArrow: "->";
|
||||||
|
case OpArrowFn: "=>";
|
||||||
|
case OpAddAssign: "+=";
|
||||||
|
case OpSubAssign: "-=";
|
||||||
|
case OpMultAssign: "*=";
|
||||||
|
case OpDivAssign: "/=";
|
||||||
|
case OpModAssign: "%=";
|
||||||
|
case OpAndAssign: "&=";
|
||||||
|
case OpOrAssign: "|=";
|
||||||
|
case OpXorAssign: "^=";
|
||||||
|
case OpShlAssign: "<<=";
|
||||||
|
case OpShrAssign: ">>=";
|
||||||
|
case OpUshrAssign: ">>>=";
|
||||||
|
case OpNcoalAssign: "??" + "=";
|
||||||
|
default: "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum abstract Unop(Int) from Int to Int {
|
||||||
|
var OpNot = 0;
|
||||||
|
var OpNeg = 1;
|
||||||
|
var OpIncrement = 2;
|
||||||
|
var OpDecrement = 3;
|
||||||
|
var OpNegBits = 4;
|
||||||
|
|
||||||
|
public static inline function fromString(s:String):Unop {
|
||||||
|
return switch(s) {
|
||||||
|
case "!": OpNot;
|
||||||
|
case "-": OpNeg;
|
||||||
|
case "++": OpIncrement;
|
||||||
|
case "--": OpDecrement;
|
||||||
|
case "~": OpNegBits;
|
||||||
|
default: -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public inline function toString():String {
|
||||||
|
return switch(this) {
|
||||||
|
case OpNot: "!";
|
||||||
|
case OpNeg: "-";
|
||||||
|
case OpIncrement: "++";
|
||||||
|
case OpDecrement: "--";
|
||||||
|
case OpNegBits: "~";
|
||||||
|
default: "?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
typedef UInt32 = #if cpp cpp.UInt32 #else Int #end;
|
typedef UInt32 = #if cpp cpp.UInt32 #else Int #end;
|
||||||
typedef UInt64 = #if cpp cpp.UInt64 #else Int #end;
|
typedef UInt64 = #if cpp cpp.UInt64 #else Int #end;
|
||||||
|
|
||||||
@@ -57,8 +214,8 @@ enum Expr {
|
|||||||
EParent( e : Expr );
|
EParent( e : Expr );
|
||||||
EBlock( e : Array<Expr> );
|
EBlock( e : Array<Expr> );
|
||||||
EField( e : Expr, f : String , ?safe : Bool );
|
EField( e : Expr, f : String , ?safe : Bool );
|
||||||
EBinop( op : String, e1 : Expr, e2 : Expr );
|
EBinop( op : Binop, e1 : Expr, e2 : Expr );
|
||||||
EUnop( op : String, prefix : Bool, e : Expr );
|
EUnop( op : Unop, prefix : Bool, e : Expr );
|
||||||
ECall( e : Expr, params : Array<Expr> );
|
ECall( e : Expr, params : Array<Expr> );
|
||||||
EIf( cond : Expr, e1 : Expr, ?e2 : Expr );
|
EIf( cond : Expr, e1 : Expr, ?e2 : Expr );
|
||||||
EWhile( cond : Expr, e : Expr );
|
EWhile( cond : Expr, e : Expr );
|
||||||
@@ -119,12 +276,14 @@ typedef Metadata = Array<MetadataEntry>;
|
|||||||
final class EnumDecl {
|
final class EnumDecl {
|
||||||
public var name : String;
|
public var name : String;
|
||||||
public var fields : Array<EnumField>;
|
public var fields : Array<EnumField>;
|
||||||
|
public var underlyingType : Null<CType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:structInit
|
@:structInit
|
||||||
final class EnumField {
|
final class EnumField {
|
||||||
public var name : String;
|
public var name : String;
|
||||||
public var args : Array<Argument>;
|
public var args : Array<Argument>;
|
||||||
|
public var value : Null<Expr>;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum CType {
|
enum CType {
|
||||||
|
|||||||
+119
-3
@@ -2,13 +2,13 @@ package hscript;
|
|||||||
|
|
||||||
import hscript.utils.UnsafeReflect;
|
import hscript.utils.UnsafeReflect;
|
||||||
|
|
||||||
// TODO: EnumTools for scripted enums
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for enums, both for real and scripted.
|
* Wrapper class for enums, both for real and scripted.
|
||||||
|
* Use EnumTools and EnumValueTools for enum operations.
|
||||||
*/
|
*/
|
||||||
@:structInit
|
@:structInit
|
||||||
class HEnum implements IHScriptCustomBehaviour {
|
class HEnum implements IHScriptCustomBehaviour {
|
||||||
private var enumValues(default, null) = {};
|
var enumValues(default, null) = {};
|
||||||
|
|
||||||
public function setEnum(name:String, enumValue:Dynamic):Void {
|
public function setEnum(name:String, enumValue:Dynamic):Void {
|
||||||
UnsafeReflect.setField(enumValues, name, enumValue);
|
UnsafeReflect.setField(enumValues, name, enumValue);
|
||||||
@@ -20,6 +20,10 @@ class HEnum implements IHScriptCustomBehaviour {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEnumValues():Dynamic {
|
||||||
|
return enumValues;
|
||||||
|
}
|
||||||
|
|
||||||
public function hget(name:String):Dynamic {
|
public function hget(name:String):Dynamic {
|
||||||
return getEnum(name);
|
return getEnum(name);
|
||||||
}
|
}
|
||||||
@@ -57,10 +61,122 @@ class HEnumValue {
|
|||||||
if (args.length != other.args.length)
|
if (args.length != other.args.length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (i in 0...args.length) // TODO: allow deep comparison, like arrays
|
for (i in 0...args.length)
|
||||||
if (args[i] != other.args[i])
|
if (args[i] != other.args[i])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@:nullSafety
|
||||||
|
class EnumTools {
|
||||||
|
public static function getConstructors(e:Dynamic):Array<String> {
|
||||||
|
if(Std.isOfType(e, HEnum)) {
|
||||||
|
var henum:HEnum = cast e;
|
||||||
|
return UnsafeReflect.fields(henum.getEnumValues());
|
||||||
|
}
|
||||||
|
return Type.getEnumConstructs(cast e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function createByName(e:Dynamic, constr:String, ?params:Array<Dynamic>):Dynamic {
|
||||||
|
if(Std.isOfType(e, HEnum)) {
|
||||||
|
var henum:HEnum = cast e;
|
||||||
|
var constructor = henum.getEnum(constr);
|
||||||
|
if(constructor == null)
|
||||||
|
throw 'Constructor $constr not found in enum';
|
||||||
|
if(Std.isOfType(constructor, HEnumValue))
|
||||||
|
return constructor;
|
||||||
|
if(Reflect.isFunction(constructor))
|
||||||
|
return constructor(params == null ? [] : params);
|
||||||
|
throw 'Invalid constructor type';
|
||||||
|
}
|
||||||
|
return Type.createEnum(cast e, constr, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function createByIndex(e:Dynamic, index:Int, ?params:Array<Dynamic>):Dynamic {
|
||||||
|
if(Std.isOfType(e, HEnum)) {
|
||||||
|
var constructors = getConstructors(e);
|
||||||
|
if(index < 0 || index >= constructors.length)
|
||||||
|
throw 'Index $index out of bounds for enum';
|
||||||
|
return createByName(e, constructors[index], params);
|
||||||
|
}
|
||||||
|
return Type.createEnumIndex(cast e, index, params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@:nullSafety
|
||||||
|
class EnumValueTools {
|
||||||
|
public static function getType(e:Dynamic):Null<String> {
|
||||||
|
if(Std.isOfType(e, HEnumValue)) {
|
||||||
|
var hv:HEnumValue = cast e;
|
||||||
|
return hv.enumName;
|
||||||
|
}
|
||||||
|
var en = Type.getEnum(e);
|
||||||
|
if(en != null)
|
||||||
|
return Type.getEnumName(en);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getName(e:Dynamic):String {
|
||||||
|
if(Std.isOfType(e, HEnumValue)) {
|
||||||
|
var hv:HEnumValue = cast e;
|
||||||
|
return hv.fieldName;
|
||||||
|
}
|
||||||
|
return Type.enumConstructor(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getParameters(e:Dynamic):Array<Dynamic> {
|
||||||
|
if(Std.isOfType(e, HEnumValue)) {
|
||||||
|
var hv:HEnumValue = cast e;
|
||||||
|
return hv.args.copy();
|
||||||
|
}
|
||||||
|
return Type.enumParameters(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getIndex(e:Dynamic):Int {
|
||||||
|
if(Std.isOfType(e, HEnumValue)) {
|
||||||
|
var hv:HEnumValue = cast e;
|
||||||
|
return hv.index;
|
||||||
|
}
|
||||||
|
return Type.enumIndex(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function equals(a:Dynamic, b:Dynamic):Bool {
|
||||||
|
if(Std.isOfType(a, HEnumValue) && Std.isOfType(b, HEnumValue)) {
|
||||||
|
var hva:HEnumValue = cast a;
|
||||||
|
var hvb:HEnumValue = cast b;
|
||||||
|
return hva.compare(hvb);
|
||||||
|
}
|
||||||
|
return Type.enumEq(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function match(e:Dynamic, pattern:Dynamic):Bool {
|
||||||
|
if(Std.isOfType(e, HEnumValue)) {
|
||||||
|
var hv:HEnumValue = cast e;
|
||||||
|
if(Std.isOfType(pattern, HEnumValue)) {
|
||||||
|
var hp:HEnumValue = cast pattern;
|
||||||
|
if(hv.enumName != hp.enumName || hv.fieldName != hp.fieldName)
|
||||||
|
return false;
|
||||||
|
if(hp.args.length == 0)
|
||||||
|
return true;
|
||||||
|
if(hv.args.length != hp.args.length)
|
||||||
|
return false;
|
||||||
|
for(i in 0...hp.args.length) {
|
||||||
|
var pa = hp.args[i];
|
||||||
|
if(pa != null && hv.args[i] != pa)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(Reflect.isObject(pattern)) {
|
||||||
|
var patternName = UnsafeReflect.hasField(pattern, "name") ? UnsafeReflect.field(pattern, "name") : null;
|
||||||
|
if(patternName != null && patternName != hv.fieldName)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Type.enumEq(e, pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+515
-301
File diff suppressed because it is too large
Load Diff
+5
-4
@@ -151,12 +151,13 @@ class Macro {
|
|||||||
case EField(e, f):
|
case EField(e, f):
|
||||||
EField(convert(e), f);
|
EField(convert(e), f);
|
||||||
case EBinop(op, e1, e2):
|
case EBinop(op, e1, e2):
|
||||||
var b = binops.get(op);
|
var b = binops.get(op.toString());
|
||||||
if( b == null ) throw EInvalidOp(op);
|
if( b == null ) throw EInvalidOp(op.toString());
|
||||||
EBinop(b, convert(e1), convert(e2));
|
EBinop(b, convert(e1), convert(e2));
|
||||||
case EUnop(op, prefix, e):
|
case EUnop(op, prefix, e):
|
||||||
var u = unops.get(op);
|
var opStr = op.toString();
|
||||||
if( u == null ) throw EInvalidOp(op);
|
var u = unops.get(opStr);
|
||||||
|
if( u == null ) throw EInvalidOp(opStr);
|
||||||
EUnop(u, !prefix, convert(e));
|
EUnop(u, !prefix, convert(e));
|
||||||
case ECall(e, params):
|
case ECall(e, params):
|
||||||
ECall(convert(e), map(params, convert));
|
ECall(convert(e), map(params, convert));
|
||||||
|
|||||||
+186
-165
@@ -215,7 +215,7 @@ class Parser {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function push(tk: Token):Void {
|
@:analyzer(fusion) inline function push(tk: Token):Void {
|
||||||
#if hscriptPos
|
#if hscriptPos
|
||||||
tokens.push( { t : tk, min : tokenMin, max : tokenMax } );
|
tokens.push( { t : tk, min : tokenMin, max : tokenMax } );
|
||||||
tokenMin = oldTokenMin;
|
tokenMin = oldTokenMin;
|
||||||
@@ -225,17 +225,17 @@ class Parser {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function ensure(tk:Token):Void {
|
@:analyzer(fusion) inline function ensure(tk:Token):Void {
|
||||||
var t = token();
|
var t = token();
|
||||||
if( t != tk ) unexpected(t);
|
if( t != tk ) unexpected(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function ensureToken(tk:Token):Void {
|
@:analyzer(fusion) inline function ensureToken(tk:Token):Void {
|
||||||
var t = token();
|
var t = token();
|
||||||
if( !Type.enumEq(t,tk) ) unexpected(t);
|
if( !Type.enumEq(t,tk) ) unexpected(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
function maybe(tk:Token):Bool {
|
@:analyzer(fusion) inline function maybe(tk:Token):Bool {
|
||||||
var t = token();
|
var t = token();
|
||||||
if( Type.enumEq(t, tk) )
|
if( Type.enumEq(t, tk) )
|
||||||
return true;
|
return true;
|
||||||
@@ -253,7 +253,7 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function expr(e:Expr):#if hscriptPos ExprDef #else Expr #end {
|
@:analyzer(fusion) inline function expr(e:Expr):#if hscriptPos ExprDef #else Expr #end {
|
||||||
#if hscriptPos
|
#if hscriptPos
|
||||||
return e.e;
|
return e.e;
|
||||||
#else
|
#else
|
||||||
@@ -261,7 +261,7 @@ class Parser {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function pmin(e:Expr):Int {
|
@:analyzer(fusion) inline function pmin(e:Expr):Int {
|
||||||
#if hscriptPos
|
#if hscriptPos
|
||||||
return e == null ? 0 : e.pmin;
|
return e == null ? 0 : e.pmin;
|
||||||
#else
|
#else
|
||||||
@@ -269,7 +269,7 @@ class Parser {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function pmax(e:Expr):Int {
|
@:analyzer(fusion) inline function pmax(e:Expr):Int {
|
||||||
#if hscriptPos
|
#if hscriptPos
|
||||||
return e == null ? 0 : e.pmax;
|
return e == null ? 0 : e.pmax;
|
||||||
#else
|
#else
|
||||||
@@ -277,7 +277,7 @@ class Parser {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
inline function mk(e:#if hscriptPos ExprDef #else Expr #end,?pmin:Int,?pmax:Int) : Expr {
|
@:analyzer(fusion) inline function mk(e:#if hscriptPos ExprDef #else Expr #end,?pmin:Int,?pmax:Int) : Expr {
|
||||||
#if hscriptPos
|
#if hscriptPos
|
||||||
if( e == null ) return null;
|
if( e == null ) return null;
|
||||||
if( pmin == null ) pmin = tokenMin;
|
if( pmin == null ) pmin = tokenMin;
|
||||||
@@ -288,7 +288,7 @@ class Parser {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
function isBlock(e:Expr):Bool {
|
@:analyzer(fusion) inline function isBlock(e:Expr):Bool {
|
||||||
if( e == null ) return false;
|
if( e == null ) return false;
|
||||||
return switch( expr(e) ) {
|
return switch( expr(e) ) {
|
||||||
case EBlock(_), EObject(_), ESwitch(_), EEnum(_, _): true;
|
case EBlock(_), EObject(_), ESwitch(_), EEnum(_, _): true;
|
||||||
@@ -308,7 +308,7 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseFullExpr( exprs : Array<Expr> ):Void {
|
@:analyzer(fusion) function parseFullExpr( exprs : Array<Expr> ):Void {
|
||||||
var e = parseExpr();
|
var e = parseExpr();
|
||||||
exprs.push(e);
|
exprs.push(e);
|
||||||
|
|
||||||
@@ -371,7 +371,7 @@ class Parser {
|
|||||||
var p1 = tokenMin;
|
var p1 = tokenMin;
|
||||||
#end
|
#end
|
||||||
switch( tk ) {
|
switch( tk ) {
|
||||||
case TId(id): // TODO: direct access to classes by typing their path
|
case TId(id):
|
||||||
var e = parseStructure(id, oldPos);
|
var e = parseStructure(id, oldPos);
|
||||||
if( e == null )
|
if( e == null )
|
||||||
e = mk(EIdent(id));
|
e = mk(EIdent(id));
|
||||||
@@ -604,27 +604,28 @@ class Parser {
|
|||||||
return switch( expr(e) ) {
|
return switch( expr(e) ) {
|
||||||
case EBinop(bop, e1, e2): mk(EBinop(bop, makeUnop(op, e1), e2), pmin(e1), pmax(e2));
|
case EBinop(bop, e1, e2): mk(EBinop(bop, makeUnop(op, e1), e2), pmin(e1), pmax(e2));
|
||||||
case ETernary(e1, e2, e3): mk(ETernary(makeUnop(op, e1), e2, e3), pmin(e1), pmax(e3));
|
case ETernary(e1, e2, e3): mk(ETernary(makeUnop(op, e1), e2, e3), pmin(e1), pmax(e3));
|
||||||
default: mk(EUnop(op,true,e),pmin(e),pmax(e));
|
default: mk(EUnop(Unop.fromString(op),true,e),pmin(e),pmax(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeBinop( op:String, e1:Expr, e:Expr ):Expr {
|
@:analyzer(fusion) inline function makeBinop( op:String, e1:Expr, e:Expr ):Expr {
|
||||||
|
var binop = Binop.fromString(op);
|
||||||
if( e == null && resumeErrors )
|
if( e == null && resumeErrors )
|
||||||
return mk(EBinop(op,e1,e),pmin(e1),pmax(e1));
|
return mk(EBinop(binop,e1,e),pmin(e1),pmax(e1));
|
||||||
return switch( expr(e) ) {
|
return switch( expr(e) ) {
|
||||||
case EBinop(op2,e2,e3):
|
case EBinop(op2,e2,e3):
|
||||||
var delta = opPriority.get(op) - opPriority.get(op2);
|
var delta = opPriority.get(op) - opPriority.get(op2.toString());
|
||||||
if( delta < 0 || (delta == 0 && !opRightAssoc.exists(op)) )
|
if( delta < 0 || (delta == 0 && !opRightAssoc.exists(op)) )
|
||||||
mk(EBinop(op2,makeBinop(op,e1,e2),e3),pmin(e1),pmax(e3));
|
mk(EBinop(op2,makeBinop(op,e1,e2),e3),pmin(e1),pmax(e3));
|
||||||
else
|
else
|
||||||
mk(EBinop(op, e1, e), pmin(e1), pmax(e));
|
mk(EBinop(binop, e1, e), pmin(e1), pmax(e));
|
||||||
case ETernary(e2,e3,e4):
|
case ETernary(e2,e3,e4):
|
||||||
if( opRightAssoc.exists(op) )
|
if( opRightAssoc.exists(op) )
|
||||||
mk(EBinop(op,e1,e),pmin(e1),pmax(e));
|
mk(EBinop(binop,e1,e),pmin(e1),pmax(e));
|
||||||
else
|
else
|
||||||
mk(ETernary(makeBinop(op, e1, e2), e3, e4), pmin(e1), pmax(e));
|
mk(ETernary(makeBinop(op, e1, e2), e3, e4), pmin(e1), pmax(e));
|
||||||
default:
|
default:
|
||||||
mk(EBinop(op,e1,e),pmin(e1),pmax(e));
|
mk(EBinop(binop,e1,e),pmin(e1),pmax(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1046,72 +1047,62 @@ class Parser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "class":
|
case "class":
|
||||||
// example: class ClassName
|
// example: class ClassName<K, V>
|
||||||
var tk = token();
|
var name:String = null;
|
||||||
var name = null;
|
var ct = parseType(); // this is for handling type parameters
|
||||||
|
switch(ct) {
|
||||||
switch (tk) {
|
case CTPath(path, params):
|
||||||
case TId(id): name = id;
|
name = path.join(".");
|
||||||
default: push(tk);
|
default:
|
||||||
|
error(EUnexpected(Std.string(ct)), p1, tokenMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
var extend:String = null;
|
var extend:String = null;
|
||||||
var interfaces:Array<String> = [];
|
if(maybe(TId("extends"))) {
|
||||||
// optional - example: extends BaseClass
|
var e = parseType();
|
||||||
|
switch(e) {
|
||||||
while( true ) {
|
case CTPath(path, params):
|
||||||
var t = token();
|
var buf = new StringBuf();
|
||||||
switch( t ) {
|
for(i in 0...path.length) {
|
||||||
case TId("extends"):
|
if(i > 0) buf.add(".");
|
||||||
var e = parseType();
|
buf.add(path[i]);
|
||||||
switch(e) {
|
|
||||||
case CTPath(path, params):
|
|
||||||
if(extend != null) {
|
|
||||||
error(ECustom('Cannot extend a class twice.'), 0, 0);
|
|
||||||
}
|
|
||||||
extend = path.join(".");
|
|
||||||
default:
|
|
||||||
error(ECustom('${Std.string(e)} is not a valid path.'), 0, 0);
|
|
||||||
}
|
}
|
||||||
|
extend = buf.toString();
|
||||||
default:
|
default:
|
||||||
push(t);
|
error(ECustom('${Std.string(e)} is not a valid path.'), p1, tokenMax);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*while(true) {
|
var interfaces:Array<String> = [];
|
||||||
tk = token();
|
var tk:Token = null;
|
||||||
trace(tk);
|
if(maybe(TId("implements"))) {
|
||||||
switch (tk) {
|
// handled manually for multiple implements
|
||||||
case TId(id):
|
while(true) {
|
||||||
if (id == "extends") {
|
tk = token();
|
||||||
tk = token();
|
switch(tk) {
|
||||||
if(extend != null) {
|
case TId("implements"): continue;
|
||||||
unexpected(tk);
|
case TId("extends"):
|
||||||
} else {
|
error(ECustom('Implements must come after extends.'), p1, tokenMax);
|
||||||
switch (tk) {
|
case TId(_):
|
||||||
case TId(id): extend = id;
|
push(tk);
|
||||||
default: unexpected(tk);
|
var e = parseType();
|
||||||
}
|
switch(e) {
|
||||||
|
case CTPath(path, params):
|
||||||
|
var buf = new StringBuf();
|
||||||
|
for(i in 0...path.length) {
|
||||||
|
if(i > 0) buf.add(".");
|
||||||
|
buf.add(path[i]);
|
||||||
|
}
|
||||||
|
interfaces.push(buf.toString());
|
||||||
|
default:
|
||||||
|
error(ECustom('${Std.string(e)} is not a valid path.'), p1, tokenMax);
|
||||||
}
|
}
|
||||||
} else if (id == "implements") {
|
default:
|
||||||
tk = token();
|
push(tk);
|
||||||
switch (tk) {
|
break;
|
||||||
case TId(id): interfaces.push(id);
|
}
|
||||||
default: unexpected(tk);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//push(tk);
|
|
||||||
}
|
|
||||||
|
|
||||||
case TBrOpen:
|
|
||||||
push(tk);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
//push(tk);
|
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
var fields = [];
|
var fields = [];
|
||||||
ensure(TBrOpen);
|
ensure(TBrOpen);
|
||||||
@@ -1127,39 +1118,64 @@ class Parser {
|
|||||||
push(tk);
|
push(tk);
|
||||||
mk(EClass(name, fields, extend, interfaces, nextIsFinal, nextIsPrivate), p1);
|
mk(EClass(name, fields, extend, interfaces, nextIsFinal, nextIsPrivate), p1);
|
||||||
|
|
||||||
case "enum": // TODO: enum abstract
|
case "enum":
|
||||||
|
var isAbstract = maybe(TId("abstract"));
|
||||||
var name = getIdent();
|
var name = getIdent();
|
||||||
|
var underlyingType:CType = null;
|
||||||
|
|
||||||
|
if(isAbstract) {
|
||||||
|
ensure(TPOpen);
|
||||||
|
if(allowTypes) {
|
||||||
|
underlyingType = parseType();
|
||||||
|
ensure(TPClose);
|
||||||
|
} else {
|
||||||
|
var t = token();
|
||||||
|
while(t != TPClose && t != TEof) {
|
||||||
|
t = token();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ensure(TBrOpen);
|
ensure(TBrOpen);
|
||||||
|
|
||||||
// TODO: optimize this
|
|
||||||
var fields:Array<EnumField> = [];
|
var fields:Array<EnumField> = [];
|
||||||
var fieldName:String = '';
|
var fieldName:String = '';
|
||||||
var enumArgs:Array<Argument> = null;
|
var enumArgs:Array<Argument> = null;
|
||||||
//var tk = token();
|
var fieldValue:Expr = null;
|
||||||
|
|
||||||
while(!maybe(TBrClose)) {
|
while(!maybe(TBrClose)) {
|
||||||
var tk = token();
|
var tk = token();
|
||||||
|
|
||||||
switch(tk) {
|
switch(tk) {
|
||||||
//case TBrClose:
|
|
||||||
// break;
|
|
||||||
case TSemicolon | TComma:
|
case TSemicolon | TComma:
|
||||||
if(fieldName.trim().length == 0) continue;
|
if(fieldName.trim().length == 0) continue;
|
||||||
|
|
||||||
fields.push({
|
fields.push({
|
||||||
name: fieldName,
|
name: fieldName,
|
||||||
args: enumArgs == null ? [] : enumArgs
|
args: enumArgs == null ? [] : enumArgs,
|
||||||
|
value: fieldValue
|
||||||
});
|
});
|
||||||
fieldName = '';
|
fieldName = '';
|
||||||
enumArgs = null;
|
enumArgs = null;
|
||||||
|
fieldValue = null;
|
||||||
case TPOpen:
|
case TPOpen:
|
||||||
|
if(isAbstract) {
|
||||||
|
error(ECustom("Enum abstract fields cannot have parameters"), tokenMin, tokenMax);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if(enumArgs != null) {
|
if(enumArgs != null) {
|
||||||
error(ECustom("Cannot have multiple argument lists in one enum constructor"), tokenMin, tokenMax);
|
error(ECustom("Cannot have multiple argument lists in one enum constructor"), tokenMin, tokenMax);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
enumArgs = parseFunctionArgs(true);
|
enumArgs = parseFunctionArgs(true);
|
||||||
|
case TOp("="):
|
||||||
|
if(!isAbstract) {
|
||||||
|
error(ECustom("Only enum abstract fields can have values"), tokenMin, tokenMax);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fieldValue = parseExpr();
|
||||||
default:
|
default:
|
||||||
|
if(tk.match(TId("var"))) continue;
|
||||||
if(fieldName.trim().length != 0) {
|
if(fieldName.trim().length != 0) {
|
||||||
error(ECustom("Expected comma or semicolon"), tokenMin, tokenMax);
|
error(ECustom("Expected comma or semicolon"), tokenMin, tokenMax);
|
||||||
break;
|
break;
|
||||||
@@ -1169,7 +1185,7 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mk(EEnum({ name: name, fields: fields }, false), p1);
|
mk(EEnum({ name: name, fields: fields, underlyingType: underlyingType }, isAbstract), p1);
|
||||||
case "cast":
|
case "cast":
|
||||||
var tk = token();
|
var tk = token();
|
||||||
var e:Expr = null;
|
var e:Expr = null;
|
||||||
@@ -1192,7 +1208,8 @@ class Parser {
|
|||||||
var e = if( tk == TSemicolon ) null else parseExpr();
|
var e = if( tk == TSemicolon ) null else parseExpr();
|
||||||
mk(EReturn(e),p1,if( e == null ) tokenMax else pmax(e));
|
mk(EReturn(e),p1,if( e == null ) tokenMax else pmax(e));
|
||||||
case "new":
|
case "new":
|
||||||
var a = [];
|
// TODO: maybe use CTPath for this
|
||||||
|
var a:Array<String> = [];
|
||||||
var params:Null<Array<CType>> = null;
|
var params:Null<Array<CType>> = null;
|
||||||
a.push(getIdent());
|
a.push(getIdent());
|
||||||
while( true ) {
|
while( true ) {
|
||||||
@@ -1369,7 +1386,7 @@ class Parser {
|
|||||||
push(tk);
|
push(tk);
|
||||||
return e1;
|
return e1;
|
||||||
}
|
}
|
||||||
return parseExprNext(mk(EUnop(op,false,e1),pmin(e1)));
|
return parseExprNext(mk(EUnop(Unop.fromString(op),false,e1),pmin(e1)));
|
||||||
}
|
}
|
||||||
return makeBinop(op,e1,parseExpr());
|
return makeBinop(op,e1,parseExpr());
|
||||||
case TId(op) if( opPriority.exists(op) ):
|
case TId(op) if( opPriority.exists(op) ):
|
||||||
@@ -1401,17 +1418,15 @@ class Parser {
|
|||||||
var done = false;
|
var done = false;
|
||||||
while( !done ) {
|
while( !done ) {
|
||||||
var name = null, opt = false;
|
var name = null, opt = false;
|
||||||
switch( tk ) {
|
if( tk == TQuestion ) {
|
||||||
case TQuestion:
|
opt = true;
|
||||||
opt = true;
|
tk = token();
|
||||||
tk = token();
|
|
||||||
default:
|
|
||||||
}
|
}
|
||||||
switch( tk ) {
|
switch( tk ) {
|
||||||
case TId(id): name = id;
|
case TId(id):
|
||||||
|
name = id;
|
||||||
default:
|
default:
|
||||||
unexpected(tk);
|
unexpected(tk);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
var arg : Argument = { name : name, opt: false, value: null, t: null };
|
var arg : Argument = { name : name, opt: false, value: null, t: null };
|
||||||
args.push(arg);
|
args.push(arg);
|
||||||
@@ -1426,13 +1441,12 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tk = token();
|
tk = token();
|
||||||
switch( tk ) {
|
if( tk == TComma ) {
|
||||||
case TComma:
|
tk = token();
|
||||||
tk = token();
|
} else if( tk == TPClose ) {
|
||||||
case TPClose:
|
done = true;
|
||||||
done = true;
|
} else {
|
||||||
default:
|
unexpected(tk);
|
||||||
unexpected(tk);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1479,31 +1493,32 @@ class Parser {
|
|||||||
if( op == "<" ) {
|
if( op == "<" ) {
|
||||||
params = [];
|
params = [];
|
||||||
while( true ) {
|
while( true ) {
|
||||||
switch( token() ) {
|
var tt = token();
|
||||||
case TConst(c):
|
switch( tt ) {
|
||||||
params.push(CTExpr(mk(EConst(c))));
|
case TConst(c):
|
||||||
case tk:
|
params.push(CTExpr(mk(EConst(c))));
|
||||||
push(tk);
|
default:
|
||||||
params.push(parseType());
|
push(tt);
|
||||||
}
|
params.push(parseType());
|
||||||
t = token();
|
|
||||||
switch( t ) {
|
|
||||||
case TComma: continue;
|
|
||||||
case TOp(op):
|
|
||||||
if( op == ">" ) break;
|
|
||||||
if( op.charCodeAt(0) == ">".code ) {
|
|
||||||
#if hscriptPos
|
|
||||||
tokens.add({ t : TOp(op.substr(1)), min : tokenMax - op.length - 1, max : tokenMax });
|
|
||||||
#else
|
|
||||||
tokens.add(TOp(op.substr(1)));
|
|
||||||
#end
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
t = token();
|
||||||
|
switch( t ) {
|
||||||
|
case TComma: continue;
|
||||||
|
case TOp(op):
|
||||||
|
if( op == ">" ) break;
|
||||||
|
if( op.charCodeAt(0) == ">".code ) {
|
||||||
|
#if hscriptPos
|
||||||
|
tokens.add({ t : TOp(op.substr(1)), min : tokenMax - op.length - 1, max : tokenMax });
|
||||||
|
#else
|
||||||
|
tokens.add(TOp(op.substr(1)));
|
||||||
|
#end
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
unexpected(t);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
unexpected(t);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
push(t);
|
push(t);
|
||||||
default:
|
default:
|
||||||
@@ -1633,13 +1648,10 @@ class Parser {
|
|||||||
while( true ) {
|
while( true ) {
|
||||||
args.push(parseExpr());
|
args.push(parseExpr());
|
||||||
tk = token();
|
tk = token();
|
||||||
switch( tk ) {
|
if( tk == etk )
|
||||||
case TComma:
|
break;
|
||||||
default:
|
if( tk != TComma )
|
||||||
if( tk == etk ) break;
|
unexpected(tk);
|
||||||
unexpected(tk);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
@@ -1726,7 +1738,7 @@ class Parser {
|
|||||||
var expr:Null<Expr> = exprs.shift();
|
var expr:Null<Expr> = exprs.shift();
|
||||||
while(true) {
|
while(true) {
|
||||||
if(exprs.length == 0) break;
|
if(exprs.length == 0) break;
|
||||||
expr = mk(EBinop('+', expr, exprs.shift()));
|
expr = mk(EBinop(OpAdd, expr, exprs.shift()));
|
||||||
}
|
}
|
||||||
return expr;
|
return expr;
|
||||||
}
|
}
|
||||||
@@ -2164,7 +2176,9 @@ class Parser {
|
|||||||
switch( char ) {
|
switch( char ) {
|
||||||
case 48,49,50,51,52,53,54,55,56,57:
|
case 48,49,50,51,52,53,54,55,56,57:
|
||||||
n = n * 10 + (char - 48);
|
n = n * 10 + (char - 48);
|
||||||
|
continue;
|
||||||
case '_'.code:
|
case '_'.code:
|
||||||
|
continue;
|
||||||
case "e".code, "E".code:
|
case "e".code, "E".code:
|
||||||
var tk = token();
|
var tk = token();
|
||||||
var pow : Null<Int> = null;
|
var pow : Null<Int> = null;
|
||||||
@@ -2193,46 +2207,48 @@ class Parser {
|
|||||||
invalidChar(char);
|
invalidChar(char);
|
||||||
}
|
}
|
||||||
exp = 1.;
|
exp = 1.;
|
||||||
|
continue;
|
||||||
case "x".code:
|
case "x".code:
|
||||||
if( n > 0 || exp > 0 )
|
if( n > 0 || exp > 0 )
|
||||||
invalidChar(char);
|
invalidChar(char);
|
||||||
// read hexa
|
// read hexa
|
||||||
var n = 0;
|
var hex = 0;
|
||||||
while( true ) {
|
while( true ) {
|
||||||
char = readChar();
|
char = readChar();
|
||||||
switch( char ) {
|
if( char >= 48 && char <= 57 ) {
|
||||||
case 48,49,50,51,52,53,54,55,56,57: // 0-9
|
hex = (hex << 4) + char - 48;
|
||||||
n = (n << 4) + char - 48;
|
continue;
|
||||||
case 65,66,67,68,69,70: // A-F
|
} else if( char >= 65 && char <= 70 ) {
|
||||||
n = (n << 4) + (char - 55);
|
hex = (hex << 4) + char - 55;
|
||||||
case 97,98,99,100,101,102: // a-f
|
continue;
|
||||||
n = (n << 4) + (char - 87);
|
} else if( char >= 97 && char <= 102 ) {
|
||||||
case '_'.code:
|
hex = (hex << 4) + char - 87;
|
||||||
default:
|
continue;
|
||||||
this.char = char;
|
} else if( char == '_'.code ) {
|
||||||
return TConst(CInt(n));
|
continue;
|
||||||
}
|
}
|
||||||
|
this.char = char;
|
||||||
|
return TConst(CInt(hex));
|
||||||
}
|
}
|
||||||
case "b".code: // Custom thing, not supported in haxe
|
case "b".code: // Custom thing, not supported in haxe
|
||||||
if( n > 0 || exp > 0 )
|
if( n > 0 || exp > 0 )
|
||||||
invalidChar(char);
|
invalidChar(char);
|
||||||
// read binary
|
// read binary
|
||||||
var n = 0;
|
var bin = 0;
|
||||||
while( true ) {
|
while( true ) {
|
||||||
char = readChar();
|
char = readChar();
|
||||||
switch( char ) {
|
if( char == 48 || char == 49 ) {
|
||||||
case 48,49: // 0-1
|
bin = (bin << 1) + char - 48;
|
||||||
n = (n << 1) + char - 48;
|
continue;
|
||||||
case '_'.code:
|
} else if( char == '_'.code ) {
|
||||||
default:
|
continue;
|
||||||
this.char = char;
|
|
||||||
return TConst(CInt(n));
|
|
||||||
}
|
}
|
||||||
|
this.char = char;
|
||||||
|
return TConst(CInt(bin));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
this.char = char;
|
this.char = char;
|
||||||
var i = Std.int(n);
|
return TConst( (exp > 0) ? CFloat(n * 10 / exp) : ((n % 1 == 0) ? CInt(Std.int(n)) : CFloat(n)) );
|
||||||
return TConst( (exp > 0) ? CFloat(n * 10 / exp) : ((i == n) ? CInt(i) : CFloat(n)) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ";".code: return TSemicolon;
|
case ";".code: return TSemicolon;
|
||||||
@@ -2328,17 +2344,19 @@ class Parser {
|
|||||||
invalidChar(char);
|
invalidChar(char);
|
||||||
default:
|
default:
|
||||||
if( ops[char] ) {
|
if( ops[char] ) {
|
||||||
var op:String = String.fromCharCode(char);
|
var buf = new StringBuf();
|
||||||
|
buf.addChar(char);
|
||||||
while( true ) {
|
while( true ) {
|
||||||
char = readChar();
|
char = readChar();
|
||||||
if( StringTools.isEof(char) ) char = 0;
|
if( StringTools.isEof(char) ) char = 0;
|
||||||
if( !ops[char] ) {
|
if( !ops[char] ) {
|
||||||
this.char = char;
|
this.char = char;
|
||||||
return TOp(op);
|
return TOp(buf.toString());
|
||||||
}
|
}
|
||||||
var pop = op;
|
var pop = buf.toString();
|
||||||
op += String.fromCharCode(char);
|
buf.addChar(char);
|
||||||
if( allowRegex && op == "~/") {
|
var op = buf.toString();
|
||||||
|
if( allowRegex && op == "~/" ) {
|
||||||
var e = readString(char, true);
|
var e = readString(char, true);
|
||||||
var f = readFlags();
|
var f = readFlags();
|
||||||
return TRegex(e, f);
|
return TRegex(e, f);
|
||||||
@@ -2352,16 +2370,17 @@ class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( idents[char] ) {
|
if( idents[char] ) {
|
||||||
var id = String.fromCharCode(char);
|
var buf = new StringBuf();
|
||||||
|
buf.addChar(char);
|
||||||
while( true ) {
|
while( true ) {
|
||||||
char = readChar();
|
char = readChar();
|
||||||
if( StringTools.isEof(char) ) char = 0;
|
if( StringTools.isEof(char) ) char = 0;
|
||||||
if( !idents[char] ) {
|
if( !idents[char] ) {
|
||||||
this.char = char;
|
this.char = char;
|
||||||
//if(id == "is") return TOp("is");
|
//if(id == "is") return TOp("is");
|
||||||
return TId(id);
|
return TId(buf.toString());
|
||||||
}
|
}
|
||||||
id += String.fromCharCode(char);
|
buf.addChar(char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
invalidChar(char);
|
invalidChar(char);
|
||||||
@@ -2384,14 +2403,16 @@ class Parser {
|
|||||||
push(TPOpen);
|
push(TPOpen);
|
||||||
parseExpr();
|
parseExpr();
|
||||||
case TId(id):
|
case TId(id):
|
||||||
|
var buf = new StringBuf();
|
||||||
|
buf.add(id);
|
||||||
while(true) {
|
while(true) {
|
||||||
var tk = token();
|
var tk = token();
|
||||||
if(tk == TDot) {
|
if(tk == TDot) {
|
||||||
id += ".";
|
buf.add(".");
|
||||||
tk = token();
|
tk = token();
|
||||||
switch(tk) {
|
switch(tk) {
|
||||||
case TId(id2):
|
case TId(id2):
|
||||||
id += id2;
|
buf.add(id2);
|
||||||
default: unexpected(tk);
|
default: unexpected(tk);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2399,9 +2420,9 @@ class Parser {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mk(EIdent(id), tokenMin, tokenMax);
|
mk(EIdent(buf.toString()), tokenMin, tokenMax);
|
||||||
case TOp("!"):
|
case TOp("!"):
|
||||||
mk(EUnop("!", true, parsePreproCond()), tokenMin, tokenMax);
|
mk(EUnop(OpNot, true, parsePreproCond()), tokenMin, tokenMax);
|
||||||
default:
|
default:
|
||||||
unexpected(tk);
|
unexpected(tk);
|
||||||
}
|
}
|
||||||
@@ -2419,13 +2440,13 @@ class Parser {
|
|||||||
error(EInvalidPreprocessor("Can't eval " + expr(e).getName() + " with " + expr(e2).getName()), readPos, readPos);
|
error(EInvalidPreprocessor("Can't eval " + expr(e).getName() + " with " + expr(e2).getName()), readPos, readPos);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case EUnop("!", _, e):
|
case EUnop(OpNot, _, e):
|
||||||
return !evalPreproCond(e);
|
return !evalPreproCond(e);
|
||||||
case EParent(e):
|
case EParent(e):
|
||||||
return evalPreproCond(e);
|
return evalPreproCond(e);
|
||||||
case EBinop("&&", e1, e2):
|
case EBinop(OpBoolAnd, e1, e2):
|
||||||
return evalPreproCond(e1) && evalPreproCond(e2);
|
return evalPreproCond(e1) && evalPreproCond(e2);
|
||||||
case EBinop("||", e1, e2):
|
case EBinop(OpBoolOr, e1, e2):
|
||||||
return evalPreproCond(e1) || evalPreproCond(e2);
|
return evalPreproCond(e1) || evalPreproCond(e2);
|
||||||
default:
|
default:
|
||||||
error(EInvalidPreprocessor("Can't eval " + expr(e).getName()), readPos, readPos);
|
error(EInvalidPreprocessor("Can't eval " + expr(e).getName()), readPos, readPos);
|
||||||
|
|||||||
+51
-27
@@ -148,34 +148,58 @@ class Printer {
|
|||||||
|
|
||||||
tabs = tabs.substr(1);
|
tabs = tabs.substr(1);
|
||||||
add("}");
|
add("}");
|
||||||
case EEnum(en, _): // TODO: enum abstracts
|
case EEnum(en, isAbstract):
|
||||||
add('enum ${en.name}');
|
if(isAbstract) {
|
||||||
if(en.fields.length == 0) {
|
add('enum abstract ${en.name}(');
|
||||||
add(' {}');
|
if(en.underlyingType != null)
|
||||||
return;
|
type(en.underlyingType);
|
||||||
}
|
else
|
||||||
tabs += "\t";
|
add('Int');
|
||||||
add(" {\n");
|
add(')');
|
||||||
|
if(en.fields.length == 0) {
|
||||||
for(e in en.fields) {
|
add(' {}');
|
||||||
add(tabs);
|
return;
|
||||||
add(e.name);
|
|
||||||
if(e.args.length > 0) {
|
|
||||||
add("(");
|
|
||||||
var first = true;
|
|
||||||
for( a in e.args ) {
|
|
||||||
if( first ) first = false else add(", ");
|
|
||||||
if( a.opt ) add("?");
|
|
||||||
add(a.name);
|
|
||||||
addType(a.t);
|
|
||||||
}
|
|
||||||
add(')');
|
|
||||||
}
|
}
|
||||||
add(";\n");
|
tabs += "\t";
|
||||||
|
add(" {\n");
|
||||||
|
for(e in en.fields) {
|
||||||
|
add(tabs);
|
||||||
|
add(e.name);
|
||||||
|
if(e.value != null) {
|
||||||
|
add(" = ");
|
||||||
|
expr(e.value);
|
||||||
|
}
|
||||||
|
add(";\n");
|
||||||
|
}
|
||||||
|
tabs = tabs.substr(1);
|
||||||
|
add("}");
|
||||||
|
} else {
|
||||||
|
add('enum ${en.name}');
|
||||||
|
if(en.fields.length == 0) {
|
||||||
|
add(' {}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tabs += "\t";
|
||||||
|
add(" {\n");
|
||||||
|
for(e in en.fields) {
|
||||||
|
add(tabs);
|
||||||
|
add(e.name);
|
||||||
|
if(e.args.length > 0) {
|
||||||
|
add("(");
|
||||||
|
var first = true;
|
||||||
|
for( a in e.args ) {
|
||||||
|
if( first ) first = false else add(", ");
|
||||||
|
if( a.opt ) add("?");
|
||||||
|
add(a.name);
|
||||||
|
addType(a.t);
|
||||||
|
}
|
||||||
|
add(')');
|
||||||
|
}
|
||||||
|
add(";\n");
|
||||||
|
}
|
||||||
|
tabs = tabs.substr(1);
|
||||||
|
add("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs = tabs.substr(1);
|
|
||||||
add("}");
|
|
||||||
case ECast(e, t):
|
case ECast(e, t):
|
||||||
var safe = t != null;
|
var safe = t != null;
|
||||||
add("cast ");
|
add("cast ");
|
||||||
@@ -252,7 +276,7 @@ class Printer {
|
|||||||
add((s == true ? "?." : ".") + f);
|
add((s == true ? "?." : ".") + f);
|
||||||
case EBinop(op, e1, e2):
|
case EBinop(op, e1, e2):
|
||||||
expr(e1);
|
expr(e1);
|
||||||
add(" " + op + " ");
|
add(" " + op.toString() + " ");
|
||||||
expr(e2);
|
expr(e2);
|
||||||
case EUnop(op, pre, e):
|
case EUnop(op, pre, e):
|
||||||
if( pre ) {
|
if( pre ) {
|
||||||
|
|||||||
+68
-18
@@ -26,15 +26,33 @@ import hscript.Expr.FieldPropertyAccess;
|
|||||||
* @see https://haxe.org/manual/class-field-property.html
|
* @see https://haxe.org/manual/class-field-property.html
|
||||||
*/
|
*/
|
||||||
@:access(hscript.Interp)
|
@:access(hscript.Interp)
|
||||||
@:structInit
|
|
||||||
class Property {
|
class Property {
|
||||||
private static inline var GET = 'get_';
|
private static inline var GET = 'get_';
|
||||||
private static inline var SET = 'set_';
|
private static inline var SET = 'set_';
|
||||||
|
|
||||||
public var r:Dynamic;
|
/**
|
||||||
public var getter:FieldPropertyAccess;
|
* Name of the attached field.
|
||||||
public var setter:FieldPropertyAccess;
|
*/
|
||||||
|
public final name:String;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current value. If isn't initialized, it's always `null`.
|
||||||
|
*/
|
||||||
|
public var r:Dynamic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The getter property kind
|
||||||
|
*/
|
||||||
|
public final getter:FieldPropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The setter property kind
|
||||||
|
*/
|
||||||
|
public final setter:FieldPropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the field is declared as static.
|
||||||
|
*/
|
||||||
public var isStatic(get, never):Bool;
|
public var isStatic(get, never):Bool;
|
||||||
function get_isStatic() {
|
function get_isStatic() {
|
||||||
return __isStatic && interp.allowStaticVariables;
|
return __isStatic && interp.allowStaticVariables;
|
||||||
@@ -43,7 +61,20 @@ class Property {
|
|||||||
var isVar:Bool;
|
var isVar:Bool;
|
||||||
var interp:Interp;
|
var interp:Interp;
|
||||||
|
|
||||||
public function new(r:Dynamic, getter:FieldPropertyAccess, setter:FieldPropertyAccess, isVar:Bool, isStatic:Bool, interp:Interp) {
|
@:allow(hscript.Interp)
|
||||||
|
private var getterFunc(get, never):String;
|
||||||
|
private inline function get_getterFunc():String {
|
||||||
|
return '$GET$name';
|
||||||
|
}
|
||||||
|
|
||||||
|
@:allow(hscript.Interp)
|
||||||
|
private var setterFunc(get, never):String;
|
||||||
|
private inline function get_setterFunc():String {
|
||||||
|
return '$SET$name';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function new(name:String, r:Dynamic, getter:FieldPropertyAccess, setter:FieldPropertyAccess, isVar:Bool, isStatic:Bool, interp:Interp) {
|
||||||
|
this.name = name;
|
||||||
this.r = r;
|
this.r = r;
|
||||||
this.getter = getter;
|
this.getter = getter;
|
||||||
this.setter = setter;
|
this.setter = setter;
|
||||||
@@ -52,23 +83,41 @@ class Property {
|
|||||||
this.interp = interp;
|
this.interp = interp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Internal flags to gain access to the current field value (if isn't a property field)
|
||||||
var __allowReadAccess:Bool = false;
|
var __allowReadAccess:Bool = false;
|
||||||
var __allowWriteAccess:Bool = false;
|
var __allowWriteAccess:Bool = false;
|
||||||
var __allowSetGet:Null<Bool> = null;
|
// Internal flag to gain access if the field is accessed with @:bypassAccessor
|
||||||
|
var __allowSetGet:Bool = true;
|
||||||
|
|
||||||
final __isStatic:Bool = false;
|
final __isStatic:Bool = false;
|
||||||
|
|
||||||
public function callGetter(name:String) {
|
public function get(isBypassAccessor:Bool) {
|
||||||
|
if(isBypassAccessor) __allowSetGet = false;
|
||||||
|
var r:Dynamic = callGetter();
|
||||||
|
if(isBypassAccessor) __allowSetGet = true;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set(value:Dynamic, isBypassAccessor:Bool) {
|
||||||
|
if(isBypassAccessor) __allowSetGet = false;
|
||||||
|
var r:Dynamic = callSetter(value);
|
||||||
|
if(isBypassAccessor) __allowSetGet = true;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function callGetter():Dynamic {
|
||||||
switch (getter) {
|
switch (getter) {
|
||||||
case AGet | ADynamic:
|
case AGet | ADynamic:
|
||||||
var fName:String = '$GET$name';
|
var fName:String = getterFunc;
|
||||||
if (!__allowReadAccess && (__allowSetGet != null && __allowSetGet || !interp.isBypassAccessor)) {
|
if (!__allowReadAccess && __allowSetGet) {
|
||||||
if (varExists(fName)) {
|
if (varExists(fName)) {
|
||||||
return callAccessor(fName);
|
return callAccessor(fName);
|
||||||
} else
|
} else
|
||||||
interp.error(ECustom('Method $fName required by property $name is missing'));
|
interp.error(ECustom('Method $fName required by property $name is missing'));
|
||||||
} else {
|
} else {
|
||||||
if ((setter == ADefault || setter == ANull) || isVar)
|
if ((setter == ADefault || setter == ANull) || isVar) {
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
interp.error(ECustom('Field $name cannot be accessed because it is not a real variable${interp.isBypassAccessor ? '. Add @:isVar to enable it' : ''}'));
|
interp.error(ECustom('Field $name cannot be accessed because it is not a real variable${interp.isBypassAccessor ? '. Add @:isVar to enable it' : ''}'));
|
||||||
}
|
}
|
||||||
@@ -80,18 +129,19 @@ class Property {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function callSetter(name:String, val:Dynamic) {
|
private function callSetter(val:Dynamic):Dynamic {
|
||||||
switch (setter) {
|
switch (setter) {
|
||||||
case ASet | ADynamic:
|
case ASet | ADynamic:
|
||||||
var fName:String = '$SET$name';
|
var fName:String = setterFunc;
|
||||||
if (!__allowWriteAccess && (__allowSetGet != null && __allowSetGet || !interp.isBypassAccessor)) {
|
if (!__allowWriteAccess && __allowSetGet) {
|
||||||
if (varExists(fName))
|
if (varExists(fName))
|
||||||
return callAccessor(fName, [val], true);
|
return callAccessor(fName, true, val);
|
||||||
else
|
else
|
||||||
interp.error(ECustom('Method $fName required by property $name is missing'));
|
interp.error(ECustom('Method $fName required by property $name is missing'));
|
||||||
} else {
|
} else {
|
||||||
if ((getter == ADefault || getter == ANull) || isVar)
|
if ((getter == ADefault || getter == ANull) || isVar) {
|
||||||
return r = val;
|
return r = val;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
interp.error(ECustom('Field $name cannot be accessed because it is not a real variable${interp.isBypassAccessor ? '. Add @:isVar to enable it' : ''}'));
|
interp.error(ECustom('Field $name cannot be accessed because it is not a real variable${interp.isBypassAccessor ? '. Add @:isVar to enable it' : ''}'));
|
||||||
}
|
}
|
||||||
@@ -103,14 +153,14 @@ class Property {
|
|||||||
return r = val;
|
return r = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function callAccessor(f:String, ?args:Array<Dynamic>, isWrite:Bool = false):Dynamic {
|
private function callAccessor(f:String, isWrite:Bool = false, ?value:Dynamic):Dynamic {
|
||||||
var fn = isStatic ? interp.staticVariables.get(f) : interp.variables.get(f);
|
var fn = isStatic ? interp.staticVariables.get(f) : interp.variables.get(f);
|
||||||
var rt:Dynamic = null;
|
var rt:Dynamic = null;
|
||||||
if (fn != null && Reflect.isFunction(fn)) {
|
if (fn != null && Reflect.isFunction(fn)) {
|
||||||
if (isWrite) __allowWriteAccess = true;
|
if (isWrite) __allowWriteAccess = true;
|
||||||
else __allowReadAccess = true;
|
else __allowReadAccess = true;
|
||||||
|
|
||||||
rt = UnsafeReflect.callMethodUnsafe(null, fn, args == null ? [] : args);
|
rt = UnsafeReflect.callMethodUnsafe(null, fn, isWrite ? [value] : []);
|
||||||
|
|
||||||
if (isWrite) __allowWriteAccess = false;
|
if (isWrite) __allowWriteAccess = false;
|
||||||
else __allowReadAccess = false;
|
else __allowReadAccess = false;
|
||||||
@@ -122,7 +172,7 @@ class Property {
|
|||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function varExists(n:String) {
|
private inline function varExists(n:String) {
|
||||||
return isStatic ? interp.staticVariables.exists(n) : interp.variables.exists(n);
|
return isStatic ? interp.staticVariables.exists(n) : interp.variables.exists(n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,13 @@ class Tools {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isUppercase(s:String) {
|
||||||
|
if(s.length == 0) return false;
|
||||||
|
var c:Int = StringTools.fastCodeAt(s, 0);
|
||||||
|
if(StringTools.isEof(c)) return false; // Just in case :3
|
||||||
|
return c >= 65 && c <= 90; // A-Z
|
||||||
|
}
|
||||||
|
|
||||||
public static inline function isCustomAbstract(obj:Dynamic):Bool
|
public static inline function isCustomAbstract(obj:Dynamic):Bool
|
||||||
return obj != null && obj is IHScriptAbstractBehaviour;
|
return obj != null && obj is IHScriptAbstractBehaviour;
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ using StringTools;
|
|||||||
|
|
||||||
class AbstractHandler {
|
class AbstractHandler {
|
||||||
public static function init() {
|
public static function init() {
|
||||||
|
#if HSCRIPT_ABSTRACT_SUPPORT
|
||||||
#if !display
|
#if !display
|
||||||
if(Context.defined("display")) return;
|
if(Context.defined("display")) return;
|
||||||
for(apply in Config.ALLOWED_ABSTRACT_AND_ENUM) {
|
for(apply in Config.ALLOWED_ABSTRACT_AND_ENUM) {
|
||||||
Compiler.addGlobalMetadata(apply, '@:build(hscript.macros.AbstractHandler.build())');
|
Compiler.addGlobalMetadata(apply, '@:build(hscript.macros.AbstractHandler.build())');
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function build():Array<Field> {
|
public static function build():Array<Field> {
|
||||||
|
|||||||
@@ -483,8 +483,9 @@ class ClassExtendMacro {
|
|||||||
if (__interp != null) {
|
if (__interp != null) {
|
||||||
if(__class__fields.contains(name)) {
|
if(__class__fields.contains(name)) {
|
||||||
var v:Dynamic = __interp.variables.get(name);
|
var v:Dynamic = __interp.variables.get(name);
|
||||||
|
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
|
||||||
if(v != null && v is hscript.Property)
|
if(v != null && v is hscript.Property)
|
||||||
return cast(v, hscript.Property).callGetter(name);
|
return cast(v, hscript.Property).get(ba);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
else @:privateAccess {
|
else @:privateAccess {
|
||||||
@@ -508,8 +509,9 @@ class ClassExtendMacro {
|
|||||||
if (__interp != null) {
|
if (__interp != null) {
|
||||||
if(__class__fields.contains(name)) {
|
if(__class__fields.contains(name)) {
|
||||||
var v:Dynamic = __interp.variables.get(name);
|
var v:Dynamic = __interp.variables.get(name);
|
||||||
|
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
|
||||||
if(v != null && v is hscript.Property)
|
if(v != null && v is hscript.Property)
|
||||||
return cast(v, hscript.Property).callGetter(name);
|
return cast(v, hscript.Property).get(ba);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
else @:privateAccess {
|
else @:privateAccess {
|
||||||
@@ -535,8 +537,9 @@ class ClassExtendMacro {
|
|||||||
if (__interp != null) {
|
if (__interp != null) {
|
||||||
if(__class__fields.contains(name)) {
|
if(__class__fields.contains(name)) {
|
||||||
var v:Dynamic = __interp.variables.get(name);
|
var v:Dynamic = __interp.variables.get(name);
|
||||||
|
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
|
||||||
if(v != null && v is hscript.Property)
|
if(v != null && v is hscript.Property)
|
||||||
return cast(v, hscript.Property).callSetter(name, val);
|
return cast(v, hscript.Property).set(val, ba);
|
||||||
__interp.variables.set(name, val);
|
__interp.variables.set(name, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
@@ -565,8 +568,9 @@ class ClassExtendMacro {
|
|||||||
if (__interp != null) {
|
if (__interp != null) {
|
||||||
if(__class__fields.contains(name)) {
|
if(__class__fields.contains(name)) {
|
||||||
var v:Dynamic = __interp.variables.get(name);
|
var v:Dynamic = __interp.variables.get(name);
|
||||||
|
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
|
||||||
if(v != null && v is hscript.Property)
|
if(v != null && v is hscript.Property)
|
||||||
return cast(v, hscript.Property).callSetter(name, val);
|
return cast(v, hscript.Property).set(val, ba);
|
||||||
__interp.variables.set(name, val);
|
__interp.variables.set(name, val);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class UsingHandler {
|
|||||||
usingEntries.set(name, {call: entry, fields: fields});
|
usingEntries.set(name, {call: entry, fields: fields});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entryExists(name:String):Bool {
|
public inline function entryExists(name:String):Bool {
|
||||||
return usingEntries.exists(name);
|
return usingEntries.exists(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user