Пример #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 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));
         }
     }
 }