public override void Evaluate(Expression left, Expression right, Emit.ILGenerator ilg, ExecutionContext ec) { Type t = left.GetEvaluatedType(ec); Type t2 = right.GetEvaluatedType(ec); if (t != t2) { throw new NotImplementedException("Type coercion not implemented yet."); } if (t == typeof(string)) { //Concatenate strings! Fun for all. //TODO: optimize the shit out of this to determine if there is tons of concatenating going on because this is inefficient as hell for something like "lol" + "hi" + 3 //TODO: classes with operator overloading so I don't need to do special exceptions within the language code itself. I dislike that. left.Push(ilg, ec); right.Push(ilg, ec); ilg.Emit(Emit.OpCodes.Call, typeof(String).GetMethod("Concat", new Type[] { typeof(string), typeof(string) })); } }
public abstract void Evaluate(Expression left, Expression right, Emit.ILGenerator ilg, ExecutionContext ec);
public abstract Type GetEvaluatedType(Expression left, Expression right, ExecutionContext ec);
public override void Evaluate(Expression left, Expression right, Emit.ILGenerator ilg, ExecutionContext ec) { throw new NotImplementedException("Non + operators are not implemented."); }
public override Type GetEvaluatedType(Expression left, Expression right, ExecutionContext ec) { throw new NotImplementedException("Non + operators are not implemented."); }
public override Type GetEvaluatedType(Expression left, Expression right, ExecutionContext ec) { Type t = left.GetEvaluatedType(ec); Type t2 = right.GetEvaluatedType(ec); if (t != t2) { throw new NotImplementedException("Type coercion not implemented yet."); } return t; //same type because you're adding! }
public NegateExpression(Expression e) { this.e = e; }
public MathExpression(Expression left, Operator o, Expression right) { this.left = left; this.o = o; this.right = right; }
public AssignmentStatement(Identifier varName, Expression e) { this.e = e; this.varName = varName.Value; }
public ReturnStatement(Expression e) { this.returnExp = e; }