public CallExpression(Expression inner,Expression[] arguments) : base(inner) { if (arguments == null) throw new ArgumentNullException("arguments"); this.arguments = arguments; }
public override void Assign(CodeContext c,Expression source) { LocalBuilder local; int parameter; if (c.Locals.TryGetValue(variablename,out local)) { Type type = source.Evaluate(c); c.Convert(type,local.LocalType); c.IL.Emit(OpCodes.Stloc,local); } else if (c.Parameters.TryGetValue(variablename,out parameter)) { Type type = source.Evaluate(c); c.Convert(type,c.ParameterTypes[parameter]); if (c.Method.IsStatic) { c.IL.Emit(OpCodes.Starg,parameter); } else { c.IL.Emit(OpCodes.Starg,parameter + 1); } } else { throw new ApplicationException(); } }
public MemberExpression(Expression inner,string membername) : base(inner) { if (membername == null) throw new ArgumentNullException("membername"); this.membername = membername; }
public override void Assign(CodeContext c,Expression source) { Type type = Inner.Evaluate(c); MemberInfo member = GetMember(type,ScriptAccessType.Set); if (member.MemberType == MemberTypes.Field) { FieldInfo field = (FieldInfo)member; if (field.IsInitOnly || field.IsLiteral) { throw new ApplicationException(); } Type sourcetype = source.Evaluate(c); c.Convert(sourcetype,field.FieldType); c.IL.Emit(OpCodes.Stfld,field); } else if (member.MemberType == MemberTypes.Property) { PropertyInfo property = (PropertyInfo)member; if (!property.CanWrite) { throw new ApplicationException(); } Type sourcetype = source.Evaluate(c); c.Convert(sourcetype,property.PropertyType); c.IL.Emit(OpCodes.Callvirt,property.GetSetMethod()); } else { throw new ApplicationException(); } }
public BinaryExpression(Expression left,Expression right) { if (left == null) throw new ArgumentNullException("left"); if (right == null) throw new ArgumentNullException("right"); this.left = left; this.right = right; }
public VarStatement(string variablename,Expression expression) { if (variablename == null) throw new ArgumentNullException("variablename"); if (expression == null) throw new ArgumentNullException("expression"); this.variablename = variablename; this.expression = expression; }
public WhileStatement(Expression condition,Statement loopstatement,Statement elsestatement) { if (condition == null) throw new ArgumentNullException("condition"); if (loopstatement == null) throw new ArgumentNullException("loopstatement"); if (elsestatement == null) throw new ArgumentNullException("elsestatement"); this.condition = condition; this.loopstatement = loopstatement; this.elsestatement = elsestatement; }
public IfStatement(Expression condition,Statement thenstatement,Statement elsestatement) { if (condition == null) throw new ArgumentNullException("condition"); if (thenstatement == null) throw new ArgumentNullException("thenstatement"); if (elsestatement == null) throw new ArgumentNullException("elsestatement"); this.condition = condition; this.thenstatement = thenstatement; this.elsestatement = elsestatement; }
public ForEachStatement(string variabletype,string variablename,Expression collection,Statement loopstatement,Statement elsestatement) { if (variabletype == null) throw new ArgumentNullException("variabletype"); if (variablename == null) throw new ArgumentNullException("variablename"); if (collection == null) throw new ArgumentNullException("collection"); if (loopstatement == null) throw new ArgumentNullException("loopstatement"); if (elsestatement == null) throw new ArgumentNullException("elsestatement"); this.variabletype = variabletype; this.variablename = variablename; this.collection = collection; this.loopstatement = loopstatement; this.elsestatement = elsestatement; }
public BitwiseNotExpression(Expression inner) : base(inner) { }
public virtual Type Invoke(CodeContext c,Expression[] arguments) { throw new ApplicationException(); }
public virtual void Assign(CodeContext c,Expression source) { throw new ApplicationException(); }
public ModuloExpression(Expression left,Expression right) : base(left,right) { }
public DivideExpression(Expression left,Expression right) : base(left,right) { }
public override Type Invoke(CodeContext c,Expression[] arguments) { Type type = Inner.Evaluate(c); MemberInfo member = GetMember(type,ScriptAccessType.Invoke); if (member.MemberType == MemberTypes.Method) { MethodInfo method = (MethodInfo)member; ParameterInfo[] parameters = method.GetParameters(); if (parameters.Length != arguments.Length) { throw new ApplicationException(); } for (int i = 0;i < arguments.Length;i++) { Type argumenttype = arguments[i].Evaluate(c); c.Convert(argumenttype,parameters[i].ParameterType); } c.IL.Emit(OpCodes.Callvirt,method); return method.ReturnType; } else { throw new ApplicationException(); } }
public AssignmentExpression(Expression left,Expression right) : base(left,right) { }
public LogicalNotExpression(Expression inner) : base(inner) { }
public LessExpression(Expression left,Expression right) : base(left,right) { }
public GreaterOrEqualExpression(Expression left,Expression right) : base(left,right) { }
public IsNotExpression(Expression left,Expression right) : base(left,right) { }
public EqualExpression(Expression left,Expression right) : base(left,right) { }
public NegateExpression(Expression inner) : base(inner) { }
public MultiplyExpression(Expression left,Expression right) : base(left,right) { }
public SubtractExpression(Expression left,Expression right) : base(left,right) { }
public BitwiseXorExpression(Expression left,Expression right) : base(left,right) { }
public LogicalAndExpression(Expression left,Expression right) : base(left,right) { }
public LeftShiftExpression(Expression left,Expression right) : base(left,right) { }
public ExpressionStatement(Expression expression) { if (expression == null) throw new ArgumentNullException("expression"); this.expression = expression; }
public UnaryExpression(Expression inner) { if (inner == null) throw new ArgumentNullException("inner"); this.inner = inner; }
public ReturnStatement(Expression expression) { // expression can be null this.expression = expression; }