コード例 #1
0
        private GenericOperand RetrieveOperand()
        {
            GenericOperand      operand = stack.Peek().Item1.Item1;
            bool                byref   = stack.Peek().Item1.Item2;
            InstructionSelector parent  = stack.Peek().Item2;

            stack.Pop();

            if (parent != this)
            {
                if (byref)
                {
                    arguments.Add(operand);
                    return(operand);
                }
                else
                {
                    VirtualRegister argument = operand as VirtualRegister;
                    argument = new VirtualRegister(argument.UnderlyingType, argument.StateSpace);
                    parent.AddInitialization(operand, argument);
                    arguments.Add(argument);
                    return(argument);
                }
            }
            else
            {
                return(operand);
            }
        }
コード例 #2
0
            public CILBBImplementation(IList <Instruction> cilbbcode,
                                       Stack <Tuple <Tuple <GenericOperand, bool>, InstructionSelector> > stack,
                                       IList <FormalParameter> parameters,
                                       IList <VirtualRegister> variables,
                                       bool result,
                                       IList <SpecialRegister> srpool,
                                       IDictionary <MethodInfo, Subprogram> spmap,
                                       Func <Type, StateSpaces, InstructionSelector.DynamicRegister> regalloc)
            {
                Stack <Tuple <Tuple <GenericOperand, bool>, InstructionSelector> > temp =
                    new Stack <Tuple <Tuple <GenericOperand, bool>, InstructionSelector> >(stack.Reverse());

                selector     = new InstructionSelector(cilbbcode, stack, parameters, variables, result, srpool, spmap, regalloc);
                initializers = stack.Except(temp).Reverse().Select(se => se.Item1).ToArray();
                typeContext  = GetTypeContext(temp);
                stackStates.Add(temp);
            }
コード例 #3
0
 public void Simulate(Stack <Tuple <Tuple <GenericOperand, bool>, InstructionSelector> > stack)
 {
     if (TypeContextEqual(stack) && !Implements(stack))
     {
         stackStates.Add(new Stack <Tuple <Tuple <GenericOperand, bool>, InstructionSelector> >(stack.Reverse()));
         foreach (GenericOperand arg in selector.Arguments)
         {
             GenericOperand      operand = stack.Peek().Item1.Item1;
             bool                byref   = stack.Peek().Item1.Item2;
             InstructionSelector parent  = stack.Peek().Item2;
             if (!byref)
             {
                 parent.AddInitialization(operand, arg as VirtualRegister);
             }
             stack.Pop();
         }
         foreach (Tuple <GenericOperand, bool> init in initializers)
         {
             stack.Push(new Tuple <Tuple <GenericOperand, bool>, InstructionSelector>(init, selector));
         }
     }
 }