SignatureFromToken() private method

private SignatureFromToken ( Signature signature, SignatureType type ) : Signature
signature Signature
type SignatureType
return Signature
Esempio n. 1
0
        // Compiles a method signature for a constructor.
        private static void ConstructorSignature(Compiler c, Signature signature)
        {
            c.Consume(TokenType.Name, "Expect constructor name after 'construct'.");

            // Capture the name.
            signature = c.SignatureFromToken(signature, SignatureType.Initializer);

            if (c.Match(TokenType.Eq))
            {
                c.Error("A constructor cannot be a setter.");
            }

            if (!c.Match(TokenType.LeftParen))
            {
                c.Error("A constructor cannot be a getter.");
                return;
            }

            if (c.Match(TokenType.RightParen)) return;

            c.FinishParameterList(signature);
            c.Consume(TokenType.RightParen, "Expect ')' after parameters.");
        }
Esempio n. 2
0
        // Compiles a method signature for a constructor.
        private static void ConstructorSignature(Compiler c, Signature signature)
        {
            c.Consume(TokenType.TOKEN_NAME, "Expect constructor name after 'construct'.");

            // Capture the name.
            signature = c.SignatureFromToken(SignatureType.SIG_INITIALIZER);

            if (c.Match(TokenType.TOKEN_EQ))
            {
                c.Error("A constructor cannot be a setter.");
            }

            if (!c.Match(TokenType.TOKEN_LEFT_PAREN))
            {
                c.Error("A constructor cannot be a getter.");
                return;
            }

            if (c.Match(TokenType.TOKEN_RIGHT_PAREN)) return;

            c.FinishParameterList(signature);
            c.Consume(TokenType.TOKEN_RIGHT_PAREN, "Expect ')' after parameters.");
        }