summaryrefslogtreecommitdiff
path: root/src/declare.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2018-12-02 13:07:46 -0500
committerAdrian Thurston <thurston@colm.net>2018-12-02 13:07:46 -0500
commit779a96e143c9aaccebd24f5de48dee04e46aeab6 (patch)
treef40c0e56edc71e7c2ff122d54622b52301747037 /src/declare.cc
parentc53140a12f434c08e01ef3c84cfd8456e6525531 (diff)
downloadcolm-779a96e143c9aaccebd24f5de48dee04e46aeab6.tar.gz
make location file name and column available in Colm code
Diffstat (limited to 'src/declare.cc')
-rw-r--r--src/declare.cc54
1 files changed, 44 insertions, 10 deletions
diff --git a/src/declare.cc b/src/declare.cc
index 6e92bdf0..d521e7c6 100644
--- a/src/declare.cc
+++ b/src/declare.cc
@@ -926,22 +926,22 @@ ObjectField *Compiler::makeDataEl()
return el;
}
-ObjectField *Compiler::makePosEl()
+ObjectField *Compiler::makeFileEl()
{
- /* Create the "data" field. */
- TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
+ /* Create the "file" field. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeStr );
ObjectField *el = ObjectField::cons( internal,
- ObjectField::InbuiltFieldType, typeRef, "pos" );
+ ObjectField::InbuiltFieldType, typeRef, "file" );
el->isConst = true;
- el->inGetR = IN_GET_TOKEN_POS_R;
- el->inGetValR = IN_GET_TOKEN_POS_R;
+ el->inGetR = IN_GET_TOKEN_FILE_R;
+ el->inGetValR = IN_GET_TOKEN_FILE_R;
return el;
}
ObjectField *Compiler::makeLineEl()
{
- /* Create the "data" field. */
+ /* Create the "line" field. */
TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
ObjectField *el = ObjectField::cons( internal,
ObjectField::InbuiltFieldType, typeRef, "line" );
@@ -952,6 +952,32 @@ ObjectField *Compiler::makeLineEl()
return el;
}
+ObjectField *Compiler::makeColEl()
+{
+ /* Create the "col" field. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
+ ObjectField *el = ObjectField::cons( internal,
+ ObjectField::InbuiltFieldType, typeRef, "col" );
+
+ el->isConst = true;
+ el->inGetR = IN_GET_TOKEN_COL_R;
+ el->inGetValR = IN_GET_TOKEN_COL_R;
+ return el;
+}
+
+ObjectField *Compiler::makePosEl()
+{
+ /* Create the "data" field. */
+ TypeRef *typeRef = TypeRef::cons( internal, uniqueTypeInt );
+ ObjectField *el = ObjectField::cons( internal,
+ ObjectField::InbuiltFieldType, typeRef, "pos" );
+
+ el->isConst = true;
+ el->inGetR = IN_GET_TOKEN_POS_R;
+ el->inGetValR = IN_GET_TOKEN_POS_R;
+ return el;
+}
+
/* Add a constant length field to the object.
* Opcode supplied by the caller. */
void Compiler::addLengthField( ObjectDef *objDef, code_t getLength )
@@ -977,13 +1003,21 @@ void Compiler::declareTokenFields( )
ObjectField *dataEl = makeDataEl();
lel->objectDef->rootScope->insertField( dataEl->name, dataEl );
- /* Create the "pos" field. */
- ObjectField *posEl = makePosEl();
- lel->objectDef->rootScope->insertField( posEl->name, posEl );
+ /* Create the "file" field. */
+ ObjectField *fileEl = makeFileEl();
+ lel->objectDef->rootScope->insertField( fileEl->name, fileEl );
/* Create the "line" field. */
ObjectField *lineEl = makeLineEl();
lel->objectDef->rootScope->insertField( lineEl->name, lineEl );
+
+ /* Create the "col" field. */
+ ObjectField *colEl = makeColEl();
+ lel->objectDef->rootScope->insertField( colEl->name, colEl );
+
+ /* Create the "pos" field. */
+ ObjectField *posEl = makePosEl();
+ lel->objectDef->rootScope->insertField( posEl->name, posEl );
}
}
}