Commit 71f90474 authored by rdubner's avatar rdubner

Working towards handling EXTERNAL

This version scans for EXTERNAL data types and adds them to the cob_data object.
parent 3648ec82
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
using namespace std; using namespace std;
//#define DUMPING #define DUMPING
void void
scan_test(const string &filename) scan_test(const string &filename)
...@@ -332,10 +332,10 @@ main(int argc, char *argv[]) ...@@ -332,10 +332,10 @@ main(int argc, char *argv[])
); );
#if defined(DUMPING) #if defined(DUMPING)
cout << endl; cout << endl;
program_labels.Dump(); //program_labels.Dump();
cob_pic_symbols.Dump(); //cob_pic_symbols.Dump();
cob_data.Dump(); cob_data.Dump();
cob_field_attributes.Dump(); //cob_field_attributes.Dump();
cob_fields.Dump(); cob_fields.Dump();
#endif #endif
// We now have a nice complete list of COB_DATA, COB_FIELD_ATTRIBUTES, COB_FIELDS // We now have a nice complete list of COB_DATA, COB_FIELD_ATTRIBUTES, COB_FIELDS
...@@ -354,7 +354,9 @@ main(int argc, char *argv[]) ...@@ -354,7 +354,9 @@ main(int argc, char *argv[])
// The Consolidate() routine puts them together. // The Consolidate() routine puts them together.
variable_tree.Dump();
variable_tree.Consolidate(data_description); variable_tree.Consolidate(data_description);
variable_tree.Dump();
#if defined(DUMPING) #if defined(DUMPING)
variable_tree.Dump(); variable_tree.Dump();
variable_tree.DumpFlatList(); variable_tree.DumpFlatList();
......
...@@ -148,6 +148,21 @@ ProcessDataStorage(ifstream &ifs, ...@@ -148,6 +148,21 @@ ProcessDataStorage(ifstream &ifs,
continue; continue;
} }
// Look for external storage
const string EXTERNAL_PREAMBLE = "static unsigned char\t*b_";
if( input.substr(0,EXTERNAL_PREAMBLE.size()) EQ EXTERNAL_PREAMBLE ) {
string c_symbol = "b_";
size_t nfound = EXTERNAL_PREAMBLE.size();
while( isdigit(input[nfound]) ) {
c_symbol += input[nfound++];
}
string cbl_symbol = GetCommentText(input);
int size = 0;
cob_data.Insert(c_symbol, size, program_id, storage, cbl_symbol);
continue;
}
vector<string> tokens = Split(input," \t"); vector<string> tokens = Split(input," \t");
if(input.substr(0,lswitch.size()) EQ lswitch) { if(input.substr(0,lswitch.size()) EQ lswitch) {
//storage = "Local"; //storage = "Local";
...@@ -305,12 +320,16 @@ ProcessDataStorage(ifstream &ifs, ...@@ -305,12 +320,16 @@ ProcessDataStorage(ifstream &ifs,
} }
while( nfound < input.length() ) { while( nfound < input.length() ) {
char ch = input[nfound++]; char ch = input[nfound++];
if( ch EQ ',' ) { if( !isdigit(ch) ) {
break; break;
} }
name_of_data += ch; name_of_data += ch;
} }
if(name_of_data EQ "NU") {
name_of_data = "";
}
// Skip past the ampersand: // Skip past the ampersand:
while( nfound < input.length() ) { while( nfound < input.length() ) {
char ch = input[nfound++]; char ch = input[nfound++];
......
...@@ -1111,6 +1111,8 @@ void ...@@ -1111,6 +1111,8 @@ void
VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_description,string &base_symbol) VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_description,string &base_symbol)
{ {
if( node ) { if( node ) {
cout << "DEBUG0 " << node->level << " " << node->canonical_name << " " << base_symbol << endl;
VSTRING tokens = Split(node->GetCanonicalName(),"/"); VSTRING tokens = Split(node->GetCanonicalName(),"/");
if( tokens.size() >= 2 ) { if( tokens.size() >= 2 ) {
if( node->level <= 1 OR node->level EQ 77 ) { if( node->level <= 1 OR node->level EQ 77 ) {
...@@ -1129,13 +1131,15 @@ VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_descript ...@@ -1129,13 +1131,15 @@ VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_descript
// We do! Save the index // We do! Save the index
index = data_description.GetIndex(program_id,cbl_symbol,offset); index = data_description.GetIndex(program_id,cbl_symbol,offset);
node->data_description_index = index; node->data_description_index = index;
} else if( data_description.IsInDs(program_id,cbl_symbol) ) {
// We didn't find one specifically at that offset, but there is
// non-specific entry (which happens when COBOL code doesn't
// actually reference the variable
index = data_description.GetIndex(program_id,cbl_symbol);
node->data_description_index = index;
} }
//else if( data_description.IsInDs(program_id,cbl_symbol) )
// {
// // We didn't find one specifically at that offset, but there is
// // non-specific entry (which happens when COBOL code doesn't
// // actually reference the variable
// index = data_description.GetIndex(program_id,cbl_symbol);
// node->data_description_index = index;
// }
if( index EQ NO_INDEX AND !node->redefines.empty() ) { if( index EQ NO_INDEX AND !node->redefines.empty() ) {
// We couldn't find ourself with our own name. Perhaps we // We couldn't find ourself with our own name. Perhaps we
...@@ -1212,6 +1216,7 @@ VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_descript ...@@ -1212,6 +1216,7 @@ VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_descript
// this node: // this node:
if( node->base_symbol.empty() AND !base_symbol.empty() ) { if( node->base_symbol.empty() AND !base_symbol.empty() ) {
cout << "DEBUG1 " << node->canonical_name << " " << base_symbol << endl ;
node->base_symbol = base_symbol; node->base_symbol = base_symbol;
} }
...@@ -1229,7 +1234,13 @@ VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_descript ...@@ -1229,7 +1234,13 @@ VARIABLE_TREE::Consolidive(VAR_NODE *node,const DATA_DESCRIPTIONS &data_descript
// One of our descendents has a base_address, and we don't. I'm not really // One of our descendents has a base_address, and we don't. I'm not really
// sure that can happen, but just in case, propogate that base_symbol // sure that can happen, but just in case, propogate that base_symbol
// upward: // upward:
cout << "DEBUG2 " << node->canonical_name << " " << base_symbol << endl ;
node->base_symbol = base_symbol; node->base_symbol = base_symbol;
if( node->level <= 1 OR node->level EQ 77 ) {
// We're starting work on a brand-new level-one(ish) variable. We need to
// clear out the base_symbol:
base_symbol = "" ;
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment