Inheritance: ICSharpCode.NRefactory.Ast.Statement
Ejemplo n.º 1
0
 public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
 {
     if (collectingUsedLabels) {
         usedLabels.Add(gotoStatement.Label);
     }
     return null;
 }
Ejemplo n.º 2
0
	void GotoStatement(
#line  2634 "VBNET.ATG" 
out GotoStatement goToStatement) {

#line  2636 "VBNET.ATG" 
		string label = String.Empty;
		
		Expect(104);
		LabelName(
#line  2639 "VBNET.ATG" 
out label);

#line  2641 "VBNET.ATG" 
		goToStatement = new GotoStatement(label);
		
	}
Ejemplo n.º 3
0
        public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
        {
            System.CodeDom.CodeGotoStatement gotoStmt = new CodeGotoStatement(gotoStatement.Label);

            // Add Statement to Current Statement Collection
            AddStmt(gotoStmt);

            return gotoStmt;
        }
Ejemplo n.º 4
0
	void GotoStatement(
#line  3466 "VBNET.ATG" 
out GotoStatement goToStatement) {

#line  3467 "VBNET.ATG" 
		string label = String.Empty; Location startLocation = la.Location; 
		Expect(134);
		LabelName(
#line  3469 "VBNET.ATG" 
out label);

#line  3471 "VBNET.ATG" 
		goToStatement = new GotoStatement(label) {
		StartLocation = startLocation,
		EndLocation = t.EndLocation
		};
		
	}
Ejemplo n.º 5
0
	void GotoStatement(
#line  3358 "VBNET.ATG" 
out GotoStatement goToStatement) {

#line  3360 "VBNET.ATG" 
		string label = String.Empty;
		
		Expect(132);
		LabelName(
#line  3363 "VBNET.ATG" 
out label);

#line  3365 "VBNET.ATG" 
		goToStatement = new GotoStatement(label);
		
	}
 public override object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data)
 {
     Console.WriteLine("VisitGotoStatement");
     return null;
 }
		public virtual object TrackedVisitGotoStatement(GotoStatement gotoStatement, object data) {
			return base.VisitGotoStatement(gotoStatement, data);
		}
Ejemplo n.º 8
0
	void GotoStatement(
#line  3119 "VBNET.ATG" 
out GotoStatement goToStatement) {

#line  3121 "VBNET.ATG" 
		string label = String.Empty;
		
		Expect(119);
		LabelName(
#line  3124 "VBNET.ATG" 
out label);

#line  3126 "VBNET.ATG" 
		goToStatement = new GotoStatement(label);
		
	}
Ejemplo n.º 9
0
	void GotoStatement(
#line  2595 "VBNET.ATG" 
out GotoStatement goToStatement) {

#line  2597 "VBNET.ATG" 
		string label = String.Empty;
		
		Expect(104);
		LabelName(
#line  2600 "VBNET.ATG" 
out label);

#line  2602 "VBNET.ATG" 
		goToStatement = new GotoStatement(label);
		
	}
		public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
		{
			gotos.Add(gotoStatement);
			return base.VisitGotoStatement(gotoStatement, data);
		}
		public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
		{
			this.isOk = false;
			foreach (LabelStatement label in this.labels) {
				if (label.Label == gotoStatement.Label)
					this.isOk = true;
			}
			if (!this.isOk) {
				MessageService.ShowError("Label '" + gotoStatement.Label + "' not found inside the selected range!");
			}
			
			return base.VisitGotoStatement(gotoStatement, data);
		}
 private bool IsMatch(GotoStatement left, GotoStatement right)
 {
     return left.Label == right.Label;
 }
Ejemplo n.º 13
0
        public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
        {
            // Remove redundant goto which goes to a label that imideately follows
            INode fallthoughTarget = GetNextStatement(gotoStatement);
            if ((fallthoughTarget is LabelStatement) &&
                (fallthoughTarget as LabelStatement).Label == gotoStatement.Label) {
                RemoveCurrentNode();
                return null;
            }

            // Replace goto with 'break'
            // Break statement moves right outside the looop
            if (CurrentLoop != null) {
                INode breakTarget = GetNextStatement(CurrentLoop);
                if ((breakTarget is LabelStatement) &&
                    (breakTarget as LabelStatement).Label == gotoStatement.Label) {
                    ReplaceCurrentNode(new BreakStatement());
                    return null;
                }
            }

            // Replace goto with 'continue'
            // Continue statement which moves at the very end of loop
            if (CurrentLoop != null &&
                (CurrentLoop.EmbeddedStatement is BlockStatement) &&
                ((CurrentLoop.EmbeddedStatement as BlockStatement).Children.Last as LabelStatement) != null &&
                ((CurrentLoop.EmbeddedStatement as BlockStatement).Children.Last as LabelStatement).Label == gotoStatement.Label) {
                ReplaceCurrentNode(new ContinueStatement());
                return null;
            }

            // Replace goto with 'continue'
            // Continue statement which moves at the very start of for loop
            if (CurrentLoop != null) {
                INode continueTarget = ExitBlockStatement(CurrentLoop); // The start of the loop
                if ((continueTarget is LabelStatement) &&
                    (continueTarget as LabelStatement).Label == gotoStatement.Label) {
                    ReplaceCurrentNode(new ContinueStatement());
                    return null;
                }
            }

            return null;
        }
