diff options
author | Adrian Thurston <thurston@complang.org> | 2011-05-12 02:58:19 +0000 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2011-05-12 02:58:19 +0000 |
commit | 2dce9cc600bd02b50c7c6860155232a4f4c21ff5 (patch) | |
tree | 474b7f684e177eb9154b5b9f539742b9c9a99868 | |
parent | adf5c202ca18265cca6fe902890de552e2ed5c20 (diff) | |
download | colm-2dce9cc600bd02b50c7c6860155232a4f4c21ff5.tar.gz |
Fixes for 64bit. The SIZEOF_LONG macro was not being included in a header that
it should have been included in. Included it and also added some preprocessor
tests that cause an error if the the macros is not defined to something
expected. refs #242.
-rw-r--r-- | colm/bytecode.c | 4 | ||||
-rw-r--r-- | colm/bytecode.h | 4 | ||||
-rw-r--r-- | colm/fsmrun.c | 34 | ||||
-rw-r--r-- | colm/parsetree.h | 4 | ||||
-rw-r--r-- | colm/pdarun.h | 5 | ||||
-rw-r--r-- | colm/tree.c | 72 |
6 files changed, 70 insertions, 53 deletions
diff --git a/colm/bytecode.c b/colm/bytecode.c index 136037fa..d917942b 100644 --- a/colm/bytecode.c +++ b/colm/bytecode.c @@ -33,6 +33,10 @@ #include "debug.h" #include "config.h" +#if SIZEOF_LONG != 4 && SIZEOF_LONG != 8 + #error "SIZEOF_LONG contained an unexpected value" +#endif + #undef COLM_LOG #undef COLM_LOG_BYTECODE #undef COLM_LOG_PARSE diff --git a/colm/bytecode.h b/colm/bytecode.h index d885023a..e7b2b431 100644 --- a/colm/bytecode.h +++ b/colm/bytecode.h @@ -29,6 +29,10 @@ extern "C" { #endif +#if SIZEOF_LONG != 4 && SIZEOF_LONG != 8 + #error "SIZEOF_LONG contained an unexpected value" +#endif + typedef unsigned long ulong; typedef unsigned char uchar; diff --git a/colm/fsmrun.c b/colm/fsmrun.c index 484a4227..c70d0301 100644 --- a/colm/fsmrun.c +++ b/colm/fsmrun.c @@ -556,12 +556,12 @@ void executeGenerationAction( Tree **sp, Program *prg, FsmRun *fsmRun, PdaRun *p void generationAction( Tree **sp, InputStream *inputStream, FsmRun *fsmRun, PdaRun *pdaRun, int id, Head *tokdata, int namedLangEl, int bindId ) { - #ifdef COLM_LOG_PARSE - if ( colm_log_parse ) { - cerr << "generation action: " << - pdaRun->tables->rtd->lelInfo[id].name << endl; - } - #endif +// #ifdef COLM_LOG_PARSE +// if ( colm_log_parse ) { +// cerr << "generation action: " << +// pdaRun->tables->rtd->lelInfo[id].name << endl; +// } +// #endif /* Find the code. */ Code *code = pdaRun->tables->rtd->frameInfo[ @@ -984,11 +984,11 @@ long scanToken( PdaRun *pdaRun, FsmRun *fsmRun, InputStream *inputStream ) void scannerError( Tree **sp, InputStream *inputStream, FsmRun *fsmRun, PdaRun *pdaRun ) { if ( pdaRunGetNextRegion( pdaRun, 1 ) != 0 ) { - #ifdef COLM_LOG_PARSE - if ( colm_log_parse ) { - cerr << "scanner failed, trying next region" << endl; - } - #endif +// #ifdef COLM_LOG_PARSE +// if ( colm_log_parse ) { +// cerr << "scanner failed, trying next region" << endl; +// } +// #endif /* May have accumulated ignore tokens from a previous region. * need to rescan them since we won't be sending tokens from @@ -997,12 +997,12 @@ void scannerError( Tree **sp, InputStream *inputStream, FsmRun *fsmRun, PdaRun * pdaRun->nextRegionInd += 1; } else if ( pdaRun->numRetry > 0 ) { - /* Invoke the parser's error handling. */ - #ifdef COLM_LOG_PARSE - if ( colm_log_parse ) { - cerr << "invoking parse error from the scanner" << endl; - } - #endif +// /* Invoke the parser's error handling. */ +// #ifdef COLM_LOG_PARSE +// if ( colm_log_parse ) { +// cerr << "invoking parse error from the scanner" << endl; +// } +// #endif sendBackQueuedIgnore( sp, inputStream, fsmRun, pdaRun ); parseToken( sp, pdaRun, fsmRun, inputStream, 0 ); diff --git a/colm/parsetree.h b/colm/parsetree.h index fc1255eb..fa05c413 100644 --- a/colm/parsetree.h +++ b/colm/parsetree.h @@ -45,6 +45,10 @@ #define OP_LogicalOr 'o' #define OP_Deref 'd' +#if SIZEOF_LONG != 4 && SIZEOF_LONG != 8 + #error "SIZEOF_LONG contained an unexpected value" +#endif + struct NameInst; struct FsmGraph; struct RedFsm; diff --git a/colm/pdarun.h b/colm/pdarun.h index 94ff74c4..f4f77c74 100644 --- a/colm/pdarun.h +++ b/colm/pdarun.h @@ -24,11 +24,16 @@ #include "input.h" #include "fsmrun.h" +#include "config.h" #ifdef __cplusplus extern "C" { #endif +#if SIZEOF_LONG != 4 && SIZEOF_LONG != 8 + #error "SIZEOF_LONG contained an unexpected value" +#endif + typedef unsigned char Code; typedef unsigned long Word; typedef unsigned long Half; diff --git a/colm/tree.c b/colm/tree.c index caf5b377..03341c7f 100644 --- a/colm/tree.c +++ b/colm/tree.c @@ -626,12 +626,12 @@ Tree *copyRealTree( Program *prg, Tree *tree, Kid *oldNextDown, List *copyList( Program *prg, List *list, Kid *oldNextDown, Kid **newNextDown ) { - #ifdef COLM_LOG_BYTECODE - if ( colm_log_bytecode ) { - cerr << "splitting list: " << list << " refs: " << - list->refs << endl; - } - #endif +// #ifdef COLM_LOG_BYTECODE +// if ( colm_log_bytecode ) { +// cerr << "splitting list: " << list << " refs: " << +// list->refs << endl; +// } +// #endif /* Not a need copy. */ List *newList = (List*)mapElAllocate( prg ); @@ -658,12 +658,12 @@ List *copyList( Program *prg, List *list, Kid *oldNextDown, Kid **newNextDown ) Map *copyMap( Program *prg, Map *map, Kid *oldNextDown, Kid **newNextDown ) { - #ifdef COLM_LOG_BYTECODE - if ( colm_log_bytecode ) { - cerr << "splitting map: " << map << " refs: " << - map->refs << endl; - } - #endif +// #ifdef COLM_LOG_BYTECODE +// if ( colm_log_bytecode ) { +// cerr << "splitting map: " << map << " refs: " << +// map->refs << endl; +// } +// #endif Map *newMap = (Map*)mapElAllocate( prg ); newMap->id = map->genericInfo->langElId; @@ -725,12 +725,12 @@ Tree *splitTree( Program *prg, Tree *tree ) assert( tree->refs >= 1 ); if ( tree->refs > 1 ) { - #ifdef COLM_LOG_BYTECODE - if ( colm_log_bytecode ) { - cerr << "splitting tree: " << tree << " refs: " << - tree->refs << endl; - } - #endif +// #ifdef COLM_LOG_BYTECODE +// if ( colm_log_bytecode ) { +// cerr << "splitting tree: " << tree << " refs: " << +// tree->refs << endl; +// } +// #endif Kid *oldNextDown = 0, *newNextDown = 0; Tree *newTree = copyTree( prg, tree, oldNextDown, &newNextDown ); @@ -1063,13 +1063,13 @@ int matchPattern( Tree **bindings, Program *prg, long pat, Kid *kid, int checkNe { PatReplNode *nodes = prg->rtd->patReplNodes; - #ifdef COLM_LOG_MATCH - if ( colm_log_match ) { - LangElInfo *lelInfo = prg->rtd->lelInfo; - cerr << "match pattern " << ( pat == -1 ? "NULL" : lelInfo[nodes[pat].id].name ) << - " vs " << ( kid == 0 ? "NULL" : lelInfo[kid->tree->id].name ) << endl; - } - #endif +// #ifdef COLM_LOG_MATCH +// if ( colm_log_match ) { +// LangElInfo *lelInfo = prg->rtd->lelInfo; +// cerr << "match pattern " << ( pat == -1 ? "NULL" : lelInfo[nodes[pat].id].name ) << +// " vs " << ( kid == 0 ? "NULL" : lelInfo[kid->tree->id].name ) << endl; +// } +// #endif /* match node, recurse on children. */ if ( pat != -1 && kid != 0 ) { @@ -1089,11 +1089,11 @@ int matchPattern( Tree **bindings, Program *prg, long pat, Kid *kid, int checkNe /* No failure, all okay. */ if ( nodes[pat].bindId > 0 ) { - #ifdef COLM_LOG_MATCH - if ( colm_log_match ) { - cerr << "bindId: " << nodes[pat].bindId << endl; - } - #endif +// #ifdef COLM_LOG_MATCH +// if ( colm_log_match ) { +// cerr << "bindId: " << nodes[pat].bindId << endl; +// } +// #endif bindings[nodes[pat].bindId] = kid->tree; } @@ -1207,12 +1207,12 @@ void splitRef( Tree ***psp, Program *prg, Ref *fromRef ) /* Now traverse the list, which goes down. */ while ( ref != 0 ) { if ( ref->kid->tree->refs > 1 ) { - #ifdef COLM_LOG_BYTECODE - if ( colm_log_bytecode ) { - cerr << "splitting tree: " << ref->kid << " refs: " << - ref->kid->tree->refs << endl; - } - #endif +// #ifdef COLM_LOG_BYTECODE +// if ( colm_log_bytecode ) { +// cerr << "splitting tree: " << ref->kid << " refs: " << +// ref->kid->tree->refs << endl; +// } +// #endif Ref *nextDown = ref->next; while ( nextDown != 0 && nextDown->kid == ref->kid ) |