Ejemplo n.º 1
0
        public DataType?VisitReturnInstruction(ReturnInstruction ret)
        {
            if (ret.Expression == null)
            {
                return(VoidType.Instance);
            }

            var dt = ret.Expression.Accept(this);

            if (!proc !.Signature.HasVoidReturn)
            {
                dt = handler.EqualTrait(proc.Signature.ReturnValue, ret.Expression);
            }
            return(dt);
        }
Ejemplo n.º 2
0
        private IEnumerable <NasmInstruction> CompileInstruction(int i, IInstruction instruction)
        {
            yield return(NasmInstruction.Comment(instruction.ToString()));

            yield return(NasmInstruction.Comment("In = { " + string.Join(", ", RegisterAllocation.GetAllInAt(i)) + " }"));

            foreach (var inst in instruction switch
            {
                UnaryComputationAssignment inst => CompileCore(inst),
                BinaryComputationAssignment inst => CompileCore(inst),
                ConditionalJump inst => CompileCore(inst),
                UnconditionalJump inst => CompileCore(inst),
                LabelInstruction inst => CompileCore(inst),
                CallInstruction inst => CompileCore(i, inst),
                ReturnInstruction inst => CompileCore(inst),
                ParameterQueryAssignment inst => CompileCore(inst),
                _ => throw new ArgumentException(nameof(instruction))
            })
Ejemplo n.º 3
0
 public override void VisitReturnInstruction(ReturnInstruction ret)
 {
     if (ret.Expression == null)
     {
         return;
     }
     ret.Expression.Accept(this);
     if (!signature.HasVoidReturn)
     {
         if (signature.ReturnValue.TypeVariable == null)
         {
             DebugEx.PrintIf(trace.TraceWarning, "Eqb: {0:X}: Type variable for return value of signature of {1} is missing", stmCur.LinearAddress, stmCur.Block.Procedure.Name);
             return;
         }
         store.MergeClasses(
             signature.ReturnValue.TypeVariable,
             ret.Expression.TypeVariable);
     }
 }
Ejemplo n.º 4
0
        public bool VisitReturnInstruction(ReturnInstruction ret)
        {
            var retPat = pattern as ReturnInstruction;

            if (retPat == null)
            {
                return(false);
            }
            if (retPat.Expression == null && ret.Expression == null)
            {
                return(true);
            }
            if (retPat.Expression == null || ret.Expression == null)
            {
                return(false);
            }
            matcher.Pattern = retPat.Expression;
            return(matcher.Match(ret.Expression));
        }
Ejemplo n.º 5
0
        public static Function operator +(Function f1, Function f2)
        {
            // Ajoute deux fonctions.
            // Ouais c'est possible :D*
            // TODO
            Function newFunc = new Function();

            Function[] funcs = new Function[] { f1, f2 };
            if (f1.PrimaryModifier != f2.PrimaryModifier)
            {
                throw new InterpreterException("Unable to add two functions with different primary modifiers");
            }
            newFunc.PrimaryModifier = f1.PrimaryModifier;
            foreach (Function f in funcs)
            {
                foreach (string argName in f.ArgumentNames)
                {
                    newFunc.ArgumentNames.Add(argName);
                }
                foreach (var kvp in f.EmbeddedVariables)
                {
                    if (!newFunc.EmbeddedVariables.ContainsKey(kvp.Key))
                    {
                        newFunc.EmbeddedVariables.Add(kvp.Key, kvp.Value);
                    }
                }
                f.Body.Context.GlobalContext = f1.Body.Context.GlobalContext;
            }
            newFunc.Body = new Block(f1.Body.Context.GlobalContext);
            ReturnInstruction ret = new ReturnInstruction();

            // Expression : f1(*args) + f2(*args2);
            ret.Expression = new PonyCarpetExtractor.ExpressionTree.ExpressionGroup();

            return(newFunc);
        }
Ejemplo n.º 6
0
 public override void VisitReturnInstruction(ReturnInstruction ret)
 {
     isCritical = true;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Génère le code pour une instruction return.
 /// </summary>
 /// <param name="instruction"></param>
 /// <returns></returns>
 string GenerateReturnInstruction(ReturnInstruction instruction)
 {
     return("return " + GenerateEvaluable(instruction.Value) + ";");
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Parse une intruction basique : appel de méthode ou affectation.
        /// La liste doit comprendre un seul jeton et pas de ;
        /// </summary>
        /// <returns></returns>
        static Instruction ParseInstruction(TokenList tokens, GlobalContext mainContext)
        {
            // Traitement spécial si return.
            if ((tokens.First().Type == TokenType.Statement))
            {
                if (tokens.Count == 2)
                {
                    InfoToken firstToken = (InfoToken)tokens[0];
                    switch (firstToken.Content)
                    {
                    case "return":
                        ReturnInstruction returnInst = new ReturnInstruction();
                        returnInst.Expression = ParseExpression(tokens[1], mainContext);
                        return(returnInst);

                    case "patchkey":
                        PatchkeyInstruction patchkeyInst = new PatchkeyInstruction();
                        patchkeyInst.Key = ((InfoToken)((OperandToken)tokens[1]).Tokens.First()).Content;
                        return(patchkeyInst);

                    default:
                        throw new Exception("Unexpected instruction");
                    }
                }
                else if (tokens.Count == 1)
                {
                    return(new ReturnInstruction());
                }
                else
                {
                    throw new Exception("Invalid 'return' expression");
                }
            }

            if (tokens.Count != 1)
            {
                // TODO : traiter les using, etc...
                throw new Exception("Unexpected token list");
            }
            Token token = tokens.First();

            // On commence les deux types d'instructions habituels.
            if (token.Type == TokenType.ExpressionGroup)
            {
                // OperandGroup + ";" : c'est une affectation, s'il n'y a pas de signe 'égal' dedans,
                // bah c'est rien du tout.
                ExpressionGroupToken   tok = (ExpressionGroupToken)token;
                AffectationInstruction ins = new AffectationInstruction();

                List <string> validTokens = new List <string>()
                {
                    "=", "+=", "-=",
                    "/=", "*="
                };

                // Si on a pas de "=", on a une expression.
                if (!validTokens.Contains(((InfoToken)tok.Operator).Content))
                {
                    throw new Exception("An expression can't be used as instruction");
                }

                ins.LeftMember = ParseSubExpression(((OperandToken)tok.Operand1).Tokens, mainContext);
                switch (((InfoToken)tok.Operator).Content)
                {
                case "=":
                    ins.RightMember = ParseExpression(tok.Operand2, mainContext);
                    break;

                case "+=":
                case "-=":
                case "/=":
                case "*=":
                    string   opString = ((InfoToken)tok.Operator).Content.Remove(1);
                    Operator op       = Operators.Mapping[opString];
                    ins.RightMember = new ExpressionGroup((IGettable)ins.LeftMember, op,
                                                          ParseExpression(tok.Operand2, mainContext));
                    break;

                default:
                    throw new Exception();
                }
                //ParseOperand((OperandToken)tok.Operand2);
                return(ins);
            }
            else if (token.Type == TokenType.OperandTokens)
            {
                TokenList internalTokens = ((TokenContainer)token).Tokens;
                Token     first          = internalTokens.First();

                // Instructions pré-faites.
                if (first.Type == TokenType.Noun)
                {
                    InfoToken itoken = (InfoToken)first;
                    switch (itoken.Content)
                    {
                    case "using":
                        if (internalTokens.Count != 2 || internalTokens[1].Type != TokenType.String)
                        {
                            throw new Exception("Invalid using instruction");
                        }
                        InfoToken itoken2 = (InfoToken)internalTokens[1];
                        mainContext.LoadedNamespaces.Add(itoken2.Content);
                        return(new UseNamespaceInstruction(itoken2.Content));

                    case "include":
                        if (internalTokens.Count != 2 || internalTokens[1].Type != TokenType.String)
                        {
                            throw new Exception("Invalid using instruction");
                        }
                        InfoToken itoken3 = (InfoToken)internalTokens[1];
                        mainContext.LoadedAssemblies.Add(itoken3.Content, Assembly.LoadWithPartialName(itoken3.Content));
                        return(new LoadAssemblyInstruction(itoken3.Content));
                    }
                }

                // C'est un appel de méthode.
                return(new MethodCallInstruction(ParseSubExpression(internalTokens, mainContext)));
            }
            throw new Exception("Uncorrect instruction");
        }
Ejemplo n.º 9
0
		public void Read(ref BlobReader reader)
		{
			this.ReadStart();

			while (reader.RemainingBytes > 0)
			{
				int offset = reader.Offset;

				ILOpCode opCode = reader.DecodeILOpCode();
				switch (opCode)
				{
					case ILOpCode.Nop:
						this.Read(NopInstruction.Nop(), offset);
						break;

					case ILOpCode.Ldarg_0:
						this.Read(LoadArgumentInstruction.FromIndex(0), offset);
						break;
					case ILOpCode.Ldarg_1:
						this.Read(LoadArgumentInstruction.FromIndex(1), offset);
						break;

					case ILOpCode.Ldloc_0:
						this.Read(LoadLocalInstruction.FromIndex(0), offset);
						break;
					case ILOpCode.Ldloc_1:
						this.Read(LoadLocalInstruction.FromIndex(1), offset);
						break;

					case ILOpCode.Ldloca_s:
						this.Read(LoadLocalAddressInstruction.FromIndex(reader.ReadSByte()), offset);
						break;

					case ILOpCode.Stloc_0:
						this.Read(StoreLocalInstruction.ToIndex(0), offset);
						break;
					case ILOpCode.Stloc_1:
						this.Read(StoreLocalInstruction.ToIndex(1), offset);
						break;

					case ILOpCode.Ldc_i4_0:
						this.Read(PushInt32Instruction.Constant(0), offset);
						break;
					case ILOpCode.Ldc_i4_1:
						this.Read(PushInt32Instruction.Constant(1), offset);
						break;
					case ILOpCode.Ldc_i4_2:
						this.Read(PushInt32Instruction.Constant(2), offset);
						break;
					case ILOpCode.Ldc_i4_3:
						this.Read(PushInt32Instruction.Constant(3), offset);
						break;
					case ILOpCode.Ldc_i4_s:
						this.Read(PushInt32Instruction.Constant(reader.ReadSByte()), offset);
						break;

					case ILOpCode.Ldc_i4:
						this.Read(PushInt32Instruction.Constant(reader.ReadInt32()), offset);
						break;
					case ILOpCode.Ldc_i8:
						this.Read(PushInt64Instruction.Constant(reader.ReadInt64()), offset);
						break;

					case ILOpCode.Br_s:
						this.Read(BranchInstruction.ILIndex(reader.ReadSByte() + reader.Offset), offset);
						break;
					case ILOpCode.Bgt_s:
						this.Read(BranchGreaterInstruction.ILIndex(reader.ReadSByte() + reader.Offset), offset);
						break;
					case ILOpCode.Brfalse_s:
						this.Read(BranchFalseInstruction.ILIndex(reader.ReadSByte() + reader.Offset), offset);
						break;

					case ILOpCode.Call:
						this.Read(CallInstruction.Handle(reader.ReadInt32()), offset);
						break;

					case ILOpCode.Pop:
						this.Read(PopInstruction.Pop(), offset);
						break;
					case ILOpCode.Ret:
						this.Read(ReturnInstruction.Return(), offset);
						break;

					case ILOpCode.Add:
						this.Read(AddInstruction.Add(), offset);
						break;
					case ILOpCode.Sub:
						this.Read(SubtractInstruction.Subtract(), offset);
						break;

					case ILOpCode.Initobj:
						this.Read(InitObjectInstruction.Handle(reader.ReadInt32()), offset);
						break;

					case ILOpCode.Ldfld:
						this.Read(LoadFieldValueInstruction.Handle(reader.ReadInt32()), offset);
						break;

					case ILOpCode.Stfld:
						this.Read(SaveFieldValueInstruction.Handle(reader.ReadInt32()), offset);
						break;

					default:
						throw new NotSupportedException("Opcode: " + opCode);
				}
			}

			this.ReadEnd();
		}
Ejemplo n.º 10
0
 void InstructionVisitor.VisitReturnInstruction(ReturnInstruction ret)
 {
     stms.Add(new AbsynReturn(ret.Expression));
 }
Ejemplo n.º 11
0
 public AbsynStatement VisitReturnInstruction(ReturnInstruction ret)
 {
     return(new AbsynReturn(ret.Expression));
 }
Ejemplo n.º 12
0
 public virtual void VisitReturnInstruction(ReturnInstruction instruction)
 {
     DefaultVisitInstruction(instruction);
 }
Ejemplo n.º 13
0
		public void VisitReturnInstruction(ReturnInstruction ret)
		{
			writer.Indent();
			writer.WriteKeyword("return");
			if (ret.Expression != null)
			{
				writer.Write(" ");
				WriteExpression(ret.Expression);
			}
			writer.Terminate();
		}
Ejemplo n.º 14
0
 public void VisitReturn(ReturnInstruction instruction) => IncrementCallCount(nameof(VisitReturn));
Ejemplo n.º 15
0
 public virtual void Visit(ReturnInstruction instruction)
 {
 }
Ejemplo n.º 16
0
 public override void VisitReturnInstruction(ReturnInstruction ret)
 {
     if (ret.Expression == null)
         return;
     ret.Expression.Accept(this);
     if (signature.ReturnValue != null)
     {
         store.MergeClasses(
             signature.ReturnValue.TypeVariable,
             ret.Expression.TypeVariable);
     }
 }
Ejemplo n.º 17
0
 public virtual void Visit(ReturnInstruction instruction)
 {
     Default(instruction);
 }
Ejemplo n.º 18
0
 static ReturnInstruction()
 {
     Singleton = new ReturnInstruction();
 }
Ejemplo n.º 19
0
 public void VisitReturnInstruction(ReturnInstruction ret)
 {
     d.VisitReturnInstruction(ret);
 }
Ejemplo n.º 20
0
 protected abstract void VisitReturnInstruction(ReturnInstruction instruction);
Ejemplo n.º 21
0
 public Instruction VisitReturnInstruction(ReturnInstruction r)
 {
     return(se.VisitReturnInstruction(r));
 }
Ejemplo n.º 22
0
		public override void VisitReturnInstruction(ReturnInstruction ret)
		{
			isCritical = true;
		}
Ejemplo n.º 23
0
 public AbsynStatement VisitReturnInstruction(ReturnInstruction ret)
 {
     regType = RegionType.Tail;
     return(new AbsynReturn(ret.Expression));
 }
Ejemplo n.º 24
0
 public override void Visit(ReturnInstruction instruction)
 {
     Copy(instruction.Operand, this.rangeAnalysis.ReturnVariable);
 }
Ejemplo n.º 25
0
 public BitRange VisitReturnInstruction(ReturnInstruction ret)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 26
0
        public override CILInstructionNone BuildNode(ParseTreeNode node)
        {
            var instrNoneParseTreeNode = node.GetFirstChildWithGrammarName(GrammarNames.INSTR_NONE);

            var addParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_add);

            if (addParseTreeNode != null)
            {
                var addInstruction = new AddInstruction();
                return(addInstruction);
            }

            var andParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_and);

            if (andParseTreeNode != null)
            {
                var andInstruction = new AndInstruction();
                return(andInstruction);
            }

            var ceqParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ceq);

            if (ceqParseTreeNode != null)
            {
                var checkIfEqualInstruction = new CheckIfEqualInstruction();
                return(checkIfEqualInstruction);
            }

            var cgtParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_cgt);

            if (cgtParseTreeNode != null)
            {
                var checkIfGreaterInstruction = new CheckIfGreaterInstruction();
                return(checkIfGreaterInstruction);
            }

            var cltParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_clt);

            if (cltParseTreeNode != null)
            {
                var checkIfLessInstruction = new CheckIfLessInstruction();
                return(checkIfLessInstruction);
            }

            var convi1ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convi1);

            if (convi1ParseTreeNode != null)
            {
                var convertToSByteInstruction = new ConvertToSByteInstruction();
                return(convertToSByteInstruction);
            }

            var convi2ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convi2);

            if (convi2ParseTreeNode != null)
            {
                var convertToShortInstruction = new ConvertToShortInstruction();
                return(convertToShortInstruction);
            }

            var convi4ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convi4);

            if (convi4ParseTreeNode != null)
            {
                var convertToIntInstruction = new ConvertToIntInstruction();
                return(convertToIntInstruction);
            }

            var convi8ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convi8);

            if (convi8ParseTreeNode != null)
            {
                var convertToLongInstruction = new ConvertToLongInstruction();
                return(convertToLongInstruction);
            }

            var convr4ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convr4);

            if (convr4ParseTreeNode != null)
            {
                var convertToFloatInstruction = new ConvertToFloatInstruction();
                return(convertToFloatInstruction);
            }

            var convr8ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convr8);

            if (convr8ParseTreeNode != null)
            {
                var convertToDoubleInstruction = new ConvertToDoubleInstruction();
                return(convertToDoubleInstruction);
            }

            var convu8ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_convu8);

            if (convu8ParseTreeNode != null)
            {
                var convertToUnsignedLongInstruction = new ConvertToUnsignedLongInstruction();
                return(convertToUnsignedLongInstruction);
            }

            var divParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_div);

            if (divParseTreeNode != null)
            {
                var divideInstruction = new DivideInstruction();
                return(divideInstruction);
            }

            var dupParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_dup);

            if (dupParseTreeNode != null)
            {
                var duplicateInstruction = new DuplicateInstruction();
                return(duplicateInstruction);
            }

            var ldarg0ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldarg0);

            if (ldarg0ParseTreeNode != null)
            {
                var loadArgument0Instruction = new LoadArgument0Instruction();
                return(loadArgument0Instruction);
            }

            var ldarg1ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldarg1);

            if (ldarg1ParseTreeNode != null)
            {
                var loadArgument1Instruction = new LoadArgument1Instruction();
                return(loadArgument1Instruction);
            }

            var ldarg2ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldarg2);

            if (ldarg2ParseTreeNode != null)
            {
                var loadArgument2Instruction = new LoadArgument2Instruction();
                return(loadArgument2Instruction);
            }

            var ldarg3ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldarg3);

            if (ldarg3ParseTreeNode != null)
            {
                var loadArgument3Instruction = new LoadArgument3Instruction();
                return(loadArgument3Instruction);
            }

            var ldci40ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci40);

            if (ldci40ParseTreeNode != null)
            {
                var loadConstantInt0Instruction = new LoadConstantInt0Instruction();
                return(loadConstantInt0Instruction);
            }

            var ldci41ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci41);

            if (ldci41ParseTreeNode != null)
            {
                var loadConstantInt1Instruction = new LoadConstantInt1Instruction();
                return(loadConstantInt1Instruction);
            }

            var ldci42ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci42);

            if (ldci42ParseTreeNode != null)
            {
                var loadConstantInt2Instruction = new LoadConstantInt2Instruction();
                return(loadConstantInt2Instruction);
            }

            var ldci43ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci43);

            if (ldci43ParseTreeNode != null)
            {
                var loadConstantInt3Instruction = new LoadConstantInt3Instruction();
                return(loadConstantInt3Instruction);
            }

            var ldci44ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci44);

            if (ldci44ParseTreeNode != null)
            {
                var loadConstantInt4Instruction = new LoadConstantInt4Instruction();
                return(loadConstantInt4Instruction);
            }

            var ldci45ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci45);

            if (ldci45ParseTreeNode != null)
            {
                var loadConstantInt5Instruction = new LoadConstantInt5Instruction();
                return(loadConstantInt5Instruction);
            }

            var ldci46ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci46);

            if (ldci46ParseTreeNode != null)
            {
                var loadConstantInt6Instruction = new LoadConstantInt6Instruction();
                return(loadConstantInt6Instruction);
            }

            var ldci47ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci47);

            if (ldci47ParseTreeNode != null)
            {
                var loadConstantInt7Instruction = new LoadConstantInt7Instruction();
                return(loadConstantInt7Instruction);
            }

            var ldci48ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci48);

            if (ldci48ParseTreeNode != null)
            {
                var loadConstantInt8Instruction = new LoadConstantInt8Instruction();
                return(loadConstantInt8Instruction);
            }

            var ldci4m1ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldci4m1);

            if (ldci4m1ParseTreeNode != null)
            {
                var loadConstantIntMinus1Instruction = new LoadConstantIntMinus1Instruction();
                return(loadConstantIntMinus1Instruction);
            }

            var ldelemi4ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldelemi4);

            if (ldelemi4ParseTreeNode != null)
            {
                var loadElementIntInstruction = new LoadElementIntInstruction();
                return(loadElementIntInstruction);
            }

            var ldelemrefParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldelemref);

            if (ldelemrefParseTreeNode != null)
            {
                var loadElementRefInstruction = new LoadElementRefInstruction();
                return(loadElementRefInstruction);
            }

            var ldlenParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldlen);

            if (ldlenParseTreeNode != null)
            {
                var loadLengthInstruction = new LoadLengthInstruction();
                return(loadLengthInstruction);
            }

            var ldloc0ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldloc0);

            if (ldloc0ParseTreeNode != null)
            {
                var loadLocalVariable0Instruction = new LoadLocalVariable0Instruction();
                return(loadLocalVariable0Instruction);
            }

            var ldloc1ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldloc1);

            if (ldloc1ParseTreeNode != null)
            {
                var loadLocalVariable1Instruction = new LoadLocalVariable1Instruction();
                return(loadLocalVariable1Instruction);
            }

            var ldloc2ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldloc2);

            if (ldloc2ParseTreeNode != null)
            {
                var loadLocalVariable2Instruction = new LoadLocalVariable2Instruction();
                return(loadLocalVariable2Instruction);
            }

            var ldloc3ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ldloc3);

            if (ldloc3ParseTreeNode != null)
            {
                var loadLocalVariable3Instruction = new LoadLocalVariable3Instruction();
                return(loadLocalVariable3Instruction);
            }

            var mulParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_mul);

            if (mulParseTreeNode != null)
            {
                var multiplyInstruction = new MultiplyInstruction();
                return(multiplyInstruction);
            }

            var notParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_not);

            if (notParseTreeNode != null)
            {
                var notInstruction = new NotInstruction();
                return(notInstruction);
            }

            var orParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_or);

            if (orParseTreeNode != null)
            {
                var orInstruction = new OrInstruction();
                return(orInstruction);
            }

            var popParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_pop);

            if (popParseTreeNode != null)
            {
                var popInstruction = new PopInstruction();
                return(popInstruction);
            }

            var remParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_rem);

            if (remParseTreeNode != null)
            {
                var remainderInstruction = new RemainderInstruction();
                return(remainderInstruction);
            }

            var retParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_ret);

            if (retParseTreeNode != null)
            {
                var returnInstruction = new ReturnInstruction();
                return(returnInstruction);
            }

            var shlParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_shl);

            if (shlParseTreeNode != null)
            {
                var shiftLeftInstruction = new ShiftLeftInstruction();
                return(shiftLeftInstruction);
            }

            var shrParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_shr);

            if (shrParseTreeNode != null)
            {
                var shiftRightInstruction = new ShiftRightInstruction();
                return(shiftRightInstruction);
            }

            var stelemi4ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_stelemi4);

            if (stelemi4ParseTreeNode != null)
            {
                var setElementIntInstruction = new SetElementIntInstruction();
                return(setElementIntInstruction);
            }

            var stelemrefParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_stelemref);

            if (stelemrefParseTreeNode != null)
            {
                var setElementRefInstruction = new SetElementRefInstruction();
                return(setElementRefInstruction);
            }

            var stloc0ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_stloc0);

            if (stloc0ParseTreeNode != null)
            {
                var setLocalVariable0Instruction = new SetLocalVariable0Instruction();
                return(setLocalVariable0Instruction);
            }

            var stloc1ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_stloc1);

            if (stloc1ParseTreeNode != null)
            {
                var setLocalVariable1Instruction = new SetLocalVariable1Instruction();
                return(setLocalVariable1Instruction);
            }

            var stloc2ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_stloc2);

            if (stloc2ParseTreeNode != null)
            {
                var setLocalVariable2Instruction = new SetLocalVariable2Instruction();
                return(setLocalVariable2Instruction);
            }

            var stloc3ParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_stloc3);

            if (stloc3ParseTreeNode != null)
            {
                var setLocalVariable3Instruction = new SetLocalVariable3Instruction();
                return(setLocalVariable3Instruction);
            }

            var subParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_sub);

            if (subParseTreeNode != null)
            {
                var subtractInstruction = new SubtractInstruction();
                return(subtractInstruction);
            }

            var xorParseTreeNode = instrNoneParseTreeNode?.GetFirstChildWithGrammarName(GrammarNames.keyword_xor);

            if (xorParseTreeNode != null)
            {
                var xorInstruction = new XorInstruction();
                return(xorInstruction);
            }

            throw new ArgumentException("Cannot recognize CIL instruction none.");
        }
Ejemplo n.º 27
0
        public Instruction VisitReturnInstruction(ReturnInstruction ret)
        {
            var exp = ret.Expression != null?ret.Expression.Accept(this) : null;

            return(new ReturnInstruction(exp));
        }
Ejemplo n.º 28
0
 void InstructionVisitor.VisitReturnInstruction(ReturnInstruction ret)
 {
     stms.Add(new AbsynReturn(ret.Expression));
 }
Ejemplo n.º 29
0
		public virtual void VisitReturnInstruction(ReturnInstruction ret)
		{
			if (ret.Expression != null)
				ret.Expression.Accept(this);
		}
Ejemplo n.º 30
0
 public void VisitReturnInstruction(ReturnInstruction ret)
 {
     if (ret.Expression != null)
     {
         var dt = ret.Expression.Accept(asc);
         desc.MeetDataType(ret.Expression, dt);
         ret.Expression.Accept(desc, ret.Expression.TypeVariable);
     }
 }