diff -r bbf9f3809d55 -r e718b56aba78 src/AST.h --- a/src/AST.h Sun Aug 12 20:51:31 2012 -0700 +++ b/src/AST.h Sat Sep 01 16:36:20 2012 -0700 @@ -47,6 +47,7 @@ _(WhileStatement) \ _(BreakStatement) \ _(ContinueStatement) \ + _(FunctionTypeStatement) \ _(IncDecExpression) \ _(UnaryExpression) \ _(TernaryExpression) \ @@ -743,25 +744,72 @@ typedef PoolList ParameterList; +class FunctionSignature +{ + public: + FunctionSignature(BoundName *returnType, ParameterList *parameters) + : returnType_(returnType), + parameters_(parameters) + { + } + + BoundName *returnType() const { + return returnType_; + } + ParameterList *parameters() const { + return parameters_; + } + + private: + BoundName *returnType_; + ParameterList *parameters_; +}; + +class FunctionTypeStatement : public Statement +{ + public: + FunctionTypeStatement(const SourcePosition &pos, NamedType *type, const FunctionSignature &signature) + : Statement(pos), + type_(type), + signature_(signature) + { + } + + Kind kind() const { + return kFunctionTypeStatement; + } + NamedType *decl() const { + return type_; + } + const FunctionSignature &signature() const { + return signature_; + } + void accept(AstVisitor *visitor) { + visitor->visit(this); + } + + private: + NamedType *type_; + FunctionSignature signature_; +}; + class FunctionStatement : public Statement { Scope *scope_; NamedFunction *fun_; Statement *body_; - ParameterList *parameters_; + FunctionSignature signature_; bool explicitReturn_; - BoundName *returnType_; public: FunctionStatement(const SourcePosition &pos, Scope *scope, NamedFunction *fun, Statement *body, - ParameterList *parameters, BoundName *returnType, bool explicitReturn) + const FunctionSignature &signature, bool explicitReturn) : Statement(pos), scope_(scope), fun_(fun), body_(body), - parameters_(parameters), - explicitReturn_(explicitReturn), - returnType_(returnType) + signature_(signature), + explicitReturn_(explicitReturn) { } @@ -777,8 +825,8 @@ Statement *body() const { return body_; } - ParameterList *parameters() const { - return parameters_; + const FunctionSignature &signature() { + return signature_; } void accept(AstVisitor *visitor) { visitor->visit(this); @@ -786,9 +834,6 @@ bool hasExplicitReturn() const { return explicitReturn_; } - BoundName *returnType() const { - return returnType_; - } }; class IfStatement : public Statement