Exemplo n.º 1
0
        private bool IsPushOrPop(Chapter7.CommandType commandType)
        {
            var isPush = commandType == Chapter7.CommandType.C_PUSH;
            var isPop  = commandType == Chapter7.CommandType.C_POP;

            return(isPush || isPop);
        }
Exemplo n.º 2
0
        public void WritePushPop(Chapter7.CommandType commandType, string segment, int index)
        {
            results.Add("//" + Chapter7.Parser.debugcurrentCommand);

            System.Console.WriteLine(segment);
            switch (segment)
            {
            case "constant":
                PushPopConstant(commandType, index);
                return;

            case "local":
                PushPopLocal(commandType, index);
                return;

            case "argument":
                PushPopArgument(commandType, index);
                return;

            case "this":
                PushPopThis(commandType, index);
                return;

            case "that":
                PushPopThat(commandType, index);
                return;

            case "temp":
                PushPopTemp(commandType, index);
                return;

            case "pointer":
                PushPopPointer(commandType, index);
                return;

            case "static":
                PushPopStatic(commandType, index);
                return;

            default:
                throw new Exception("unexpected " + segment);
            }
        }