GP-2237 AddrSpace as marshaling primitive and prettyprint update

This commit is contained in:
caheckman 2022-06-23 20:16:51 -04:00
parent 4807ec354a
commit 6be9943b8a
58 changed files with 1333 additions and 1098 deletions

View file

@ -17,6 +17,9 @@
#include "printlanguage.hh"
#include "funcdata.hh"
const string PrintLanguage::OPEN_PAREN = "(";
const string PrintLanguage::CLOSE_PAREN = ")";
vector<PrintLanguageCapability *> PrintLanguageCapability::thelist;
/// This retrieves the capability with its \b isdefault field set or
@ -138,7 +141,7 @@ void PrintLanguage::pushOp(const OpToken *tok,const PcodeOp *op)
emitOp(revpol.back());
paren = parentheses(tok);
if (paren)
id = emit->openParen('(');
id = emit->openParen(OPEN_PAREN);
else
id = emit->openGroup();
}
@ -170,7 +173,7 @@ void PrintLanguage::pushAtom(const Atom &atom)
if (revpol.back().visited == revpol.back().tok->stage) {
emitOp(revpol.back());
if (revpol.back().paren)
emit->closeParen(')',revpol.back().id);
emit->closeParen(CLOSE_PAREN,revpol.back().id);
else
emit->closeGroup(revpol.back().id);
revpol.pop_back();
@ -327,32 +330,32 @@ void PrintLanguage::emitOp(const ReversePolish &entry)
case OpToken::binary:
if (entry.visited!=1) return;
emit->spaces(entry.tok->spacing,entry.tok->bump); // Spacing around operator
emit->tagOp(entry.tok->print,EmitXml::no_color,entry.op);
emit->tagOp(entry.tok->print1,EmitMarkup::no_color,entry.op);
emit->spaces(entry.tok->spacing,entry.tok->bump);
break;
case OpToken::unary_prefix:
if (entry.visited!=0) return;
emit->tagOp(entry.tok->print,EmitXml::no_color,entry.op);
emit->tagOp(entry.tok->print1,EmitMarkup::no_color,entry.op);
emit->spaces(entry.tok->spacing,entry.tok->bump);
break;
case OpToken::postsurround:
if (entry.visited==0) return;
if (entry.visited==1) { // Front surround token
emit->spaces(entry.tok->spacing,entry.tok->bump);
entry.id2 = emit->openParen(entry.tok->print[0]);
entry.id2 = emit->openParen(entry.tok->print1);
emit->spaces(0,entry.tok->bump);
}
else { // Back surround token
emit->closeParen(entry.tok->print[1],entry.id2);
emit->closeParen(entry.tok->print2,entry.id2);
}
break;
case OpToken::presurround:
if (entry.visited==2) return;
if (entry.visited==0) { // Front surround token
entry.id2 = emit->openParen(entry.tok->print[0]);
entry.id2 = emit->openParen(entry.tok->print1);
}
else { // Back surround token
emit->closeParen(entry.tok->print[1],entry.id2);
emit->closeParen(entry.tok->print2,entry.id2);
emit->spaces(entry.tok->spacing,entry.tok->bump);
}
break;
@ -372,24 +375,22 @@ void PrintLanguage::emitAtom(const Atom &atom)
{
switch(atom.type) {
case syntax:
emit->print(atom.name.c_str(),atom.highlight);
emit->print(atom.name,atom.highlight);
break;
case vartoken:
emit->tagVariable(atom.name.c_str(),atom.highlight,
atom.ptr_second.vn,atom.op);
emit->tagVariable(atom.name,atom.highlight,atom.ptr_second.vn,atom.op);
break;
case functoken:
emit->tagFuncName(atom.name.c_str(),atom.highlight,
atom.ptr_second.fd,atom.op);
emit->tagFuncName(atom.name,atom.highlight,atom.ptr_second.fd,atom.op);
break;
case optoken:
emit->tagOp(atom.name.c_str(),atom.highlight,atom.op);
emit->tagOp(atom.name,atom.highlight,atom.op);
break;
case typetoken:
emit->tagType(atom.name.c_str(),atom.highlight,atom.ptr_second.ct);
emit->tagType(atom.name,atom.highlight,atom.ptr_second.ct);
break;
case fieldtoken:
emit->tagField(atom.name.c_str(),atom.highlight,atom.ptr_second.ct,atom.offset,atom.op);
emit->tagField(atom.name,atom.highlight,atom.ptr_second.ct,atom.offset,atom.op);
break;
case blanktoken:
break; // Print nothing
@ -592,7 +593,7 @@ void PrintLanguage::emitLineComment(int4 indent,const Comment *comm)
int4 id = emit->startComment();
// The comment delimeters should not be printed as
// comment tags, so that they won't get filled
emit->tagComment(commentstart.c_str(),EmitXml::comment_color,
emit->tagComment(commentstart,EmitMarkup::comment_color,
spc,off);
int4 pos = 0;
while(pos < text.size()) {
@ -620,24 +621,21 @@ void PrintLanguage::emitLineComment(int4 indent,const Comment *comm)
pos += 1;
}
string sub = text.substr(pos-count,count);
emit->tagComment(sub.c_str(),EmitXml::comment_color,
spc,off);
emit->tagComment(sub,EmitMarkup::comment_color,spc,off);
}
}
if (commentend.size() != 0)
emit->tagComment(commentend.c_str(),EmitXml::comment_color,
spc,off);
emit->tagComment(commentend,EmitMarkup::comment_color,spc,off);
emit->stopComment(id);
comm->setEmitted(true);
}
/// Tell the emitter whether to emit just the raw tokens or if
/// output is in XML format with additional mark-up on the raw tokens.
/// \param val is \b true for XML mark-up
void PrintLanguage::setXML(bool val)
/// Tell the emitter whether to emit just the raw tokens or if additional mark-up should be provided.
/// \param val is \b true for additional mark-up
void PrintLanguage::setMarkup(bool val)
{
((EmitPrettyPrint *)emit)->setXML(val);
((EmitPrettyPrint *)emit)->setMarkup(val);
}
/// Emitting formal code structuring can be turned off, causing all control-flow