Пример #1
0
        private void ProcessSubroutineCall(Queue <NodeBase> children, Identifier identifier)
        {
            string call;
            Token  token = GetSymbol(children.Dequeue());

            if (token.Value == ".")
            {
                var classMemberIdentifier = GetIdentifier(children.Dequeue());
                call  = $"{(identifier.ClassType != null ? identifier.ClassType : identifier.Value)}.{classMemberIdentifier.Value}";
                token = GetSymbol(children.Dequeue());
            }
            else
            {
                call = $"{className}.{identifier.Value}";
            }
            int argumentCount = 0;

            if (identifier.Kind != IdentifierKind.Class)
            {
                vmWriter.Push(identifier);
                argumentCount++;
            }
            Expect(token, NodeType.Symbol, "(");
            argumentCount += ProcessExpressionList(children.Dequeue());
            Expect(children.Dequeue(), NodeType.Symbol, ")");
            vmWriter.Call(call, argumentCount);
        }