Ejemplo n.º 1
0
        public override void Do(ICommandContext context)
        {
            BaseType valueToPush = null;

            switch (AccessMode)
            {
                case ValueAccessModes.Constant:
                    valueToPush = value;
                    break;
                case ValueAccessModes.LocalVariable:
                case ValueAccessModes.LocalVariableReference:
                    valueToPush = context.GetVariable(name);
                    break;
                case ValueAccessModes.Register:
                case ValueAccessModes.RegisterByReference:
                    if (registryIndex >= 0)
                    {
                        valueToPush = context.Registry[registryIndex];
                    }
                    else
                    {
                        valueToPush = context.Registry[registerName];
                    }
                    break;
            }

            if (AccessMode == ValueAccessModes.Constant || AccessMode == ValueAccessModes.Register)
            {
                valueToPush = valueToPush.Dereference().Clone();
                //valueToPush.Delete();
            }
            // To revise: this code snippet has no effect on the tests.
            else if (AccessMode == ValueAccessModes.LocalVariableReference || AccessMode == ValueAccessModes.RegisterByReference)
            {
                valueToPush = valueToPush.ToReference();
            }
            //else
            //{
            //    valueToPush = valueToPush.Clone();
            //}

            if (valueToPush == null)
            {
                throw new Exceptions.InvalidOperationException("Cannot push a null.");
            }

            context.RunStack.Push(valueToPush);
        }