Beispiel #1
0
        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) }));
            }
        }
Beispiel #2
0
 public abstract void Evaluate(Expression left, Expression right, Emit.ILGenerator ilg, ExecutionContext ec);
Beispiel #3
0
 public abstract Type GetEvaluatedType(Expression left, Expression right, ExecutionContext ec);
Beispiel #4
0
 public override void Evaluate(Expression left, Expression right, Emit.ILGenerator ilg, ExecutionContext ec)
 {
     throw new NotImplementedException("Non + operators are not implemented.");
 }
Beispiel #5
0
 public override Type GetEvaluatedType(Expression left, Expression right, ExecutionContext ec)
 {
     throw new NotImplementedException("Non + operators are not implemented.");
 }
Beispiel #6
0
        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!
        }
Beispiel #7
0
 public NegateExpression(Expression e)
 {
     this.e = e;
 }
Beispiel #8
0
 public MathExpression(Expression left, Operator o, Expression right)
 {
     this.left = left;
     this.o = o;
     this.right = right;
 }
Beispiel #9
0
 public AssignmentStatement(Identifier varName, Expression e)
 {
     this.e = e;
     this.varName = varName.Value;
 }
Beispiel #10
0
 public ReturnStatement(Expression e)
 {
     this.returnExp = e;
 }