public Input(Expression inputPromptExpr, Block inputs, LineId line) : base(line) { this.inputPrompt = new Print( new Expression[] { inputPromptExpr, new StringLiteral("\0", line) }, line); this.inputs = inputs; }
private Assign(Location loc, string builtIn, LineId line) : base(line) { this.location = loc; this.value = null; this.builtIn = builtIn; }
public For(Assign init, Expression comparison, Assign update, Statement stmt, LineId line) : base(line) { this.init = init; this.comparison = comparison; this.stmt = stmt; this.update = update; }
protected RelationalExpression(Expression e1, Expression e2, bool not, LineId line) : base(line) { this.e1 = e1; this.e2 = e2; this.not = not; }
public If(Expression conditional, string label, string elseLabel, LineId line) : base(line) { jmp = new Goto(label, line); elseJmp = new Goto(elseLabel, line); this.conditional = conditional; }
public override void EmitStore(ILGenerator gen, IList<FieldBuilder> fields, Expression value) { gen.Emit(OpCodes.Ldarg_0); // Emit the code to generate the value for the given expression value.Emit(gen); // Convert booleans (which are used internally for Booleans) to doubles // which is how they are stored in TIBasic. Plus it needs to be negated. if (value.GetBasicType() == BasicType.Boolean) { gen.Emit(OpCodes.Conv_R8); gen.Emit(OpCodes.Neg); } gen.Emit(OpCodes.Stfld, fields[symbolIndex]); }
public Negative(Expression value, LineId line) : base(line) { this.value = value; }
public Equals(Expression e1, Expression e2, bool not, LineId line) : base(e1, e2, not, line) { }
protected BinaryOperator(Expression e1, Expression e2, LineId line) : base(line) { this.expr1 = e1; this.expr2 = e2; }
public override void CheckTypes() { location.ConstrainType(symbols); BasicType locationType = location.BasicType; if (locationType != BasicType.String && locationType != BasicType.Number && locationType != BasicType.Boolean) throw new Exception("type error"); if (builtIn != null) { switch (builtIn) { case readExpr: value = (locationType == BasicType.String) ? BuiltInsMethodCall.ReadStringFromData() : BuiltInsMethodCall.ReadNumberFromData(); break; case inputExpr: value = (locationType == BasicType.String) ? BuiltInsMethodCall.ReadStringFromConsole() : BuiltInsMethodCall.ReadNumberFromConsole(); break; } } valueType = value.GetBasicType(); if (locationType == BasicType.String && valueType == BasicType.String) return; if (valueType == BasicType.Number || valueType == BasicType.Boolean) return; throw new Exception("Type mismatch exception in an assignment"); }
public Randomize(Expression seedExpression, LineId line) : base(line) { this.seedExpression = seedExpression; seedSpecified = true; }
public Power(Expression e1, Expression e2, LineId line) : base(e1, e2, line) { }
public Assign(Location loc, Expression value, LineId line) : base(line) { this.location = loc; this.value = value; }
public static RelationalExpression CompareLessThan( Expression e1, Expression e2, LineId line) { return new LessThan(e1, e2, false, line); }
public static RelationalExpression CompareLessThanEquals( Expression e1, Expression e2, LineId line) { return new GreaterThan(e1, e2, true, line); }
public GreaterThan(Expression expr1, Expression expr2, bool not, LineId line) : base(expr1, expr2, not, line) { }
Expression MoreStringExpr(Expression s1) { if (lookahead == Token.Concatenate) { LineId line = lexer.LineId; Match(Token.Concatenate); Expression s2 = StringExpr(); return MoreStringExpr(new Concatenate(s1, s2, line)); } else return s1; }
public Subtract(Expression e1, Expression e2, LineId line) : base(e1, e2, line) { }
public Tab(Expression expr, LineId line) : base(line) { this.expr = expr; }
public LessThan(Expression e1, Expression e2, bool not, LineId line) : base(e1, e2, not, line) { }
Expression MoreMultiplicationExpr(Expression m1) { LineId line = lexer.LineId; switch (lookahead) { case Token.Times: case Token.Divides: Token l = lookahead; Match(lookahead); Expression m2 = MultiplicationExpr(); Expression m3=null; if (l == Token.Times) m3 = new Multiply(m1, m2, line); if (l == Token.Divides) m3 = new Division(m1, m2, line); return MoreMultiplicationExpr(m3); default: break; } return m1; }
Expression MoreAdditionExpr(Expression a1) { LineId line = lexer.LineId; switch (lookahead) { case Token.Plus: case Token.Minus: Token l = lookahead; Match(lookahead); Expression a2 = AdditionExpr(); Expression a3=null; if (l == Token.Plus) a3 = new Add(a1, a2, line); if (l == Token.Minus) a3 = new Subtract(a1, a2, line); return MoreAdditionExpr(a3); default: break; } return a1; }
public OnGoto(Expression number, List<string> targets, LineId line) : base(line) { this.numericExpression = number; this.targets = targets; }
public abstract void EmitStore(ILGenerator gen, IList<FieldBuilder> fields, Expression value);
public Concatenate(Expression s1, Expression s2, LineId line) : base(line) { this.s1 = s1; this.s2 = s2; }
public Add(Expression e1, Expression e2, LineId line) : base(e1, e2, line) { }
Expression MoreFactors(Expression f1) { LineId line = lexer.LineId; if (lookahead == Token.Exponent) { Match(lookahead); Expression f2 = Factor(); Expression f3 = new Power(f1, f2, line); return MoreFactors(f3); } return f1; }
Expression MoreRelationalExpr(Expression r1) { Expression r2; Expression r3=null; LineId line = lexer.LineId; switch (lookahead) { case Token.Equals: case Token.LessThan: case Token.GreaterThan: case Token.NotEquals: case Token.LessThanEqual: case Token.GreaterThanEqual: Token l = lookahead; Match(lookahead); r2 = RelationalExpr(); if (l == Token.Equals) r3 = RelationalExpression.CompareEquals(r1, r2, line); else if (l == Token.LessThan) r3 = RelationalExpression.CompareLessThan(r1, r2, line); else if (l == Token.LessThanEqual) r3 = RelationalExpression.CompareLessThanEquals(r1, r2, line); else if (l == Token.GreaterThan) r3 = RelationalExpression.CompareGreaterThan(r1, r2, line); else if (l == Token.GreaterThanEqual) r3 = RelationalExpression.CompareGreaterThanEquals(r1, r2, line); else if (l == Token.NotEquals) r3 = RelationalExpression.CompareNotEquals(r1, r2, line); return MoreRelationalExpr(r3); default: break; } return r1; }
public static RelationalExpression CompareNotEquals( Expression e1, Expression e2, LineId line) { return new Equals(e1, e2, true, line); }
public Print(Expression[] values, LineId line) : base(line) { this.values = values; printItemTypes = new BasicType[values.Length]; }