Example #1
0
        protected override void ToFenxe(FenxeNode fenxe, string register, IDictionary <IdentifierNode, uint> anaxDictionary)
        {
            if (register != "f0")
            {
                this.writer.WriteLine("nta 4 f5 krz f0 f5@");
            }

            int count = ((fenxe.Arguments?.Count ?? 0) + 1) * 4;

            this.writer.WriteLine("nta {0} f5 ; allocate arguments stack", count);

            int argCount = count;

            foreach (var arg in fenxe.Arguments)
            {
                count -= 4;
                OutputExpression(arg, "f0", anaxDictionary);
                this.writer.WriteLine("krz f0 f5+{0}@ ; push argument", count);
            }

            this.writer.WriteLine("inj {0} xx f5@ ata {1} f5", fenxe.Name.Value, count);
            if (register != "f0")
            {
                this.writer.WriteLine("krz f0 {0} krz f5@ f0 ata 4 f5", register);
            }
        }
Example #2
0
        private ExpressionNode GetFenxe(Identifier identifier, IList <Token> tokens, ref int index)
        {
            var fenxe = new FenxeNode
            {
                Name = new IdentifierNode
                {
                    Value = (identifier as Identifier).Name,
                },
                Arguments = new List <ExpressionNode>(),
            };

            Token token = tokens[++index];

            if (token.Type != TokenType.L_CIRC)
            {
                throw new ApplicationException($"Not found '(': fenxe {fenxe.Name.Value}");
            }

            int count = tokens.Count;

            token = tokens[++index];
            while (index < count && token.Type != TokenType.R_CIRC)
            {
                ExpressionNode expression = GetCompareNode(tokens, ref index);

                if (expression != null)
                {
                    fenxe.Arguments.Add(expression);
                }
                else
                {
                    throw new ApplicationException($"Invalid token: {token}");
                }

                token = tokens[index];

                if (token.Type == TokenType.R_CIRC)
                {
                    break;
                }
                else if (token.Type == TokenType.COMMA)
                {
                    index++;
                }
                else
                {
                    throw new ApplicationException($"Invalid token: {token}");
                }
            }

            if (token.Type != TokenType.R_CIRC)
            {
                throw new ApplicationException($"Not found ')': fenxe {fenxe.Name.Value}");
            }

            return(fenxe);
        }
Example #3
0
 protected abstract void ToFenxe(FenxeNode fenxe, string register, IDictionary <IdentifierNode, uint> anaxDictionary);