ext/include/iv/ast-factory.h in iv-phonic-0.0.1 vs ext/include/iv/ast-factory.h in iv-phonic-0.0.2

- old
+ new

@@ -1,9 +1,10 @@ #ifndef _IV_AST_FACTORY_H_ #define _IV_AST_FACTORY_H_ #include <tr1/type_traits> #include "functor.h" +#include "location.h" #include "ast.h" #include "alloc.h" #include "static_assert.h" #include "ustringpiece.h" @@ -46,25 +47,16 @@ typedef std::tr1::is_base_of<this_type, Factory> is_base_of_factory; IV_STATIC_ASSERT(is_convertible_to_this::value || is_base_of_factory::value); } - Identifier* NewIdentifier(const UStringPiece& buffer) { + template<typename Range> + Identifier* NewIdentifier(const Range& range) { return new (static_cast<Factory*>(this)) - Identifier(buffer, static_cast<Factory*>(this)); + Identifier(range, static_cast<Factory*>(this)); } - Identifier* NewIdentifier(const std::vector<uc16>& buffer) { - return new (static_cast<Factory*>(this)) - Identifier(buffer, static_cast<Factory*>(this)); - } - - Identifier* NewIdentifier(const std::vector<char>& buffer) { - return new (static_cast<Factory*>(this)) - Identifier(buffer, static_cast<Factory*>(this)); - } - NumberLiteral* NewNumberLiteral(const double& val) { return new (static_cast<Factory*>(this)) NumberLiteral(val); } StringLiteral* NewStringLiteral(const std::vector<uc16>& buffer) { @@ -147,41 +139,55 @@ Declaration* NewDeclaration(Identifier* name, Expression* expr) { return new (static_cast<Factory*>(this)) Declaration(name, expr); } - IfStatement* NewIfStatement(Expression* cond, Statement* then) { - return new (static_cast<Factory*>(this)) IfStatement(cond, then); + IfStatement* NewIfStatement(Expression* cond, + Statement* then_statement, + Statement* else_statement) { + return new (static_cast<Factory*>(this)) IfStatement(cond, + then_statement, + else_statement); } - DoWhileStatement* NewDoWhileStatement() { - return new (static_cast<Factory*>(this)) DoWhileStatement(); + DoWhileStatement* NewDoWhileStatement(Statement* body, + Expression* cond) { + return new (static_cast<Factory*>(this)) DoWhileStatement(body, cond); } - WhileStatement* NewWhileStatement(Expression* expr) { - return new (static_cast<Factory*>(this)) WhileStatement(expr); + WhileStatement* NewWhileStatement(Statement* body, + Expression* cond) { + return new (static_cast<Factory*>(this)) WhileStatement(body, cond); } - ForInStatement* NewForInStatement(Statement* each, + ForInStatement* NewForInStatement(Statement* body, + Statement* each, Expression* enumerable) { - return new (static_cast<Factory*>(this)) ForInStatement(each, enumerable); + return new (static_cast<Factory*>(this)) ForInStatement(body, + each, enumerable); } ExpressionStatement* NewExpressionStatement(Expression* expr) { return new (static_cast<Factory*>(this)) ExpressionStatement(expr); } - ForStatement* NewForStatement() { - return new (static_cast<Factory*>(this)) ForStatement(); + ForStatement* NewForStatement(Statement* body, + Statement* init, + Expression* cond, + Statement* next) { + return new (static_cast<Factory*>(this)) ForStatement(body, init, + cond, next); } - ContinueStatement* NewContinueStatement() { - return new (static_cast<Factory*>(this)) ContinueStatement(); + ContinueStatement* NewContinueStatement(Identifier* label, + IterationStatement** target) { + return new (static_cast<Factory*>(this)) ContinueStatement(label, target); } - BreakStatement* NewBreakStatement() { - return new (static_cast<Factory*>(this)) BreakStatement(); + BreakStatement* NewBreakStatement(Identifier* label, + BreakableStatement** target) { + return new (static_cast<Factory*>(this)) BreakStatement(label, target); } ReturnStatement* NewReturnStatement( Expression* expr) { return new (static_cast<Factory*>(this)) ReturnStatement(expr); @@ -195,20 +201,26 @@ SwitchStatement* NewSwitchStatement(Expression* expr) { return new (static_cast<Factory*>(this)) SwitchStatement(expr, static_cast<Factory*>(this)); } - CaseClause* NewCaseClause() { + CaseClause* NewCaseClause(bool is_default, Expression* expr) { return new (static_cast<Factory*>(this)) - CaseClause(static_cast<Factory*>(this)); + CaseClause(is_default, expr, static_cast<Factory*>(this)); } ThrowStatement* NewThrowStatement(Expression* expr) { return new (static_cast<Factory*>(this)) ThrowStatement(expr); } - TryStatement* NewTryStatement(Block* block) { - return new (static_cast<Factory*>(this)) TryStatement(block); + TryStatement* NewTryStatement(Block* try_block, + Identifier* catch_name, + Block* catch_block, + Block* finally_block) { + return new (static_cast<Factory*>(this)) TryStatement(try_block, + catch_name, + catch_block, + finally_block); } LabelledStatement* NewLabelledStatement( Expression* expr, Statement* stmt) {