ext/include/iv/ast-factory.h in iv-phonic-0.0.3 vs ext/include/iv/ast-factory.h in iv-phonic-0.0.5
- old
+ new
@@ -10,14 +10,14 @@
namespace iv {
namespace core {
namespace ast {
-template<std::size_t N, typename Factory>
-class BasicAstFactory : public Space<N> {
+template<typename Factory>
+class BasicAstFactory {
public:
- typedef BasicAstFactory<N, Factory> this_type;
+ 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;
@@ -26,12 +26,11 @@
#define V(S) typedef typename SpaceUString<Factory>::type S;
AST_STRING(V)
#undef V
BasicAstFactory()
- : Space<N>(),
- undefined_instance_(
+ : undefined_instance_(
new(static_cast<Factory*>(this))Undefined()),
empty_statement_instance_(
new(static_cast<Factory*>(this))EmptyStatement()),
debugger_statement_instance_(
new(static_cast<Factory*>(this))DebuggerStatement()),
@@ -88,12 +87,18 @@
ObjectLiteral* NewObjectLiteral() {
return new (static_cast<Factory*>(this))
ObjectLiteral(static_cast<Factory*>(this));
}
+ template<typename T>
+ T** NewPtr() {
+ return new (static_cast<Factory*>(this)->New(sizeof(T*))) T*(NULL);
+ }
+
Identifiers* NewLabels() {
- return new (Space<N>::New(sizeof(Identifiers)))
+ void* place = static_cast<Factory*>(this)->New(sizeof(Identifiers));
+ return new (place)
Identifiers(
typename Identifiers::allocator_type(static_cast<Factory*>(this)));
}
NullLiteral* NewNullLiteral() {
@@ -124,9 +129,13 @@
return false_instance_;
}
FunctionStatement* NewFunctionStatement(FunctionLiteral* func) {
return new (static_cast<Factory*>(this)) FunctionStatement(func);
+ }
+
+ FunctionDeclaration* NewFunctionDeclaration(FunctionLiteral* func) {
+ return new (static_cast<Factory*>(this)) FunctionDeclaration(func);
}
Block* NewBlock() {
return new (static_cast<Factory*>(this)) Block(static_cast<Factory*>(this));
}