Added support for ?.
This commit is contained in:
+6
-6
@@ -45,10 +45,10 @@ enum Expr {
|
||||
#end
|
||||
EConst( c : Const );
|
||||
EIdent( v : String );
|
||||
EVar( n : String, ?t : CType, ?e : Expr, ?isPublic : Bool, ?isStatic : Bool);
|
||||
EVar( n : String, ?t : CType, ?e : Expr, ?isPublic : Bool, ?isStatic : Bool );
|
||||
EParent( e : 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 );
|
||||
EUnop( op : String, prefix : Bool, e : Expr );
|
||||
ECall( e : Expr, params : Array<Expr> );
|
||||
@@ -57,22 +57,22 @@ enum Expr {
|
||||
EFor( v : String, it : Expr, e : Expr );
|
||||
EBreak;
|
||||
EContinue;
|
||||
EFunction( args : Array<Argument>, e : Expr, ?name : String, ?ret : CType, ?isPublic : Bool, ?isStatic : Bool, ?isOverride : Bool);
|
||||
EFunction( args : Array<Argument>, e : Expr, ?name : String, ?ret : CType, ?isPublic : Bool, ?isStatic : Bool, ?isOverride : Bool );
|
||||
EReturn( ?e : Expr );
|
||||
EArray( e : Expr, index : Expr );
|
||||
EArrayDecl( e : Array<Expr>, ?wantedType: CType);
|
||||
EArrayDecl( e : Array<Expr>, ?wantedType: CType );
|
||||
ENew( cl : String, params : Array<Expr> );
|
||||
EThrow( e : Expr );
|
||||
ETry( e : Expr, v : String, t : Null<CType>, ecatch : Expr );
|
||||
EObject( fl : Array<{ name : String, e : Expr }> );
|
||||
ETernary( cond : Expr, e1 : Expr, e2 : Expr );
|
||||
ESwitch( e : Expr, cases : Array<{ values : Array<Expr>, expr : Expr }>, ?defaultExpr : Expr);
|
||||
ESwitch( e : Expr, cases : Array<{ values : Array<Expr>, expr : Expr }>, ?defaultExpr : Expr );
|
||||
EDoWhile( cond : Expr, e : Expr);
|
||||
EMeta( name : String, args : Array<Expr>, e : Expr );
|
||||
ECheckType( e : Expr, t : CType );
|
||||
|
||||
EImport( c : String );
|
||||
EClass(name:String, fields:Array<Expr>, ?extend:String, interfaces:Array<String>);
|
||||
EClass( name:String, fields:Array<Expr>, ?extend:String, interfaces:Array<String> );
|
||||
}
|
||||
|
||||
typedef Argument = { name : String, ?t : CType, ?opt : Bool, ?value : Expr };
|
||||
|
||||
+9
-4
@@ -521,8 +521,11 @@ class Interp {
|
||||
v = expr(e);
|
||||
restore(old);
|
||||
return v;
|
||||
case EField(e, f):
|
||||
return get(expr(e), f);
|
||||
case EField(e, f, s):
|
||||
var field = expr(e);
|
||||
if(s && field == null)
|
||||
return null;
|
||||
return get(field, f);
|
||||
case EBinop(op, e1, e2):
|
||||
var fop = binops.get(op);
|
||||
if (fop == null)
|
||||
@@ -553,10 +556,12 @@ class Interp {
|
||||
args.push(expr(p));
|
||||
|
||||
switch (Tools.expr(e)) {
|
||||
case EField(e, f):
|
||||
case EField(e, f, s):
|
||||
var obj = expr(e);
|
||||
if (obj == null)
|
||||
if (obj == null) {
|
||||
if(s) return null;
|
||||
error(EInvalidAccess(f));
|
||||
}
|
||||
return fcall(obj, f, args);
|
||||
default:
|
||||
return call(null, expr(e), args);
|
||||
|
||||
+1
-1
@@ -1018,7 +1018,7 @@ class Parser {
|
||||
return makeBinop(op,e1,parseExpr());
|
||||
case TDot | TQuestionDot:
|
||||
var field = getIdent();
|
||||
return parseExprNext(mk(EField(e1,field),pmin(e1)));
|
||||
return parseExprNext(mk(EField(e1, field, tk == TQuestionDot), pmin(e1)));
|
||||
case TPOpen:
|
||||
return parseExprNext(mk(ECall(e1,parseExprList(TPClose)),pmin(e1)));
|
||||
case TBkOpen:
|
||||
|
||||
Reference in New Issue
Block a user