예제 #1
0
 public CallExpression(Expression inner,Expression[] arguments)
     : base(inner)
 {
     if (arguments == null)
         throw new ArgumentNullException("arguments");
     this.arguments = arguments;
 }
예제 #2
0
 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();
     }
 }
예제 #3
0
 public MemberExpression(Expression inner,string membername)
     : base(inner)
 {
     if (membername == null)
         throw new ArgumentNullException("membername");
     this.membername = membername;
 }
예제 #4
0
 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();
     }
 }
예제 #5
0
 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;
 }
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
 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;
 }
예제 #9
0
 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;
 }
예제 #10
0
 public BitwiseNotExpression(Expression inner) : base(inner)
 {
 }
예제 #11
0
 public virtual Type Invoke(CodeContext c,Expression[] arguments)
 {
     throw new ApplicationException();
 }
예제 #12
0
 public virtual void Assign(CodeContext c,Expression source)
 {
     throw new ApplicationException();
 }
예제 #13
0
 public ModuloExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #14
0
 public DivideExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #15
0
 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();
     }
 }
예제 #16
0
 public AssignmentExpression(Expression left,Expression right)
     : base(left,right)
 {
 }
예제 #17
0
 public LogicalNotExpression(Expression inner) : base(inner)
 {
 }
예제 #18
0
 public LessExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #19
0
 public GreaterOrEqualExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #20
0
 public IsNotExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #21
0
 public EqualExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #22
0
 public NegateExpression(Expression inner) : base(inner)
 {
 }
예제 #23
0
 public MultiplyExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #24
0
 public SubtractExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #25
0
 public BitwiseXorExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #26
0
 public LogicalAndExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #27
0
 public LeftShiftExpression(Expression left,Expression right) : base(left,right)
 {
 }
예제 #28
0
 public ExpressionStatement(Expression expression)
 {
     if (expression == null)
         throw new ArgumentNullException("expression");
     this.expression = expression;
 }
예제 #29
0
 public UnaryExpression(Expression inner)
 {
     if (inner == null)
         throw new ArgumentNullException("inner");
     this.inner = inner;
 }
예제 #30
0
 public ReturnStatement(Expression expression)
 {
     // expression can be null
     this.expression = expression;
 }