Ejemplo n.º 14
0
	void GotoStatement(
#line  1772 "cs.ATG" 
out Statement stmt) {

#line  1773 "cs.ATG" 
		Expression expr; stmt = null; 
		Expect(78);
		if (StartOf(18)) {
			Identifier();

#line  1777 "cs.ATG" 
			stmt = new GotoStatement(t.val); 
			Expect(11);
		} else if (la.kind == 55) {
			lexer.NextToken();
			Expr(
#line  1778 "cs.ATG" 
out expr);
			Expect(11);

#line  1778 "cs.ATG" 
			stmt = new GotoCaseStatement(expr); 
		} else if (la.kind == 63) {
			lexer.NextToken();
			Expect(11);

#line  1779 "cs.ATG" 
			stmt = new GotoCaseStatement(null); 
		} else SynErr(203);
	}
 public virtual bool VisitGotoStatement(GotoStatement gotoStatement, object d)
 {
     if ((gotoStatement == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if(gotoStatement.GetType() != d.GetType()) {return SetFailure();}
     var data = (GotoStatement)d;
     if (!IsMatch(gotoStatement, data)) {
         return SetFailure();
     }
     return true;
 }
Ejemplo n.º 16
0
        static Ast.INode TransformByteCode_Internal(MethodDefinition methodDef, ILExpression byteCode, List<Ast.Expression> args)
        {
            // throw new NotImplementedException();

            OpCode opCode = byteCode.OpCode;
            object operand = byteCode.Operand;
            Ast.TypeReference operandAsTypeRef = operand is Cecil.TypeReference ? new Ast.TypeReference(((Cecil.TypeReference)operand).FullName) : null;
            ILExpression operandAsByteCode = operand as ILExpression;
            Ast.Expression arg1 = args.Count >= 1 ? args[0] : null;
            Ast.Expression arg2 = args.Count >= 2 ? args[1] : null;
            Ast.Expression arg3 = args.Count >= 3 ? args[2] : null;

            Ast.Statement branchCommand = null;
            if (byteCode.Operand is ILLabel) {
                branchCommand = new Ast.GotoStatement(((ILLabel)byteCode.Operand).Name);
            }

            switch(opCode.Code) {
                #region Arithmetic
                    case Code.Add:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
                    case Code.Add_Ovf:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
                    case Code.Add_Ovf_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Add, arg2);
                    case Code.Div:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Divide, arg2);
                    case Code.Div_Un:     return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Divide, arg2);
                    case Code.Mul:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2);
                    case Code.Mul_Ovf:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2);
                    case Code.Mul_Ovf_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Multiply, arg2);
                    case Code.Rem:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Modulus, arg2);
                    case Code.Rem_Un:     return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Modulus, arg2);
                    case Code.Sub:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
                    case Code.Sub_Ovf:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
                    case Code.Sub_Ovf_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Subtract, arg2);
                    case Code.And:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.BitwiseAnd, arg2);
                    case Code.Xor:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ExclusiveOr, arg2);
                    case Code.Shl:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftLeft, arg2);
                    case Code.Shr:        return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftRight, arg2);
                    case Code.Shr_Un:     return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.ShiftRight, arg2);

                    case Code.Neg:        return new Ast.UnaryOperatorExpression(arg1, UnaryOperatorType.Minus);
                    case Code.Not:        return new Ast.UnaryOperatorExpression(arg1, UnaryOperatorType.BitNot);
                #endregion
                #region Arrays
                    case Code.Newarr:
                        operandAsTypeRef.RankSpecifier = new int[] {0};
                        return new Ast.ArrayCreateExpression(operandAsTypeRef, new List<Expression>(new Expression[] {arg1}));

                    case Code.Ldlen: return new Ast.MemberReferenceExpression(arg1, "Length");

                    case Code.Ldelem_I:
                    case Code.Ldelem_I1:
                    case Code.Ldelem_I2:
                    case Code.Ldelem_I4:
                    case Code.Ldelem_I8:
                    case Code.Ldelem_U1:
                    case Code.Ldelem_U2:
                    case Code.Ldelem_U4:
                    case Code.Ldelem_R4:
                    case Code.Ldelem_R8:
                    case Code.Ldelem_Ref: return new Ast.IndexerExpression(arg1, new List<Expression>(new Expression[] {arg2}));
                    case Code.Ldelem_Any: throw new NotImplementedException();
                    case Code.Ldelema:    return new Ast.IndexerExpression(arg1, new List<Expression>(new Expression[] {arg2}));

                    case Code.Stelem_I:
                    case Code.Stelem_I1:
                    case Code.Stelem_I2:
                    case Code.Stelem_I4:
                    case Code.Stelem_I8:
                    case Code.Stelem_R4:
                    case Code.Stelem_R8:
                    case Code.Stelem_Ref: return new Ast.AssignmentExpression(new Ast.IndexerExpression(arg1, new List<Expression>(new Expression[] {arg2})), AssignmentOperatorType.Assign, arg3);
                    case Code.Stelem_Any: throw new NotImplementedException();
                #endregion
                #region Branching
                    case Code.Br:      return branchCommand;
                    case Code.Brfalse: return new Ast.IfElseStatement(new Ast.UnaryOperatorExpression(arg1, UnaryOperatorType.Not), branchCommand);
                    case Code.Brtrue:  return new Ast.IfElseStatement(arg1, branchCommand);
                    case Code.Beq:     return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Equality, arg2), branchCommand);
                    case Code.Bge:     return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThanOrEqual, arg2), branchCommand);
                    case Code.Bge_Un:  return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThanOrEqual, arg2), branchCommand);
                    case Code.Bgt:     return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThan, arg2), branchCommand);
                    case Code.Bgt_Un:  return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThan, arg2), branchCommand);
                    case Code.Ble:     return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThanOrEqual, arg2), branchCommand);
                    case Code.Ble_Un:  return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThanOrEqual, arg2), branchCommand);
                    case Code.Blt:     return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThan, arg2), branchCommand);
                    case Code.Blt_Un:  return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThan, arg2), branchCommand);
                    case Code.Bne_Un:  return new Ast.IfElseStatement(new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.InEquality, arg2), branchCommand);
                #endregion
                #region Comparison
                    case Code.Ceq:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.Equality, ConvertIntToBool(arg2));
                    case Code.Cgt:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThan, arg2);
                    case Code.Cgt_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.GreaterThan, arg2);
                    case Code.Clt:    return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThan, arg2);
                    case Code.Clt_Un: return new Ast.BinaryOperatorExpression(arg1, BinaryOperatorType.LessThan, arg2);
                #endregion
                #region Conversions
                    case Code.Conv_I:    return new Ast.CastExpression(new Ast.TypeReference(typeof(int).FullName), arg1, CastType.Cast); // TODO
                    case Code.Conv_I1:   return new Ast.CastExpression(new Ast.TypeReference(typeof(SByte).FullName), arg1, CastType.Cast);
                    case Code.Conv_I2:   return new Ast.CastExpression(new Ast.TypeReference(typeof(Int16).FullName), arg1, CastType.Cast);
                    case Code.Conv_I4:   return new Ast.CastExpression(new Ast.TypeReference(typeof(Int32).FullName), arg1, CastType.Cast);
                    case Code.Conv_I8:   return new Ast.CastExpression(new Ast.TypeReference(typeof(Int64).FullName), arg1, CastType.Cast);
                    case Code.Conv_U:    return new Ast.CastExpression(new Ast.TypeReference(typeof(uint).FullName), arg1, CastType.Cast); // TODO
                    case Code.Conv_U1:   return new Ast.CastExpression(new Ast.TypeReference(typeof(Byte).FullName), arg1, CastType.Cast);
                    case Code.Conv_U2:   return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt16).FullName), arg1, CastType.Cast);
                    case Code.Conv_U4:   return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt32).FullName), arg1, CastType.Cast);
                    case Code.Conv_U8:   return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt64).FullName), arg1, CastType.Cast);
                    case Code.Conv_R4:   return new Ast.CastExpression(new Ast.TypeReference(typeof(float).FullName), arg1, CastType.Cast);
                    case Code.Conv_R8:   return new Ast.CastExpression(new Ast.TypeReference(typeof(double).FullName), arg1, CastType.Cast);
                    case Code.Conv_R_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(double).FullName), arg1, CastType.Cast); // TODO

                    case Code.Conv_Ovf_I:  return new Ast.CastExpression(new Ast.TypeReference(typeof(int).FullName), arg1, CastType.Cast); // TODO
                    case Code.Conv_Ovf_I1: return new Ast.CastExpression(new Ast.TypeReference(typeof(SByte).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_I2: return new Ast.CastExpression(new Ast.TypeReference(typeof(Int16).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_I4: return new Ast.CastExpression(new Ast.TypeReference(typeof(Int32).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_I8: return new Ast.CastExpression(new Ast.TypeReference(typeof(Int64).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U:  return new Ast.CastExpression(new Ast.TypeReference(typeof(uint).FullName), arg1, CastType.Cast); // TODO
                    case Code.Conv_Ovf_U1: return new Ast.CastExpression(new Ast.TypeReference(typeof(Byte).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U2: return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt16).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U4: return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt32).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U8: return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt64).FullName), arg1, CastType.Cast);

                    case Code.Conv_Ovf_I_Un:  return new Ast.CastExpression(new Ast.TypeReference(typeof(int).FullName), arg1, CastType.Cast); // TODO
                    case Code.Conv_Ovf_I1_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(SByte).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_I2_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(Int16).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_I4_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(Int32).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_I8_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(Int64).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U_Un:  return new Ast.CastExpression(new Ast.TypeReference(typeof(uint).FullName), arg1, CastType.Cast); // TODO
                    case Code.Conv_Ovf_U1_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(Byte).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U2_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt16).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U4_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt32).FullName), arg1, CastType.Cast);
                    case Code.Conv_Ovf_U8_Un: return new Ast.CastExpression(new Ast.TypeReference(typeof(UInt64).FullName), arg1, CastType.Cast);
                #endregion
                #region Indirect
                    case Code.Ldind_I: throw new NotImplementedException();
                    case Code.Ldind_I1: throw new NotImplementedException();
                    case Code.Ldind_I2: throw new NotImplementedException();
                    case Code.Ldind_I4: throw new NotImplementedException();
                    case Code.Ldind_I8: throw new NotImplementedException();
                    case Code.Ldind_U1: throw new NotImplementedException();
                    case Code.Ldind_U2: throw new NotImplementedException();
                    case Code.Ldind_U4: throw new NotImplementedException();
                    case Code.Ldind_R4: throw new NotImplementedException();
                    case Code.Ldind_R8: throw new NotImplementedException();
                    case Code.Ldind_Ref: throw new NotImplementedException();

                    case Code.Stind_I: throw new NotImplementedException();
                    case Code.Stind_I1: throw new NotImplementedException();
                    case Code.Stind_I2: throw new NotImplementedException();
                    case Code.Stind_I4: throw new NotImplementedException();
                    case Code.Stind_I8: throw new NotImplementedException();
                    case Code.Stind_R4: throw new NotImplementedException();
                    case Code.Stind_R8: throw new NotImplementedException();
                    case Code.Stind_Ref: throw new NotImplementedException();
                #endregion
                case Code.Arglist: throw new NotImplementedException();
                case Code.Box: throw new NotImplementedException();
                case Code.Break: throw new NotImplementedException();
                case Code.Call:
                case Code.Callvirt:
                    // TODO: Diferentiate vitual and non-vitual dispach
                    Cecil.MethodReference cecilMethod = ((MethodReference)operand);
                    Ast.Expression target;
                    List<Ast.Expression> methodArgs = new List<Ast.Expression>(args);
                    if (cecilMethod.HasThis) {
                        target = methodArgs[0];
                        methodArgs.RemoveAt(0);
                    } else {
                        target = new Ast.IdentifierExpression(cecilMethod.DeclaringType.FullName);
                    }

                    // TODO: Constructors are ignored
                    if (cecilMethod.Name == ".ctor") {
                        return MakeComment("// Constructor");
                    }

                    // TODO: Hack, detect properties properly
                    if (cecilMethod.Name.StartsWith("get_")) {
                        return new Ast.MemberReferenceExpression(target, cecilMethod.Name.Remove(0, 4));
                    } else if (cecilMethod.Name.StartsWith("set_")) {
                        return new Ast.AssignmentExpression(
                            new Ast.MemberReferenceExpression(target, cecilMethod.Name.Remove(0, 4)),
                            AssignmentOperatorType.Assign,
                            methodArgs[0]
                        );
                    }

                    // Multi-dimensional array acces // TODO: do properly
                    if (cecilMethod.Name == "Get") {
                        return new Ast.IndexerExpression(target, methodArgs);
                    } else if (cecilMethod.Name == "Set") {
                        Expression val = methodArgs[methodArgs.Count - 1];
                        methodArgs.RemoveAt(methodArgs.Count - 1);
                        return new Ast.AssignmentExpression(
                            new Ast.IndexerExpression(target, methodArgs),
                            AssignmentOperatorType.Assign,
                            Convert(val, ((Cecil.ArrayType)target.UserData["Type"]).ElementType)
                        );
                    }

                    // Default invocation
                    return new Ast.InvocationExpression(
                        new Ast.MemberReferenceExpression(target, cecilMethod.Name),
                        methodArgs
                    );
                case Code.Calli: throw new NotImplementedException();
                case Code.Castclass: return new Ast.CastExpression(operandAsTypeRef, arg1, CastType.Cast);
                case Code.Ckfinite: throw new NotImplementedException();
                case Code.Constrained: throw new NotImplementedException();
                case Code.Cpblk: throw new NotImplementedException();
                case Code.Cpobj: throw new NotImplementedException();
                case Code.Dup: return arg1;
                case Code.Endfilter: throw new NotImplementedException();
                case Code.Endfinally: return null;
                case Code.Initblk: throw new NotImplementedException();
                case Code.Initobj: throw new NotImplementedException();
                case Code.Isinst: return new Ast.TypeOfIsExpression(arg1, new Ast.TypeReference(((Cecil.TypeReference)operand).FullName));
                case Code.Jmp: throw new NotImplementedException();
                case Code.Ldarg:
                    if (methodDef.HasThis && ((ParameterDefinition)operand).Index < 0) {
                        return new Ast.ThisReferenceExpression();
                    } else {
                        return new Ast.IdentifierExpression(((ParameterDefinition)operand).Name);
                    }
                case Code.Ldarga: throw new NotImplementedException();
                case Code.Ldc_I4:
                case Code.Ldc_I8:
                case Code.Ldc_R4:
                case Code.Ldc_R8: return new Ast.PrimitiveExpression(operand, null);
                case Code.Ldfld:
                case Code.Ldsfld: {
                    if (operand is FieldDefinition) {
                        FieldDefinition field = (FieldDefinition) operand;
                        if (field.IsStatic) {
                            return new Ast.MemberReferenceExpression(
                                new Ast.IdentifierExpression(field.DeclaringType.FullName),
                                field.Name
                            );
                        } else {
                            return new Ast.MemberReferenceExpression(arg1, field.Name);
                        }
                    } else {
                        // TODO: Static accesses
                        return new Ast.MemberReferenceExpression(arg1, ((FieldReference)operand).Name);
                    }
                }
                case Code.Stfld:
                case Code.Stsfld: {
                    FieldDefinition field = (FieldDefinition) operand;
                    if (field.IsStatic) {
                        return new AssignmentExpression(
                            new Ast.MemberReferenceExpression(
                                new Ast.IdentifierExpression(field.DeclaringType.FullName),
                                field.Name
                            ),
                            AssignmentOperatorType.Assign,
                            arg1
                        );
                    } else {
                        return new AssignmentExpression(
                            new Ast.MemberReferenceExpression(arg1, field.Name),
                            AssignmentOperatorType.Assign,
                            arg2
                        );
                    }
                }
                case Code.Ldflda:
                case Code.Ldsflda: throw new NotImplementedException();
                case Code.Ldftn: throw new NotImplementedException();
                case Code.Ldloc:
                    if (operand is ILStackVariable) {
                        return new Ast.IdentifierExpression(((ILStackVariable)operand).Name);
                    } else {
                        return new Ast.IdentifierExpression(((VariableDefinition)operand).Name);
                    }
                case Code.Ldloca: throw new NotImplementedException();
                case Code.Ldnull: return new Ast.PrimitiveExpression(null, null);
                case Code.Ldobj: throw new NotImplementedException();
                case Code.Ldstr: return new Ast.PrimitiveExpression(operand, null);
                case Code.Ldtoken:
                    if (operand is Cecil.TypeReference) {
                        return new Ast.MemberReferenceExpression(
                            new Ast.TypeOfExpression(operandAsTypeRef),
                            "TypeHandle"
                        );
                    } else {
                        throw new NotImplementedException();
                    }
                case Code.Ldvirtftn: throw new NotImplementedException();
                case Code.Leave: return null;
                case Code.Localloc: throw new NotImplementedException();
                case Code.Mkrefany: throw new NotImplementedException();
                case Code.Newobj:
                    Cecil.TypeReference declaringType = ((MethodReference)operand).DeclaringType;
                    // TODO: Ensure that the corrent overloaded constructor is called
                    if (declaringType is ArrayType) {
                        return new Ast.ArrayCreateExpression(
                            new Ast.TypeReference(((ArrayType)declaringType).ElementType.FullName, new int[] {}),
                            new List<Expression>(args)
                        );
                    }
                    return new Ast.ObjectCreateExpression(
                        new Ast.TypeReference(declaringType.FullName),
                        new List<Expression>(args)
                    );
                case Code.No: throw new NotImplementedException();
                case Code.Nop: return null;
                case Code.Or: throw new NotImplementedException();
                case Code.Pop: return arg1;
                case Code.Readonly: throw new NotImplementedException();
                case Code.Refanytype: throw new NotImplementedException();
                case Code.Refanyval: throw new NotImplementedException();
                case Code.Ret: {
                    if (methodDef.ReturnType.FullName != Constants.Void) {
                        arg1 = Convert(arg1, methodDef.ReturnType);
                        return new Ast.ReturnStatement(arg1);
                    } else {
                        return new Ast.ReturnStatement(null);
                    }
                }
                case Code.Rethrow: return new Ast.ThrowStatement(new IdentifierExpression("exception"));
                case Code.Sizeof: throw new NotImplementedException();
                case Code.Starg: throw new NotImplementedException();
                case Code.Stloc: {
                    if (operand is ILStackVariable) {
                        Ast.LocalVariableDeclaration astLocalVar = new Ast.LocalVariableDeclaration(new Ast.VariableDeclaration(((ILStackVariable)operand).Name, arg1));
                        astLocalVar.TypeReference = new Ast.TypeReference("var");
                        return astLocalVar;
                    }
                    VariableDefinition locVar = (VariableDefinition)operand;
                    string name = locVar.Name;
                    arg1 = Convert(arg1, locVar.VariableType);
                    if (localVarDefined.ContainsKey(name)) {
                        if (localVarDefined[name]) {
                            return new Ast.AssignmentExpression(new Ast.IdentifierExpression(name), AssignmentOperatorType.Assign, arg1);
                        } else {
                            Ast.LocalVariableDeclaration astLocalVar = new Ast.LocalVariableDeclaration(new Ast.VariableDeclaration(name, arg1));
                            astLocalVar.TypeReference = new Ast.TypeReference(localVarTypes[name].FullName);
                            localVarDefined[name] = true;
                            return astLocalVar;
                        }
                    } else {
                        return new Ast.AssignmentExpression(new Ast.IdentifierExpression(name), AssignmentOperatorType.Assign, arg1);
                    }
                }
                case Code.Stobj: throw new NotImplementedException();
                case Code.Switch: throw new NotImplementedException();
                case Code.Tail: throw new NotImplementedException();
                case Code.Throw: return new Ast.ThrowStatement(arg1);
                case Code.Unaligned: throw new NotImplementedException();
                case Code.Unbox: throw new NotImplementedException();
                case Code.Unbox_Any: throw new NotImplementedException();
                case Code.Volatile: throw new NotImplementedException();
                default: throw new Exception("Unknown OpCode: " + opCode);
            }
        }
 public object VisitGotoStatement(GotoStatement gotoStatement, object data)
 {
     throw new NotImplementedException ();
 }
