summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-07-02 10:56:45 -0400
committerAdrian Thurston <thurston@complang.org>2012-07-02 10:56:45 -0400
commit5bc746ffabed73350a4e39d5eb3473b8a53b930a (patch)
tree3ea18c0b8bf4100a20123ed373ac331d4b11f86b
parent4aa97741c466dd8946ee9206c12afa7743fc7615 (diff)
downloadcolm-5bc746ffabed73350a4e39d5eb3473b8a53b930a.tar.gz
more static member constructors
-rw-r--r--src/lmparse.kl76
-rw-r--r--src/parsetree.h310
-rw-r--r--src/synthesis.cc4
3 files changed, 236 insertions, 154 deletions
diff --git a/src/lmparse.kl b/src/lmparse.kl
index 3a3b8013..16c7b656 100644
--- a/src/lmparse.kl
+++ b/src/lmparse.kl
@@ -1483,8 +1483,8 @@ require_pattern:
patternItemList, pd->nextPatReplId++ );
pd->patternList.append( pattern );
- $$->expr = new LangExpr(
- new LangTerm( LangTerm::MatchType, $2->varRef, pattern ) );
+ $$->expr = LangExpr::cons(
+ LangTerm::cons( LangTerm::MatchType, $2->varRef, pattern ) );
};
nonterm block_or_single uses lang_stmt_list;
@@ -1506,11 +1506,11 @@ nonterm iter_call
iter_call: var_ref '(' opt_code_expr_list ')'
final {
- $$->langTerm = new LangTerm( $1->varRef, $3->exprVect );
+ $$->langTerm = LangTerm::cons( $1->varRef, $3->exprVect );
};
iter_call: TK_Word
final {
- $$->langTerm = new LangTerm( LangTerm::VarRefType,
+ $$->langTerm = LangTerm::cons( LangTerm::VarRefType,
new LangVarRef( $1->loc, new QualItemVect, $1->data ) );
};
@@ -1679,12 +1679,12 @@ nonterm code_expr
code_expr: code_expr TK_AmpAmp code_relational
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, OP_LogicalAnd, $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, OP_LogicalAnd, $3->expr );
};
code_expr: code_expr TK_BarBar code_relational
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, OP_LogicalOr, $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, OP_LogicalOr, $3->expr );
};
code_expr: code_relational
@@ -1696,32 +1696,32 @@ nonterm code_relational uses code_expr;
code_relational: code_relational TK_DoubleEql code_additive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, OP_DoubleEql, $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, OP_DoubleEql, $3->expr );
};
code_relational: code_relational TK_NotEql code_additive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, OP_NotEql, $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, OP_NotEql, $3->expr );
};
code_relational: code_relational '<' code_additive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, '<', $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, '<', $3->expr );
};
code_relational: code_relational '>' code_additive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, '>', $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, '>', $3->expr );
};
code_relational: code_relational TK_LessEql code_additive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, OP_LessEql, $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, OP_LessEql, $3->expr );
};
code_relational: code_relational TK_GrtrEql code_additive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, OP_GrtrEql, $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, OP_GrtrEql, $3->expr );
};
@@ -1734,12 +1734,12 @@ nonterm code_additive uses code_expr;
code_additive: code_additive '+' code_multiplicitive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, '+', $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, '+', $3->expr );
};
code_additive: code_additive '-' code_multiplicitive
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, '-', $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, '-', $3->expr );
};
code_additive: code_multiplicitive
@@ -1751,12 +1751,12 @@ nonterm code_multiplicitive uses code_expr;
code_multiplicitive: code_multiplicitive '*' code_unary
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, '*', $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, '*', $3->expr );
};
code_multiplicitive: code_multiplicitive '/' code_unary
final {
- $$->expr = new LangExpr( $2->loc, $1->expr, '/', $3->expr );
+ $$->expr = LangExpr::cons( $2->loc, $1->expr, '/', $3->expr );
};
code_multiplicitive: code_unary
@@ -1767,19 +1767,19 @@ code_multiplicitive: code_unary
nonterm code_unary uses code_expr;
code_unary: '!' code_factor
final {
- $$->expr = new LangExpr( $1->loc, '!', $2->expr );
+ $$->expr = LangExpr::cons( $1->loc, '!', $2->expr );
};
code_unary: '$' code_factor
final {
- $$->expr = new LangExpr( $1->loc, '$', $2->expr );
+ $$->expr = LangExpr::cons( $1->loc, '$', $2->expr );
};
code_unary: '^' code_factor
final {
- $$->expr = new LangExpr( $1->loc, '^', $2->expr );
+ $$->expr = LangExpr::cons( $1->loc, '^', $2->expr );
};
code_unary: '%' code_factor
final {
- $$->expr = new LangExpr( $1->loc, '%', $2->expr );
+ $$->expr = LangExpr::cons( $1->loc, '%', $2->expr );
};
code_unary: code_factor
final {
@@ -1801,19 +1801,19 @@ nonterm code_factor uses code_expr;
code_factor: TK_Number
final {
- $$->expr = new LangExpr( new LangTerm( LangTerm::NumberType, $1->data ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( LangTerm::NumberType, $1->data ) );
};
code_factor: TK_Literal
final {
- $$->expr = new LangExpr( new LangTerm( LangTerm::StringType, $1->data ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( LangTerm::StringType, $1->data ) );
};
code_factor: var_ref '(' opt_code_expr_list ')'
final {
- $$->expr = new LangExpr( new LangTerm( $1->varRef, $3->exprVect ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->varRef, $3->exprVect ) );
};
code_factor: var_ref
final {
- $$->expr = new LangExpr( new LangTerm( LangTerm::VarRefType, $1->varRef ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( LangTerm::VarRefType, $1->varRef ) );
};
code_factor: KW_Match var_ref pattern_list
final {
@@ -1823,11 +1823,11 @@ code_factor: KW_Match var_ref pattern_list
patternItemList, pd->nextPatReplId++ );
pd->patternList.append( pattern );
- $$->expr = new LangExpr( new LangTerm( LangTerm::MatchType, $2->varRef, pattern ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( LangTerm::MatchType, $2->varRef, pattern ) );
};
code_factor: KW_New code_factor
final {
- $$->expr = new LangExpr( new LangTerm( LangTerm::NewType, $2->expr ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( LangTerm::NewType, $2->expr ) );
};
code_factor:
KW_Construct opt_capture type_ref opt_field_init repl_list
@@ -1842,7 +1842,7 @@ code_factor:
if ( $2->objField != 0 )
varRef = new LangVarRef( $2->objField->loc, new QualItemVect, $2->objField->name );
- $$->expr = new LangExpr( new LangTerm( $1->loc, LangTerm::ConstructType,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc, LangTerm::ConstructType,
varRef, $2->objField, $3->typeRef, $4->fieldInitVect, replacement ) );
/* Check for redeclaration. */
@@ -1879,7 +1879,7 @@ code_factor: KW_Parse opt_capture type_ref '(' opt_code_expr_list ')'
if ( $2->objField != 0 )
varRef = new LangVarRef( $2->objField->loc, new QualItemVect, $2->objField->name );
- $$->expr = new LangExpr( new LangTerm( $1->loc, LangTerm::ParseType,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc, LangTerm::ParseType,
varRef, $2->objField, $3->typeRef, generic, parserTypeRef, replacement ) );
$$->expr->term->args = $5->exprVect;
@@ -1918,7 +1918,7 @@ code_factor: KW_ParseStop opt_capture type_ref '(' opt_code_expr_list ')'
if ( $2->objField != 0 )
varRef = new LangVarRef( $2->objField->loc, new QualItemVect, $2->objField->name );
- $$->expr = new LangExpr( new LangTerm( $1->loc, LangTerm::ParseStopType,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc, LangTerm::ParseStopType,
varRef, $2->objField, $3->typeRef, generic, parserTypeRef, replacement ) );
$$->expr->term->args = $5->exprVect;
@@ -1937,27 +1937,27 @@ code_factor: KW_ParseStop opt_capture type_ref '(' opt_code_expr_list ')'
};
code_factor: KW_TypeId '<' type_ref '>'
final {
- $$->expr = new LangExpr( new LangTerm( $1->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc,
LangTerm::TypeIdType, $3->typeRef ) );
};
code_factor: type_ref KW_In var_ref
final {
- $$->expr = new LangExpr( new LangTerm( $2->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $2->loc,
LangTerm::SearchType, $1->typeRef, $3->varRef ) );
};
code_factor: KW_Nil
final {
- $$->expr = new LangExpr( new LangTerm( $1->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc,
LangTerm::NilType ) );
};
code_factor: KW_True
final {
- $$->expr = new LangExpr( new LangTerm( $1->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc,
LangTerm::TrueType ) );
};
code_factor: KW_False
final {
- $$->expr = new LangExpr( new LangTerm( $1->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc,
LangTerm::FalseType ) );
};
code_factor: '(' code_expr ')'
@@ -1966,21 +1966,21 @@ code_factor: '(' code_expr ')'
};
code_factor: KW_MakeTree '(' opt_code_expr_list ')'
final {
- $$->expr = new LangExpr( new LangTerm( $1->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc,
LangTerm::MakeTreeType, $3->exprVect ) );
};
code_factor: KW_MakeToken '(' opt_code_expr_list ')'
final {
- $$->expr = new LangExpr( new LangTerm( $1->loc,
+ $$->expr = LangExpr::cons( LangTerm::cons( $1->loc,
LangTerm::MakeTokenType, $3->exprVect ) );
};
code_factor: KW_Deref code_expr
final {
- $$->expr = new LangExpr( $1->loc, OP_Deref, $2->expr );
+ $$->expr = LangExpr::cons( $1->loc, OP_Deref, $2->expr );
};
code_factor: string_list
final {
- $$->expr = new LangExpr( new LangTerm( replItemList ) );
+ $$->expr = LangExpr::cons( LangTerm::cons( replItemList ) );
};
nonterm opt_field_init uses field_init_list;
diff --git a/src/parsetree.h b/src/parsetree.h
index 96f96fdf..45bc5b13 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -1714,6 +1714,21 @@ struct TypeRef
Ptr,
};
+ TypeRef()
+ :
+ type((Type)-1),
+ nspaceQual(0),
+ pdaLiteral(0),
+ iterDef(0),
+ typeRef1(0),
+ typeRef2(0),
+ repeatType((RepeatType)-1),
+ nspace(0),
+ uniqueType(0),
+ searchUniqueType(0),
+ generic(0)
+ {}
+
/* Qualification and a type name. These require lookup. */
static TypeRef *cons( const InputLoc &loc, NamespaceQual *nspaceQual, String typeName )
{
@@ -1722,15 +1737,7 @@ struct TypeRef
t->loc = (loc);
t->nspaceQual = (nspaceQual);
t->typeName = (typeName);
- t->pdaLiteral = (0);
- t->iterDef = (0);
- t->typeRef1 = (0);
- t->typeRef2 = (0);
t->repeatType = (RepeatNone);
- t->nspace = (0);
- t->uniqueType = (0);
- t->searchUniqueType = (0);
- t->generic = (0);
return t;
}
@@ -1742,14 +1749,7 @@ struct TypeRef
t->loc = (loc);
t->nspaceQual = (nspaceQual);
t->pdaLiteral = (pdaLiteral);
- t->iterDef = (0);
- t->typeRef1 = (0);
- t->typeRef2 = (0);
t->repeatType = (RepeatNone);
- t->nspace = (0);
- t->uniqueType = (0);
- t->searchUniqueType = (0);
- t->generic = (0);
return t;
}
@@ -1760,15 +1760,9 @@ struct TypeRef
t->type = (type);
t->loc = (loc);
t->nspaceQual = (nspaceQual);
- t->pdaLiteral = (0);
- t->iterDef = (0);
t->typeRef1 = (typeRef1);
t->typeRef2 = (typeRef2);
t->repeatType = (RepeatNone);
- t->nspace = (0);
- t->uniqueType = (0);
- t->searchUniqueType = (0);
- t->generic = (0);
return t;
}
@@ -1778,16 +1772,8 @@ struct TypeRef
TypeRef *t = new TypeRef;
t->type = (type);
t->loc = (loc);
- t->nspaceQual = (0);
- t->pdaLiteral = (0);
- t->iterDef = (0);
t->typeRef1 = (typeRef1);
- t->typeRef2 = (0);
t->repeatType = (RepeatNone);
- t->nspace = (0);
- t->uniqueType = (0);
- t->searchUniqueType = (0);
- t->generic = (0);
return t;
}
@@ -1800,16 +1786,10 @@ struct TypeRef
TypeRef *t = new TypeRef;
t->type = (Iterator);
t->loc = (loc);
- t->nspaceQual = (0);
- t->pdaLiteral = (0);
t->iterDef = (iterDef);
- t->typeRef1 = (0);
- t->typeRef2 = (0);
t->repeatType = (RepeatNone);
- t->nspace = (0);
t->uniqueType = (uniqueType);
t->searchUniqueType = (searchUniqueType);
- t->generic = (0);
return t;
}
@@ -1819,16 +1799,8 @@ struct TypeRef
TypeRef *t = new TypeRef;
t->type = (Unspecified);
t->loc = (loc);
- t->nspaceQual = (0);
- t->pdaLiteral = (0);
- t->iterDef = (0);
- t->typeRef1 = (0);
- t->typeRef2 = (0);
t->repeatType = (RepeatNone);
- t->nspace = (0);
t->uniqueType = (uniqueType);
- t->searchUniqueType = (0);
- t->generic = (0);
return t;
}
@@ -2184,58 +2156,156 @@ struct LangTerm
EmbedStringType
};
- LangTerm( Type type, LangVarRef *varRef )
- : type(type), varRef(varRef) {}
+ static LangTerm *cons( Type type, LangVarRef *varRef )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (type);
+ t->varRef = (varRef);
+ return t;
+ }
- LangTerm( LangVarRef *varRef, ExprVect *args )
- : type(MethodCallType), varRef(varRef), args(args) {}
+ static LangTerm *cons( LangVarRef *varRef, ExprVect *args )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (MethodCallType);
+ t->varRef = (varRef);
+ t->args = (args);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, ExprVect *args )
- : loc(loc), type(type), args(args) {}
+ static LangTerm *cons( const InputLoc &loc, Type type, ExprVect *args )
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->args = (args);
+ return t;
+ }
- LangTerm( Type type, String data )
- : type(type), varRef(0), data(data) {}
+ static LangTerm *cons( Type type, String data )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (type);
+ t->varRef = (0);
+ t->data = (data);
+ return t;
+ }
- LangTerm( Type type, NamespaceQual *nspaceQual, const String &data )
- : type(type), varRef(0), nspaceQual(nspaceQual), data(data) {}
+ static LangTerm *cons( Type type, NamespaceQual *nspaceQual, const String &data )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (type);
+ t->varRef = (0);
+ t->nspaceQual = (nspaceQual);
+ t->data = (data);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type )
- : loc(loc), type(type), varRef(0), typeRef(0) {}
+ static LangTerm *cons( const InputLoc &loc, Type type )
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->varRef = (0);
+ t->typeRef = (0);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, TypeRef *typeRef )
- : loc(loc), type(type), varRef(0), typeRef(typeRef) {}
+ static LangTerm *cons( const InputLoc &loc, Type type, TypeRef *typeRef )
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->varRef = (0);
+ t->typeRef = (typeRef);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, LangVarRef *varRef )
- : loc(loc), type(type), varRef(varRef) {}
+ static LangTerm *cons( const InputLoc &loc, Type type, LangVarRef *varRef )
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->varRef = (varRef);
+ return t;
+ }
- LangTerm( Type type, LangVarRef *varRef, Pattern *pattern )
- : type(type), varRef(varRef), pattern(pattern) {}
+ static LangTerm *cons( Type type, LangVarRef *varRef, Pattern *pattern )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (type);
+ t->varRef = (varRef);
+ t->pattern = (pattern);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, TypeRef *typeRef, LangVarRef *varRef )
- : loc(loc), type(type), varRef(varRef), typeRef(typeRef) {}
+ static LangTerm *cons( const InputLoc &loc, Type type, TypeRef *typeRef, LangVarRef *varRef )
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->varRef = (varRef);
+ t->typeRef = (typeRef);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, TypeRef *typeRef, FieldInitVect *fieldInitArgs,
+ static LangTerm *cons( const InputLoc &loc, Type type, TypeRef *typeRef, FieldInitVect *fieldInitArgs,
Replacement *replacement )
- : loc(loc), type(type), typeRef(typeRef), fieldInitArgs(fieldInitArgs),
- replacement(replacement) {}
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->typeRef = (typeRef);
+ t->fieldInitArgs = (fieldInitArgs);
+ t->replacement = (replacement);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, LangVarRef *varRef, ObjField *objField,
+ static LangTerm *cons( const InputLoc &loc, Type type, LangVarRef *varRef, ObjField *objField,
TypeRef *typeRef, FieldInitVect *fieldInitArgs, Replacement *replacement )
- : loc(loc), type(type), varRef(varRef), objField(objField), typeRef(typeRef),
- fieldInitArgs(fieldInitArgs), replacement(replacement) {}
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->varRef = (varRef);
+ t->objField = (objField);
+ t->typeRef = (typeRef);
+ t->fieldInitArgs = (fieldInitArgs);
+ t->replacement = (replacement);
+ return t;
+ }
- LangTerm( Type type, LangExpr *expr )
- : type(type), expr(expr) {}
+ static LangTerm *cons( Type type, LangExpr *expr )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (type);
+ t->expr = (expr);
+ return t;
+ }
- LangTerm( ReplItemList *replItemList )
- : type(EmbedStringType), replItemList(replItemList) {}
+ static LangTerm *cons( ReplItemList *replItemList )
+ {
+ LangTerm *t = new LangTerm;
+ t->type = (EmbedStringType);
+ t->replItemList = (replItemList);
+ return t;
+ }
- LangTerm( const InputLoc &loc, Type type, LangVarRef *varRef,
+ static LangTerm *cons( const InputLoc &loc, Type type, LangVarRef *varRef,
ObjField *objField, TypeRef *typeRef, GenericType *generic, TypeRef *parserTypeRef,
Replacement *replacement )
- : loc(loc), type(type), varRef(varRef), objField(objField),
- typeRef(typeRef), generic(generic), parserTypeRef(parserTypeRef),
- replacement(replacement) {}
+ {
+ LangTerm *t = new LangTerm;
+ t->loc = (loc);
+ t->type = (type);
+ t->varRef = (varRef);
+ t->objField = (objField);
+ t->typeRef = (typeRef);
+ t->generic = (generic);
+ t->parserTypeRef = (parserTypeRef);
+ t->replacement = (replacement);
+ return t;
+ }
void resolve( Compiler *pd );
@@ -2274,14 +2344,35 @@ struct LangExpr
TermType
};
- LangExpr( const InputLoc &loc, LangExpr *left, char op, LangExpr *right )
- : loc(loc), type(BinaryType), left(left), op(op), right(right) {}
+ static LangExpr *cons( const InputLoc &loc, LangExpr *left, char op, LangExpr *right )
+ {
+ LangExpr *e = new LangExpr;
+ e->loc = (loc);
+ e->type = (BinaryType);
+ e->left = (left);
+ e->op = (op);
+ e->right = (right);
+ return e;
+ }
- LangExpr( const InputLoc &loc, char op, LangExpr *right )
- : loc(loc), type(UnaryType), left(0), op(op), right(right) {}
+ static LangExpr *cons( const InputLoc &loc, char op, LangExpr *right )
+ {
+ LangExpr *e = new LangExpr;
+ e->loc = (loc);
+ e->type = (UnaryType);
+ e->left = (0);
+ e->op = (op);
+ e->right =(right);
+ return e;
+ }
- LangExpr( LangTerm *term )
- : type(TermType), term(term) {}
+ static LangExpr *cons( LangTerm *term )
+ {
+ LangExpr *e = new LangExpr;
+ e->type = (TermType);
+ e->term = (term);
+ return e;
+ }
void resolve( Compiler *pd ) const;
@@ -2318,15 +2409,34 @@ struct LangStmt
ParserType
};
+ LangStmt()
+ :
+ type((Type)-1),
+ varRef(0),
+ langTerm(0),
+ objField(0),
+ typeRef(0),
+ expr(0),
+ replacement(0),
+ parserText(0),
+ exprPtrVect(0),
+ fieldInitVect(0),
+ stmtList(0),
+ elsePart(0),
+
+ /* Normally you don't need to initialize double list pointers, however,
+ * we make use of the next pointer for returning a pair of statements
+ * using one pointer to a LangStmt, so we need to initialize it above. */
+ prev(0),
+ next(0)
+ {}
+
static LangStmt *cons( const InputLoc &loc, Type type, FieldInitVect *fieldInitVect )
{
LangStmt *s = new LangStmt;
s->loc = (loc);
s->type = (type);
- s->varRef = (0);
- s->expr = (0);
s->fieldInitVect = (fieldInitVect);
- s->next = (0);
return s;
}
@@ -2335,10 +2445,7 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->loc = (loc);
s->type = (type);
- s->varRef = (0);
- s->expr = (0);
s->exprPtrVect = (exprPtrVect);
- s->next = (0);
return s;
}
@@ -2347,10 +2454,7 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->loc = (loc);
s->type = (type);
- s->varRef = (0);
s->expr = (expr);
- s->exprPtrVect = (0);
- s->next = (0);
return s;
}
@@ -2359,9 +2463,6 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->type = (type);
s->varRef = (varRef);
- s->expr = (0);
- s->exprPtrVect = (0);
- s->next = (0);
return s;
}
@@ -2370,11 +2471,7 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->loc = (loc);
s->type = (type);
- s->varRef = (0);
s->objField = (objField);
- s->expr = (0);
- s->exprPtrVect = (0);
- s->next = (0);
return s;
}
@@ -2385,8 +2482,6 @@ struct LangStmt
s->type = (type);
s->varRef = (varRef);
s->expr = (expr);
- s->exprPtrVect = (0);
- s->next = (0);
return s;
}
@@ -2396,7 +2491,6 @@ struct LangStmt
s->type = (type);
s->expr = (expr);
s->stmtList = (stmtList);
- s->next = (0);
return s;
}
@@ -2405,7 +2499,6 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->type = (type);
s->stmtList = (stmtList);
- s->next = (0);
return s;
}
@@ -2416,7 +2509,6 @@ struct LangStmt
s->expr = (expr);
s->stmtList = (stmtList);
s->elsePart = (elsePart);
- s->next = (0);
return s;
}
@@ -2425,7 +2517,6 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->loc = (loc);
s->type = (type);
- s->next = (0);
return s;
}
@@ -2434,10 +2525,7 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->type = (type);
s->varRef = (varRef);
- s->expr = (0);
s->replacement = (replacement);
- s->exprPtrVect = (0);
- s->next = (0);
return s;
}
@@ -2446,14 +2534,10 @@ struct LangStmt
LangStmt *s = new LangStmt;
s->type = (type);
s->varRef = (varRef);
- s->expr = (0);
s->parserText = (parserText);
- s->exprPtrVect = (0);
- s->next = (0);
return s;
}
- /* ForIterType */
static LangStmt *cons( const InputLoc &loc, Type type, ObjField *objField,
TypeRef *typeRef, LangTerm *langTerm, StmtList *stmtList )
{
@@ -2464,7 +2548,6 @@ struct LangStmt
s->objField = (objField);
s->typeRef = (typeRef);
s->stmtList = (stmtList);
- s->next = (0);
return s;
}
@@ -2472,7 +2555,6 @@ struct LangStmt
{
LangStmt *s = new LangStmt;
s->type = (type);
- s->next = (0);
return s;
}
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 47f2ba71..15918e58 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -1934,11 +1934,11 @@ LangTerm *LangStmt::chooseDefaultIter( Compiler *pd, LangTerm *fromVarRef ) cons
/* The parameters. */
ExprVect *callExprVect = new ExprVect;
- LangExpr *callExpr = new LangExpr( new LangTerm(
+ LangExpr *callExpr = LangExpr::cons( LangTerm::cons(
LangTerm::VarRefType, fromVarRef->varRef ) );
callExprVect->append( callExpr );
- LangTerm *callLangTerm = new LangTerm( callVarRef, callExprVect );
+ LangTerm *callLangTerm = LangTerm::cons( callVarRef, callExprVect );
return callLangTerm;
}