Commit 51136588 authored by rdubner's avatar rdubner

Make sure the VARIABLE_STRING_ output is the same as it was

parent d95ff0b9
...@@ -89,6 +89,9 @@ scan_test(const string &filename) ...@@ -89,6 +89,9 @@ scan_test(const string &filename)
static void static void
CreateSymc(PARAMETERS &params, CreateSymc(PARAMETERS &params,
const COB_PROGRAM_LABELS &program_labels, const COB_PROGRAM_LABELS &program_labels,
const COB_FIELDS &cob_fields,
const COB_FIELD_ATTRIBUTES &cob_field_attributes,
const COB_PIC_SYMBOLS &cob_pic_symbols,
const VARIABLE_TREE &variable_tree, const VARIABLE_TREE &variable_tree,
bool tack_on_python, bool tack_on_python,
bool tack_on_filename) bool tack_on_filename)
...@@ -108,7 +111,7 @@ CreateSymc(PARAMETERS &params, ...@@ -108,7 +111,7 @@ CreateSymc(PARAMETERS &params,
program_labels.FormatProgramInfo(ss); program_labels.FormatProgramInfo(ss);
// Continue with the data variables information: // Continue with the data variables information:
variable_tree.FormatVariablesInfo(ss); variable_tree.FormatVariablesInfo(ss,cob_fields,cob_field_attributes,cob_pic_symbols);
// Do the line/address information from the .text in the minimal form // Do the line/address information from the .text in the minimal form
// used by cobcd.py to figure out which program a trap has occurred in. // used by cobcd.py to figure out which program a trap has occurred in.
...@@ -361,6 +364,9 @@ main(int argc, char *argv[]) ...@@ -361,6 +364,9 @@ main(int argc, char *argv[])
#endif #endif
CreateSymc(params, CreateSymc(params,
program_labels, program_labels,
cob_fields,
cob_field_attributes,
cob_pic_symbols,
variable_tree, variable_tree,
tack_on_python, tack_on_python,
tack_on_filename); tack_on_filename);
......
...@@ -500,6 +500,17 @@ public: ...@@ -500,6 +500,17 @@ public:
v_cob_fields[i].offset = offset_; v_cob_fields[i].offset = offset_;
} }
const COB_FIELD *
Fetch(std::string f_name_) const
{
const COB_FIELD *retval = nullptr;
M_COB_FIELDS::const_iterator it = m_cob_fields.find(f_name_);
if( it != m_cob_fields.end() ) {
retval = &v_cob_fields[it->second];
}
return retval;
}
void void
FixLookup(const COB_DATA &cob_data) FixLookup(const COB_DATA &cob_data)
{ {
......
...@@ -1234,13 +1234,38 @@ VARIABLE_TREE::DumpFlatList() const ...@@ -1234,13 +1234,38 @@ VARIABLE_TREE::DumpFlatList() const
} }
void void
VARIABLE_TREE::FormatVariablesInfo(stringstream &ss) const VARIABLE_TREE::FormatVariablesInfo(stringstream &ss,
const COB_FIELDS &cob_fields,
const COB_FIELD_ATTRIBUTES &cob_field_attributes,
const COB_PIC_SYMBOLS &cob_pic_symbols) const
{ {
for(VVAR_NODES::const_iterator it=flat_list.begin(); for(VVAR_NODES::const_iterator it=flat_list.begin(); it!=flat_list.end(); it++) {
it!=flat_list.end();
it++) {
VAR_NODE *node = *it; VAR_NODE *node = *it;
string f_name = node->f_name;
const COB_FIELD *pfield = cob_fields.Fetch(f_name);
const COB_FIELD_ATTRIBUTE *pattr = nullptr;
int attr_type = 0 ;
int attr_digits = 0 ;
int attr_scale = 0 ;
int attr_flags = 0 ;
string picture = node->picture;
if( pfield ) {
pattr = cob_field_attributes.GetFieldAttribute(pfield->a_name);
if( pattr ) {
attr_type = pattr->type;
attr_digits = pattr->digits;
attr_scale = pattr->scale;
attr_flags = pattr->flags;
string p_name = pattr->p_name;
const COB_PIC_SYMBOL *ppic = cob_pic_symbols.GetPicSymbol(p_name);
if( ppic ) {
picture = ppic->pic_symbol;
}
}
}
ss << "D|"; ss << "D|";
ss << node->section.substr(0,2) << "|"; ss << node->section.substr(0,2) << "|";
ss << ZeroIsNull(node->level) << "|" ; ss << ZeroIsNull(node->level) << "|" ;
...@@ -1249,9 +1274,13 @@ VARIABLE_TREE::FormatVariablesInfo(stringstream &ss) const ...@@ -1249,9 +1274,13 @@ VARIABLE_TREE::FormatVariablesInfo(stringstream &ss) const
ss << ZeroIsNull(node->offset) << "|" ; ss << ZeroIsNull(node->offset) << "|" ;
ss << node->type.substr(0,1) << "|" ; ss << node->type.substr(0,1) << "|" ;
ss << ZeroIsNull(node->size) << "|" ; ss << ZeroIsNull(node->size) << "|" ;
ss << node->picture << "|" ; ss << picture << "|" ;
ss << node->usage << "|" ; ss << node->usage << "|" ;
ss << ZeroIsNull(node->occurs) << "|" ; ss << ZeroIsNull(node->occurs) << "|" ;
ss << ZeroIsNull(attr_type) << "|" ;
ss << ZeroIsNull(attr_digits) << "|" ;
ss << ZeroIsNull(attr_scale) << "|" ;
ss << ZeroIsNull(attr_flags) << "~";
} }
} }
...@@ -203,6 +203,8 @@ typedef std::vector<VAR_NODE *>VVAR_NODES; ...@@ -203,6 +203,8 @@ typedef std::vector<VAR_NODE *>VVAR_NODES;
class COB_DATA; class COB_DATA;
class COB_FIELDS; class COB_FIELDS;
class DATA_DESCRIPTIONS; class DATA_DESCRIPTIONS;
class COB_FIELD_ATTRIBUTES;
class COB_PIC_SYMBOLS;
class VARIABLE_TREE class VARIABLE_TREE
{ {
private: private:
...@@ -238,8 +240,10 @@ public: ...@@ -238,8 +240,10 @@ public:
void Consolidate(const COB_FIELDS &cob_fields); void Consolidate(const COB_FIELDS &cob_fields);
void DumpANode(const VAR_NODE *node) const; void DumpANode(const VAR_NODE *node) const;
void DumpFlatList() const; void DumpFlatList() const;
void FormatVariablesInfo(std::stringstream &ss) const; void FormatVariablesInfo(std::stringstream &ss,
const COB_FIELDS &cob_fields,
const COB_FIELD_ATTRIBUTES &cob_field_attributes,
const COB_PIC_SYMBOLS &cob_pic_symbols) const ;
int int
size() const size() const
{ {
......
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