ext/include/iv/ast_factory.h in iv-phonic-0.1.5 vs ext/include/iv/ast_factory.h in iv-phonic-0.1.6

- old
+ new

@@ -18,21 +18,19 @@ typedef BasicAstFactory<Factory> this_type; #define V(AST) typedef typename ast::AST<Factory> AST; AST_NODE_LIST(V) #undef V -#define V(X, XS) typedef typename SpaceVector<Factory, X*>::type XS; +#define V(XS) typedef typename ast::AstNode<Factory>::XS XS; AST_LIST_LIST(V) #undef V #define V(S) typedef typename SpaceUString<Factory>::type S; AST_STRING(V) #undef V BasicAstFactory() - : undefined_instance_( - new(static_cast<Factory*>(this))Undefined()), - empty_statement_instance_( + : empty_statement_instance_( new(static_cast<Factory*>(this))EmptyStatement()), debugger_statement_instance_( new(static_cast<Factory*>(this))DebuggerStatement()), this_instance_( new(static_cast<Factory*>(this))ThisLiteral()), @@ -86,11 +84,11 @@ return new (static_cast<Factory*>(this)) RegExpLiteral(content, flags, static_cast<Factory*>(this)); } FunctionLiteral* NewFunctionLiteral(typename FunctionLiteral::DeclType type, - Identifier* name, + Maybe<Identifier> name, Identifiers* params, Statements* body, Scope* scope, bool strict, std::size_t begin_block_position, @@ -106,11 +104,11 @@ strict, begin_block_position, end_block_position); } - ArrayLiteral* NewArrayLiteral(Expressions* items, + ArrayLiteral* NewArrayLiteral(MaybeExpressions* items, std::size_t begin, std::size_t end) { return new (static_cast<Factory*>(this)) ArrayLiteral(items); } ObjectLiteral* @@ -144,14 +142,10 @@ ThisLiteral* NewThisLiteral(std::size_t begin, std::size_t end) { return this_instance_; } - Undefined* NewUndefined() { - return undefined_instance_; - } - TrueLiteral* NewTrueLiteral(std::size_t begin, std::size_t end) { return true_instance_; } FalseLiteral* NewFalseLiteral(std::size_t begin, std::size_t end) { @@ -190,19 +184,19 @@ VariableStatement(token, decls); } // if you want begin / end position, // set position to Identifier / Expression and use it - Declaration* NewDeclaration(Identifier* name, Expression* expr) { + Declaration* NewDeclaration(Identifier* name, Maybe<Expression> expr) { return new (static_cast<Factory*>(this)) Declaration(name, expr); } // if you want end position, // set position to Statement and use it IfStatement* NewIfStatement(Expression* cond, Statement* then_statement, - Statement* else_statement, + Maybe<Statement> else_statement, std::size_t begin) { return new (static_cast<Factory*>(this)) IfStatement(cond, then_statement, else_statement); } @@ -233,37 +227,37 @@ } // if you want end position, // set position to Statement and use it ForStatement* NewForStatement(Statement* body, - Statement* init, - Expression* cond, - Statement* next, + Maybe<Statement> init, + Maybe<Expression> cond, + Maybe<Statement> next, std::size_t begin) { return new (static_cast<Factory*>(this)) ForStatement(body, init, cond, next); } ExpressionStatement* NewExpressionStatement(Expression* expr, std::size_t end) { return new (static_cast<Factory*>(this)) ExpressionStatement(expr); } - ContinueStatement* NewContinueStatement(Identifier* label, + ContinueStatement* NewContinueStatement(Maybe<Identifier> label, IterationStatement** target, std::size_t begin, std::size_t end) { return new (static_cast<Factory*>(this)) ContinueStatement(label, target); } - BreakStatement* NewBreakStatement(Identifier* label, + BreakStatement* NewBreakStatement(Maybe<Identifier> label, BreakableStatement** target, std::size_t begin, std::size_t end) { return new (static_cast<Factory*>(this)) BreakStatement(label, target); } - ReturnStatement* NewReturnStatement(Expression* expr, + ReturnStatement* NewReturnStatement(Maybe<Expression> expr, std::size_t begin, std::size_t end) { return new (static_cast<Factory*>(this)) ReturnStatement(expr); } @@ -279,11 +273,11 @@ return new (static_cast<Factory*>(this)) SwitchStatement(expr, clauses); } // !!! if body is empty, end_position is end. CaseClause* NewCaseClause(bool is_default, - Expression* expr, Statements* body, + Maybe<Expression> expr, Statements* body, std::size_t begin, std::size_t end) { return new (static_cast<Factory*>(this)) CaseClause(is_default, expr, body); } @@ -293,13 +287,13 @@ } // if you want end position, // set position to Block and use it TryStatement* NewTryStatement(Block* try_block, - Identifier* catch_name, - Block* catch_block, - Block* finally_block, + Maybe<Identifier> catch_name, + Maybe<Block> catch_block, + Maybe<Block> finally_block, std::size_t begin) { return new (static_cast<Factory*>(this)) TryStatement(try_block, catch_name, catch_block, finally_block); @@ -378,10 +372,9 @@ Identifier* ident) { return new (static_cast<Factory*>(this)) IdentifierAccess(expr, ident); } private: - Undefined* undefined_instance_; EmptyStatement* empty_statement_instance_; DebuggerStatement* debugger_statement_instance_; ThisLiteral* this_instance_; NullLiteral* null_instance_; TrueLiteral* true_instance_;