public object visit_this(ThisExpr this_expr) { if (class_type == ClassType.None) { throw new RuntimeException("Cannot use this outside of a class"); } // Resolve the this identifier resolve_local_position(this_expr, "this"); return(null); }
private static bool ShallowEq(ThisExpr expr1, ThisExpr expr2) { if (expr1 is ImplicitThisExpr && expr2 is ImplicitThisExpr) { return(ShallowEq((ImplicitThisExpr)expr1, (ImplicitThisExpr)expr2)); } else { return(expr1.GetType() == expr2.GetType()); // LiteralExpr is not abstract } }
public override Null Visit(ThisExpr node) { context = null; node.computedType = new ErrorType(); if (node.info.classDef != null && node.info.funcDef != null && !node.info.inStaticFunc) { node.computedType = new ClassType { def = node.info.classDef }; } else { log.ErrorBadThis(node.location); } return null; }
protected override object MatchThisExpr(ThisExpr expr) { if (_currentClass == ClassType.NONE) { Lox.Error(expr.Keyword, "Cannot use 'this' outside of a class."); } ResolveLocal(expr, expr.Keyword); return(null); }
public override void Visit(ThisExpr e) { string definingClassName = e.Type.ToString(); var definingClass = FindDeclaration(definingClassName, SurroundingScope, Kind.Class); var declaration = definingClass; CreateSymbol( name: "this", kind: Kind.Class, positionAsToken: e.tok, bodyStartPosAsToken: null, bodyEndPosAsToken: null, isDeclaration: false, declarationSymbol: declaration, addUsageAtDeclaration: false, canHaveChildren: false, canBeUsed: false ); }
public virtual void Visit(ThisExpr thisExpression) { }
void ConstAtomExpression(out Expression e, bool allowSemi, bool allowLambda) { Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; BigInteger n; Basetypes.BigDec d; e = dummyExpr; Type toType = null; switch (la.kind) { case 131: { Get(); e = new LiteralExpr(t, false); break; } case 132: { Get(); e = new LiteralExpr(t, true); break; } case 133: { Get(); e = new LiteralExpr(t); break; } case 2: case 3: { Nat(out n); e = new LiteralExpr(t, n); break; } case 4: { Dec(out d); e = new LiteralExpr(t, d); break; } case 19: { Get(); e = new CharLiteralExpr(t, t.val.Substring(1, t.val.Length - 2)); break; } case 20: { Get(); bool isVerbatimString; string s = Util.RemoveParsedStringQuotes(t.val, out isVerbatimString); e = new StringLiteralExpr(t, s, isVerbatimString); break; } case 134: { Get(); e = new ThisExpr(t); break; } case 135: { Get(); x = t; Expect(50); Expression(out e, true, true); Expect(51); e = new UnaryOpExpr(x, UnaryOpExpr.Opcode.Fresh, e); break; } case 136: { Get(); x = t; Expect(50); Expression(out e, true, true); Expect(51); e = new OldExpr(x, e); break; } case 23: { Get(); x = t; Expression(out e, true, true); e = new UnaryOpExpr(x, UnaryOpExpr.Opcode.Cardinality, e); Expect(23); break; } case 8: case 10: { if (la.kind == 8) { Get(); x = t; toType = new IntType(); } else { Get(); x = t; toType = new RealType(); } Expect(50); Expression(out e, true, true); Expect(51); e = new ConversionExpr(x, e, toType); break; } case 50: { ParensExpression(out e, allowSemi, allowLambda); break; } default: SynErr(234); break; } }
public object visit_this(ThisExpr this_expr) { return(lookup_variable(new Token(Token.Type.This, "this"), this_expr)); }
public override void Leave(ThisExpr e) { }
public override void Visit(ThisExpr e) { }
public object visit_this(ThisExpr this_expr) { return(lookup_variable("this", this_expr)); }
protected abstract object MatchThisExpr(ThisExpr thisExpr);
public virtual void Visit(ThisExpr expr) { }
void ConstAtomExpression(out Expression e, bool allowSemi, bool allowLambda) { Contract.Ensures(Contract.ValueAtReturn(out e) != null); IToken/*!*/ x; BigInteger n; Basetypes.BigDec d; e = dummyExpr; Type toType = null; switch (la.kind) { case 138: { Get(); e = new LiteralExpr(t, false); break; } case 139: { Get(); e = new LiteralExpr(t, true); break; } case 140: { Get(); e = new LiteralExpr(t); break; } case 2: case 3: { Nat(out n); e = new LiteralExpr(t, n); break; } case 4: { Dec(out d); e = new LiteralExpr(t, d); break; } case 20: { Get(); e = new CharLiteralExpr(t, t.val.Substring(1, t.val.Length - 2)); break; } case 21: { Get(); bool isVerbatimString; string s = Util.RemoveParsedStringQuotes(t.val, out isVerbatimString); e = new StringLiteralExpr(t, s, isVerbatimString); break; } case 141: { Get(); e = new ThisExpr(t); break; } case 142: { Get(); x = t; Expect(54); Expression(out e, true, true); Expect(55); e = new UnaryOpExpr(x, UnaryOpExpr.Opcode.Fresh, e); break; } case 143: { Get(); x = t; Expect(54); Expression(out e, true, true); Expect(55); e = new UnaryOpExpr(x, UnaryOpExpr.Opcode.Allocated, e); break; } case 144: { Get(); x = t; FrameExpression fe; var mod = new List<FrameExpression>(); Expect(54); FrameExpression(out fe, false, false); mod.Add(fe); while (la.kind == 23) { Get(); FrameExpression(out fe, false, false); mod.Add(fe); } Expect(55); e = new UnchangedExpr(x, mod); break; } case 145: { Get(); x = t; Expect(54); Expression(out e, true, true); Expect(55); e = new OldExpr(x, e); break; } case 24: { Get(); x = t; Expression(out e, true, true, false); e = new UnaryOpExpr(x, UnaryOpExpr.Opcode.Cardinality, e); Expect(24); break; } case 9: case 11: { if (la.kind == 9) { Get(); x = t; toType = new IntType(); } else { Get(); x = t; toType = new RealType(); } errors.Deprecated(t, string.Format("the syntax \"{0}(expr)\" for type conversions has been deprecated; the new syntax is \"expr as {0}\"", x.val)); Expect(54); Expression(out e, true, true); Expect(55); e = new ConversionExpr(x, e, toType); break; } case 54: { ParensExpression(out e, allowSemi, allowLambda); break; } default: SynErr(262); break; } }
public override void Visit(ThisExpr expr) { AddStr("this."); }