Ejemplo n.º 18
0
		public virtual object VisitGotoStatement(GotoStatement gotoStatement, object data) {
			throw new global::System.NotImplementedException("GotoStatement");
		}
		public virtual object VisitGotoStatement(GotoStatement gotoStatement, object data) {
			Debug.Assert((gotoStatement != null));
			return null;
		}
		public sealed override object VisitGotoStatement(GotoStatement gotoStatement, object data) {
			this.BeginVisit(gotoStatement);
			object result = this.TrackedVisitGotoStatement(gotoStatement, data);
			this.EndVisit(gotoStatement);
			return result;
		}
Ejemplo n.º 21
0
 public virtual object VisitGotoStatement(GotoStatement gotoStatement, object data) {
     throw CreateException(gotoStatement);
 }
Ejemplo n.º 22
0
	void GotoStatement(
//#line  3458 "VBNET.ATG" 
out GotoStatement goToStatement) {

//#line  3459 "VBNET.ATG" 
		string label = String.Empty; Location startLocation = la.Location; 
		Expect(132);
		LabelName(
//#line  3461 "VBNET.ATG" 
out label);

//#line  3463 "VBNET.ATG" 
		goToStatement = new GotoStatement(label) {
		StartLocation = startLocation,
		EndLocation = t.EndLocation
		};
		
	}
Ejemplo n.º 23
0
            public override object VisitGotoStatement(GotoStatement gotoStatement, object data)
            {
                UnlockWith(gotoStatement);

                return base.VisitGotoStatement(gotoStatement, data);
            }