summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2012-07-02 09:49:51 -0400
committerAdrian Thurston <thurston@complang.org>2012-07-02 09:49:51 -0400
commit061b9cc63c351d6462dddccc5021360384266959 (patch)
tree8b63ebc7fe78926b143e3601f02d3a868a715c3e
parenta6a74ea14ef45682a4fdf665084c0b977902c379 (diff)
downloadcolm-061b9cc63c351d6462dddccc5021360384266959.tar.gz
using static member functions for TypeRef construction
-rw-r--r--src/compiler.cc12
-rw-r--r--src/declare.cc2
-rw-r--r--src/lmparse.kl40
-rw-r--r--src/parsetree.h136
-rw-r--r--src/pdabuild.cc2
-rw-r--r--src/synthesis.cc28
6 files changed, 146 insertions, 74 deletions
diff --git a/src/compiler.cc b/src/compiler.cc
index 057373b8..e5cdfbb1 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1081,11 +1081,11 @@ LangEl *Compiler::makeRepeatProd( Namespace *nspace, const String &repeatName,
ProdElList *prodElList1 = new ProdElList;
/* Build the first production of the repeat. */
- TypeRef *typeRef1 = new TypeRef( InputLoc(), nspaceQual, name );
+ TypeRef *typeRef1 = TypeRef::cons( InputLoc(), nspaceQual, name );
ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef1, 0 );
UniqueType *prodNameUT = findUniqueType( TYPE_TREE, prodName );
- TypeRef *typeRef2 = new TypeRef( InputLoc(), prodNameUT );
+ TypeRef *typeRef2 = TypeRef::cons( InputLoc(), prodNameUT );
ProdEl *factor2 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef2, 0 );
prodElList1->append( factor1 );
@@ -1119,11 +1119,11 @@ LangEl *Compiler::makeListProd( Namespace *nspace, const String &listName, Names
prodName->isList = true;
/* Build the first production of the list. */
- TypeRef *typeRef1 = new TypeRef( InputLoc(), nspaceQual, name );
+ TypeRef *typeRef1 = TypeRef::cons( InputLoc(), nspaceQual, name );
ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef1, 0 );
UniqueType *prodNameUT = findUniqueType( TYPE_TREE, prodName );
- TypeRef *typeRef2 = new TypeRef( InputLoc(), prodNameUT );
+ TypeRef *typeRef2 = TypeRef::cons( InputLoc(), prodNameUT );
ProdEl *factor2 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef2, 0 );
ProdElList *prodElList1 = new ProdElList;
@@ -1139,7 +1139,7 @@ LangEl *Compiler::makeListProd( Namespace *nspace, const String &listName, Names
prodList.append( newDef1 );
/* Build the second production of the list. */
- TypeRef *typeRef3 = new TypeRef( InputLoc(), nspaceQual, name );
+ TypeRef *typeRef3 = TypeRef::cons( InputLoc(), nspaceQual, name );
ProdEl *factor3 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef3, 0 );
ProdElList *prodElList2 = new ProdElList;
@@ -1164,7 +1164,7 @@ LangEl *Compiler::makeOptProd( Namespace *nspace, const String &optName, Namespa
ProdElList *prodElList1 = new ProdElList;
/* Build the first production of the repeat. */
- TypeRef *typeRef1 = new TypeRef( InputLoc(), nspaceQual, name );
+ TypeRef *typeRef1 = TypeRef::cons( InputLoc(), nspaceQual, name );
ProdEl *factor1 = new ProdEl( ProdEl::ReferenceType, InputLoc(), 0, false, typeRef1, 0 );
prodElList1->append( factor1 );
diff --git a/src/declare.cc b/src/declare.cc
index 167fe050..342ffd65 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -110,7 +110,7 @@ void Compiler::declareBaseLangEls()
void Compiler::addProdRedObjectVar( ObjectDef *localFrame, LangEl *nonTerm )
{
UniqueType *prodNameUT = findUniqueType( TYPE_TREE, nonTerm );
- TypeRef *typeRef = new TypeRef( InputLoc(), prodNameUT );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), prodNameUT );
ObjField *el = new ObjField( InputLoc(), typeRef, "lhs" );
el->isLhsEl = true;
diff --git a/src/lmparse.kl b/src/lmparse.kl
index e49c1554..209b0a8e 100644
--- a/src/lmparse.kl
+++ b/src/lmparse.kl
@@ -186,7 +186,7 @@ nonterm reference_type_ref uses type_ref;
reference_type_ref: KW_Ref type_ref
final {
- $$->typeRef = new TypeRef( TypeRef::Ref, $1->loc, $2->typeRef );
+ $$->typeRef = TypeRef::cons( TypeRef::Ref, $1->loc, $2->typeRef );
};
nonterm global_def uses statement;
@@ -263,7 +263,7 @@ nonterm pred_token
pred_token:
region_qual TK_Word
final {
- TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, $2->data );
+ TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, $2->data );
PredDecl *predDecl = new PredDecl( typeRef, predType, pd->predValue );
pd->predDeclList.append( predDecl );
@@ -273,7 +273,7 @@ pred_token:
region_qual TK_Literal
final {
PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 );
- TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, literal );
+ TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, literal );
PredDecl *predDecl = new PredDecl( typeRef, predType, pd->predValue );
pd->predDeclList.append( predDecl );
@@ -419,7 +419,7 @@ type_ref: KW_Map '<' type_ref type_ref '>'
final {
NamespaceQual *nspaceQual = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- $$->typeRef = new TypeRef( TypeRef::Map, InputLoc(), nspaceQual,
+ $$->typeRef = TypeRef::cons( TypeRef::Map, InputLoc(), nspaceQual,
$3->typeRef, $4->typeRef );
};
@@ -427,34 +427,34 @@ type_ref: KW_List '<' type_ref '>'
final {
NamespaceQual *nspaceQual = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- $$->typeRef = new TypeRef( TypeRef::List, InputLoc(), nspaceQual, $3->typeRef, 0 );
+ $$->typeRef = TypeRef::cons( TypeRef::List, InputLoc(), nspaceQual, $3->typeRef, 0 );
};
type_ref: KW_Vector '<' type_ref '>'
final {
NamespaceQual *nspaceQual = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- $$->typeRef = new TypeRef( TypeRef::Vector, InputLoc(), nspaceQual, $3->typeRef, 0 );
+ $$->typeRef = TypeRef::cons( TypeRef::Vector, InputLoc(), nspaceQual, $3->typeRef, 0 );
};
type_ref: KW_Accum '<' type_ref '>'
final {
NamespaceQual *nspaceQual = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- $$->typeRef = new TypeRef( TypeRef::Parser, InputLoc(), nspaceQual, $3->typeRef, 0 );
+ $$->typeRef = TypeRef::cons( TypeRef::Parser, InputLoc(), nspaceQual, $3->typeRef, 0 );
};
nonterm basic_type_ref uses type_ref;
basic_type_ref: region_qual TK_Word opt_repeat
final {
- $$->typeRef = new TypeRef( $2->loc, $1->nspaceQual, $2->data );
+ $$->typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, $2->data );
$$->typeRef->repeatType = $3->repeatType;
};
basic_type_ref: KW_Ptr region_qual TK_Word opt_repeat
final {
- $$->typeRef = new TypeRef( $1->loc, $2->nspaceQual, $3->data );
+ $$->typeRef = TypeRef::cons( $1->loc, $2->nspaceQual, $3->data );
$$->typeRef->repeatType = $4->repeatType;
- $$->typeRef = new TypeRef( TypeRef::Ptr, $1->loc, $$->typeRef );
+ $$->typeRef = TypeRef::cons( TypeRef::Ptr, $1->loc, $$->typeRef );
};
@@ -651,7 +651,7 @@ nonterm pattern_el_type_or_lit
pattern_el_type_or_lit: region_qual TK_Word opt_repeat
final {
- TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, $2->data );
+ TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, $2->data );
typeRef->repeatType = $3->repeatType;
ProdEl *factor = new ProdEl( ProdEl::ReferenceType, $2->loc, 0, false, typeRef, 0 );
$$->patternItem = new PatternItem( $2->loc, factor, PatternItem::FactorType );
@@ -661,7 +661,7 @@ pattern_el_type_or_lit: region_qual TK_Word opt_repeat
pattern_el_type_or_lit: region_qual TK_Literal opt_repeat
final {
PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 );
- TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, literal );
+ TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, literal );
typeRef->repeatType = $3->repeatType;
ProdEl *factor = new ProdEl( ProdEl::ReferenceType, $2->loc, 0, false, typeRef, 0 );
@@ -716,7 +716,7 @@ repl_el_list: ;
repl_el: region_qual TK_Literal
final {
PdaLiteral *literal = new PdaLiteral( $2->loc, *$2 );
- TypeRef *typeRef = new TypeRef( $2->loc, $1->nspaceQual, literal );
+ TypeRef *typeRef = TypeRef::cons( $2->loc, $1->nspaceQual, literal );
typeRef->repeatType = RepeatNone;
ProdEl *factor = new ProdEl( ProdEl::LiteralType, $2->loc, 0, false, typeRef, 0 );
ReplItem *replItem = new ReplItem( $2->loc, ReplItem::FactorType, factor );
@@ -849,7 +849,7 @@ nonterm prod_el
prod_el:
opt_capture opt_commit region_qual TK_Word opt_repeat
final {
- TypeRef *typeRef = new TypeRef( $4->loc, $3->nspaceQual, $4->data );
+ TypeRef *typeRef = TypeRef::cons( $4->loc, $3->nspaceQual, $4->data );
typeRef->repeatType = $5->repeatType;
$$->factor = new ProdEl( ProdEl::ReferenceType, $4->loc, $1->objField, $2->commit, typeRef, 0 );
@@ -878,7 +878,7 @@ prod_el:
final {
/* Create a new factor node going to a concat literal. */
PdaLiteral *literal = new PdaLiteral( $4->loc, *$4 );
- TypeRef *typeRef = new TypeRef( $4->loc, $3->nspaceQual, literal );
+ TypeRef *typeRef = TypeRef::cons( $4->loc, $3->nspaceQual, literal );
typeRef->repeatType = $5->repeatType;
$$->factor = new ProdEl( ProdEl::LiteralType, $4->loc, $1->objField, $2->commit, typeRef, 0 );
@@ -1868,7 +1868,7 @@ code_factor: KW_Parse opt_capture type_ref '(' opt_code_expr_list ')'
NamespaceQual *nspaceQual = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- TypeRef *parserTypeRef = new TypeRef( TypeRef::Parser,
+ TypeRef *parserTypeRef = TypeRef::cons( TypeRef::Parser,
InputLoc(), nspaceQual, $3->typeRef, 0 );
Replacement *replacement = new Replacement( $1->loc, nspace, pd->rootRegion,
@@ -1907,7 +1907,7 @@ code_factor: KW_ParseStop opt_capture type_ref '(' opt_code_expr_list ')'
NamespaceQual *nspaceQual = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- TypeRef *parserTypeRef = new TypeRef( TypeRef::Parser,
+ TypeRef *parserTypeRef = TypeRef::cons( TypeRef::Parser,
InputLoc(), nspaceQual, $3->typeRef, 0 );
Replacement *replacement = new Replacement( $1->loc, nspace, pd->rootRegion,
@@ -2175,7 +2175,7 @@ factor_with_label:
/* Create the object field. */
NamespaceQual *qual = new NamespaceQual( namespaceStack.top(), regionStack.top() );
- TypeRef *typeRef = new TypeRef( $1->loc, qual, "str" );
+ TypeRef *typeRef = TypeRef::cons( $1->loc, qual, "str" );
ObjField *objField = new ObjField( $1->loc, typeRef, $1->data );
/* Insert it into the map. */
@@ -2576,12 +2576,12 @@ void ColmParser::addArgvList()
{
NamespaceQual *nspaceQual1 = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- TypeRef *typeRef = new TypeRef( InputLoc(), nspaceQual1, "str" );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), nspaceQual1, "str" );
NamespaceQual *nspaceQual2 = new NamespaceQual(
namespaceStack.top(), regionStack.top() );
- pd->argvTypeRef = new TypeRef( TypeRef::List, InputLoc(),
+ pd->argvTypeRef = TypeRef::cons( TypeRef::List, InputLoc(),
nspaceQual2, typeRef, 0 );
}
diff --git a/src/parsetree.h b/src/parsetree.h
index 608a783f..7f70dbfe 100644
--- a/src/parsetree.h
+++ b/src/parsetree.h
@@ -513,7 +513,6 @@ struct TypeMapEl
TypeMapEl( const String &key, LangEl *value )
: type(LangElType), key(key), value(value), typeRef(0) {}
-
Type type;
String key;
LangEl *value;
@@ -1716,49 +1715,122 @@ struct TypeRef
};
/* Qualification and a type name. These require lookup. */
- TypeRef( const InputLoc &loc, NamespaceQual *nspaceQual, String typeName ) :
- type(Name), loc(loc), nspaceQual(nspaceQual), typeName(typeName), pdaLiteral(0), iterDef(0),
- typeRef1(0), typeRef2(0),
- repeatType(RepeatNone),
- nspace(0), uniqueType(0), searchUniqueType(0), generic(0) {}
+ static TypeRef *cons( const InputLoc &loc, NamespaceQual *nspaceQual, String typeName )
+ {
+ TypeRef *t = new TypeRef;
+ t->type = (Name);
+ 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;
+ }
/* Qualification and a type name. These require lookup. */
- TypeRef( const InputLoc &loc, NamespaceQual *nspaceQual, PdaLiteral *pdaLiteral ) :
- type(Literal), loc(loc), nspaceQual(nspaceQual), pdaLiteral(pdaLiteral), iterDef(0),
- typeRef1(0), typeRef2(0),
- repeatType(RepeatNone),
- nspace(0), uniqueType(0), searchUniqueType(0), generic(0) {}
+ static TypeRef *cons( const InputLoc &loc, NamespaceQual *nspaceQual, PdaLiteral *pdaLiteral )
+ {
+ TypeRef *t = new TypeRef;
+ t->type = (Literal);
+ 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;
+ }
/* Generics. */
- TypeRef( Type type, const InputLoc &loc, NamespaceQual *nspaceQual, TypeRef *typeRef1, TypeRef *typeRef2 ) :
- type(type), loc(loc), nspaceQual(nspaceQual), pdaLiteral(0), iterDef(0),
- typeRef1(typeRef1), typeRef2(typeRef2),
- repeatType(RepeatNone),
- nspace(0), uniqueType(0), searchUniqueType(0), generic(0) {}
+ static TypeRef *cons( Type type, const InputLoc &loc, NamespaceQual *nspaceQual, TypeRef *typeRef1, TypeRef *typeRef2 )
+ {
+ TypeRef *t = new 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;
+ }
/* Pointers and Refs. */
- TypeRef( Type type, const InputLoc &loc, TypeRef *typeRef1 ) :
- type(type), loc(loc), nspaceQual(0), pdaLiteral(0), iterDef(0),
- typeRef1(typeRef1), typeRef2(0),
- repeatType(RepeatNone),
- nspace(0), uniqueType(0), searchUniqueType(0), generic(0) {}
+ static TypeRef *cons( Type type, const InputLoc &loc, TypeRef *typeRef1 )
+ {
+ 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;
+ }
/* Resolution not needed. */
/* Iterator definition. */
- TypeRef( const InputLoc &loc, IterDef *iterDef, UniqueType *uniqueType,
- UniqueType *searchUniqueType ) :
- type(Iterator), loc(loc), nspaceQual(0), pdaLiteral(0), iterDef(iterDef),
- typeRef1(0), typeRef2(0),
- repeatType(RepeatNone),
- nspace(0), uniqueType(uniqueType), searchUniqueType(searchUniqueType), generic(0) {}
+ static TypeRef *cons( const InputLoc &loc, IterDef *iterDef, UniqueType *uniqueType,
+ UniqueType *searchUniqueType )
+ {
+ 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;
+ }
/* Unique type is given directly. */
- TypeRef( const InputLoc &loc, UniqueType *uniqueType ) :
- type(Unspecified), loc(loc), nspaceQual(0), pdaLiteral(0), iterDef(0),
- typeRef1(0), typeRef2(0),
- repeatType(RepeatNone),
- nspace(0), uniqueType(uniqueType), searchUniqueType(0), generic(0) {}
+ static TypeRef *cons( const InputLoc &loc, UniqueType *uniqueType )
+ {
+ 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;
+ }
void resolveRepeat( Compiler *pd );
diff --git a/src/pdabuild.cc b/src/pdabuild.cc
index 4bce96ce..3d1c6ab0 100644
--- a/src/pdabuild.cc
+++ b/src/pdabuild.cc
@@ -150,7 +150,7 @@ ProdElList *Compiler::makeProdElList( LangEl *langEl )
{
ProdElList *prodElList = new ProdElList();
UniqueType *uniqueType = findUniqueType( TYPE_TREE, langEl );
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueType );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueType );
prodElList->append( new ProdEl( InputLoc(), typeRef ) );
prodElList->tail->langEl = langEl;
return prodElList;
diff --git a/src/synthesis.cc b/src/synthesis.cc
index 794927ad..47f2ba71 100644
--- a/src/synthesis.cc
+++ b/src/synthesis.cc
@@ -1966,7 +1966,7 @@ void LangStmt::compileForIter( Compiler *pd, CodeVect &code ) const
/* Now that we have done the iterator call lookup we can make the type
* reference for the object field. */
UniqueType *iterUniqueType = pd->findUniqueType( TYPE_ITER, lookup.objMethod->iterDef );
- objField->typeRef = new TypeRef( loc, lookup.objMethod->iterDef, iterUniqueType, searchUT );
+ objField->typeRef = TypeRef::cons( loc, lookup.objMethod->iterDef, iterUniqueType, searchUT );
/* Also force the field to be initialized. */
pd->curLocalFrame->initField( pd, objField );
@@ -2294,7 +2294,7 @@ void CodeBlock::compile( Compiler *pd, CodeVect &code ) const
void Compiler::addMatchLength( ObjectDef *frame, LangEl *lel )
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeInt );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeInt );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "match_length" );
@@ -2309,7 +2309,7 @@ void Compiler::addMatchLength( ObjectDef *frame, LangEl *lel )
void Compiler::addMatchText( ObjectDef *frame, LangEl *lel )
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeStr );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeStr );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "match_text" );
@@ -2324,7 +2324,7 @@ void Compiler::addMatchText( ObjectDef *frame, LangEl *lel )
void Compiler::addInput( ObjectDef *frame )
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeInput );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeInput );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "input" );
@@ -2342,7 +2342,7 @@ void Compiler::addInput( ObjectDef *frame )
void Compiler::addCtx( ObjectDef *frame )
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeStream );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeStream );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "ctx" );
@@ -2393,7 +2393,7 @@ void Compiler::initIntObject( )
void Compiler::addLengthField( ObjectDef *objDef, Code getLength )
{
/* Create the "length" field. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeInt );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeInt );
ObjField *el = new ObjField( InputLoc(), typeRef, "length" );
el->beenReferenced = true;
el->beenInitialized = true;
@@ -2446,7 +2446,7 @@ void Compiler::initInputObject( )
ObjField *Compiler::makeDataEl()
{
/* Create the "data" field. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeStr );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeStr );
ObjField *el = new ObjField( InputLoc(), typeRef, "data" );
/* Setting beenReferenced to true prevents us from assigning instructions
@@ -2464,7 +2464,7 @@ ObjField *Compiler::makeDataEl()
ObjField *Compiler::makePosEl()
{
/* Create the "data" field. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeInt );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeInt );
ObjField *el = new ObjField( InputLoc(), typeRef, "pos" );
/* Setting beenReferenced to true prevents us from assigning instructions
@@ -2481,7 +2481,7 @@ ObjField *Compiler::makePosEl()
ObjField *Compiler::makeLineEl()
{
/* Create the "data" field. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeInt );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeInt );
ObjField *el = new ObjField( InputLoc(), typeRef, "line" );
/* Setting beenReferenced to true prevents us from assigning instructions
@@ -2762,7 +2762,7 @@ void Compiler::initListFunctions( GenericType *gen )
void Compiler::initListField( GenericType *gen, const char *name, int offset )
{
/* Make the type ref and create the field. */
- TypeRef *typeRef = new TypeRef( InputLoc(), gen->utArg );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), gen->utArg );
ObjField *el = new ObjField( InputLoc(), typeRef, name );
el->inGetR = IN_GET_LIST_MEM_R;
@@ -2810,7 +2810,7 @@ void Compiler::initCtxField( GenericType *gen )
/* Make the type ref and create the field. */
UniqueType *ctxUT = findUniqueType( TYPE_TREE, context->lel );
- TypeRef *typeRef = new TypeRef( InputLoc(), ctxUT );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), ctxUT );
ObjField *el = new ObjField( InputLoc(), typeRef, "ctx" );
el->inGetR = IN_GET_ACCUM_CTX_R;
@@ -3112,7 +3112,7 @@ void Compiler::makeDefaultIterators()
void Compiler::addStdin()
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeStream );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeStream );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "stdin" );
@@ -3127,7 +3127,7 @@ void Compiler::addStdin()
void Compiler::addStdout()
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeStr );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeStr );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "stout" );
@@ -3142,7 +3142,7 @@ void Compiler::addStdout()
void Compiler::addStderr()
{
/* Make the type ref. */
- TypeRef *typeRef = new TypeRef( InputLoc(), uniqueTypeStr );
+ TypeRef *typeRef = TypeRef::cons( InputLoc(), uniqueTypeStr );
/* Create the field and insert it into the map. */
ObjField *el = new ObjField( InputLoc(), typeRef, "stderr" );