Exemple #1
0
 private ConstructArray/*!*/ ParseNewArray() {
   TypeNode type = (TypeNode)this.GetMemberFromToken();
   ExpressionList sizes = new ExpressionList(1);
   sizes.Add(PopOperand());
   ConstructArray result = new ConstructArray(type, sizes, null);
   result.Type = type.GetArrayType(1);
   return result;
 }
Exemple #2
0
 private Construct/*!*/ ParseConstruct() {
   TypeNodeList varArgTypes;
   Method meth = (Method)this.GetMemberFromToken(out varArgTypes);
   int n = meth.Parameters.Count;
   Expression[] args = new Expression[n];
   ExpressionList arguments = new ExpressionList(n);
   for (int i = n-1; i >= 0; i--) args[i] = PopOperand();
   for (int i = 0; i < n; i++) arguments.Add(args[i]);
   Construct result = new Construct(new MemberBinding(null, meth), arguments);
   result.Type = meth.DeclaringType;
   return result;
 }
Exemple #3
0
 private MethodCall/*!*/ ParseCalli(out bool isStatement) {
   FunctionPointer fp = this.reader.GetCalliSignature(this.GetInt32());
   if (fp == null) throw new InvalidMetadataException(ExceptionStrings.BaddCalliSignature);
   isStatement = BodyParser.TypeIsVoid(fp.ReturnType);
   int n = fp.ParameterTypes.Count; 
   Expression[] args = new Expression[n+1];
   ExpressionList arguments = new ExpressionList(n+1);
   for (int i = n; i >= 0; i--) args[i] = PopOperand();
   for (int i = 0; i <= n; i++) arguments.Add(args[i]);
   Expression thisob = fp.IsStatic ? null : PopOperand();
   MemberBinding methBinding = new MemberBinding(thisob, fp);
   MethodCall result = new MethodCall(methBinding, arguments, NodeType.Calli);
   result.Type = fp.ReturnType;
   result.IsTailCall = this.isTailCall;
   return result;
 }
Exemple #4
0
 private MethodCall/*!*/ ParseCall(NodeType typeOfCall, out bool isStatement) {
   TypeNodeList varArgTypes;
   Method meth = (Method)this.GetMemberFromToken(out varArgTypes);
   int numVarArgs = varArgTypes == null ? 0 : varArgTypes.Count;
   isStatement = BodyParser.TypeIsVoid(meth.ReturnType);
   int n = meth.Parameters == null ? 0 : meth.Parameters.Count; 
   if (typeOfCall == NodeType.Jmp) n = 0;
   else n += numVarArgs;
   Expression[] args = new Expression[n];
   ExpressionList arguments = new ExpressionList(n);
   for (int i = n-1; i >= 0; i--) args[i] = PopOperand();
   for (int i = 0; i < n; i++) arguments.Add(args[i]);
   if (varArgTypes != null) {
     for (int i = n-1, j = numVarArgs; j > 0; j--, i--) {
       Expression e = arguments[i];
       TypeNode t = varArgTypes[j-1];
       if (e != null && t != null) e.Type = t;
     }
   }
   Expression thisob = meth.IsStatic ? null : PopOperand();
   MemberBinding methBinding = new MemberBinding(thisob, meth);
   MethodCall result = new MethodCall(methBinding, arguments, typeOfCall);
   result.Type = meth.ReturnType;
   result.IsTailCall = this.isTailCall;
   if (this.constraint != null){
     result.Constraint = this.constraint;
     this.constraint = null;
   }
   return result;
 }
Exemple #5
0
 private Indexer/*!*/ ParseArrayElementLoad(OpCode opCode, TypeNode elementType){
   ExpressionList indexers = new ExpressionList(1); indexers.Add(PopOperand());
   Expression array = PopOperand();
   Indexer indexer = new Indexer(array, indexers);
   TypeNode t = elementType;
   switch(opCode){
     case OpCode.Ldelem_I1: t = CoreSystemTypes.Int8; break;
     case OpCode.Ldelem_U1: t = CoreSystemTypes.UInt8; break;
     case OpCode.Ldelem_I2: t = CoreSystemTypes.Int16; break;
     case OpCode.Ldelem_U2: t = CoreSystemTypes.UInt16; break;
     case OpCode.Ldelem_I4: t = CoreSystemTypes.Int32; break;
     case OpCode.Ldelem_U4: t = CoreSystemTypes.UInt32; break;
     case OpCode.Ldelem_I8: t = CoreSystemTypes.Int64; break;
     case OpCode.Ldelem_I: t = CoreSystemTypes.IntPtr; break;
     case OpCode.Ldelem_R4: t = CoreSystemTypes.Single; break;
     case OpCode.Ldelem_R8: t = CoreSystemTypes.Double; break;
     case OpCode.Ldelem: t = (TypeNode)this.GetMemberFromToken(); break;
     default:
       if (t != null) break;
       t = CoreSystemTypes.Object;
       ArrayType arrT = array.Type as ArrayType;
       if (arrT != null) t = arrT.ElementType;
       break;
   }
   indexer.ElementType = indexer.Type = t;
   return indexer;
 }
Exemple #6
0
 private AssignmentStatement/*!*/ ParseArrayElementAssignment(OpCode opCode) {
   Expression rhvalue = PopOperand();
   ExpressionList indexers = new ExpressionList(1);
   indexers.Add(PopOperand());
   Expression array = PopOperand();
   Indexer indexer = new Indexer(array, indexers);
   TypeNode t = CoreSystemTypes.Object;
   switch(opCode){
     case OpCode.Stelem_I: t = CoreSystemTypes.IntPtr; break;
     case OpCode.Stelem_I1: t = CoreSystemTypes.Int8; break;
     case OpCode.Stelem_I2: t = CoreSystemTypes.Int16; break;
     case OpCode.Stelem_I4: t = CoreSystemTypes.Int32; break;
     case OpCode.Stelem_I8: t = CoreSystemTypes.Int64; break;
     case OpCode.Stelem_R4: t = CoreSystemTypes.Single; break;
     case OpCode.Stelem_R8: t = CoreSystemTypes.Double; break;
     case OpCode.Stelem: t = (TypeNode)this.GetMemberFromToken(); break;
     default:
       ArrayType arrT = array.Type as ArrayType;
       if (arrT != null) t = arrT.ElementType;
       break;
   }
   indexer.ElementType = indexer.Type = t;
   return new AssignmentStatement(indexer, rhvalue);
 }