DeclareNamedVariable() private method

private DeclareNamedVariable ( ) : int
return int
Example #1
0
        // Compiles a method signature for an operator that can either be unary or
        // infix (i.e. "-").
        private static void MixedSignature(Compiler c, Signature signature)
        {
            signature.Type = SignatureType.Getter;

            // If there is a parameter, it's an infix operator, otherwise it's unary.
            if (c.Match(TokenType.LeftParen))
            {
                // Add the RHS parameter.
                signature.Type = SignatureType.Method;
                signature.Arity = 1;

                // Parse the parameter name.
                c.DeclareNamedVariable();
                c.Consume(TokenType.RightParen, "Expect ')' after parameter name.");
            }
        }
Example #2
0
        // Compiles a method signature for an operator that can either be unary or
        // infix (i.e. "-").
        private static void MixedSignature(Compiler c, Signature signature)
        {
            signature.Type = SignatureType.SIG_GETTER;

            // If there is a parameter, it's an infix operator, otherwise it's unary.
            if (c.Match(TokenType.TOKEN_LEFT_PAREN))
            {
                // Add the RHS parameter.
                signature.Type = SignatureType.SIG_METHOD;
                signature.Arity = 1;

                // Parse the parameter name.
                c.DeclareNamedVariable();
                c.Consume(TokenType.TOKEN_RIGHT_PAREN, "Expect ')' after parameter name.");
            }
        }
Example #3
0
        // Compiles a method signature for an infix operator.
        static void InfixSignature(Compiler c, Signature signature)
        {
            // Add the RHS parameter.
            signature.Type = SignatureType.Method;
            signature.Arity = 1;

            // Parse the parameter name.
            c.Consume(TokenType.LeftParen, "Expect '(' after operator name.");
            c.DeclareNamedVariable();
            c.Consume(TokenType.RightParen, "Expect ')' after parameter name.");
        }
Example #4
0
        // Compiles a method signature for an infix operator.
        static void InfixSignature(Compiler c, Signature signature)
        {
            // Add the RHS parameter.
            signature.Type = SignatureType.SIG_METHOD;
            signature.Arity = 1;

            // Parse the parameter name.
            c.Consume(TokenType.TOKEN_LEFT_PAREN, "Expect '(' after operator name.");
            c.DeclareNamedVariable();
            c.Consume(TokenType.TOKEN_RIGHT_PAREN, "Expect ')' after parameter name.");
        }