Skip to content

Commit

Permalink
code.l: make CallContext independent of global variables
Browse files Browse the repository at this point in the history
  • Loading branch information
groleo committed Jul 26, 2019
1 parent 7f7e3fe commit 632fc63
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/code.l
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ class CallContext
public:
struct Ctx
{
Ctx() : name(g_name), type(g_type), d(0) {}
Ctx(QCString _name, QCString _type) : name(_name), type(_type), d(0) {}
QCString name;
QCString type;
const Definition *d;
};

CallContext()
CallContext()
{
m_defList.append(new Ctx);
m_defList.append(new Ctx("",""));
m_defList.setAutoDelete(TRUE);
}
virtual ~CallContext() {}
Expand All @@ -359,21 +359,21 @@ class CallContext
ctx->d=d;
}
}
void pushScope()
void pushScope(QCString _name, QCString _type)
{
m_defList.append(new Ctx);
m_defList.append(new Ctx(_name,_type));
DBG_CTX((stderr,"** Push call context %d\n",m_defList.count()));
}
void popScope()
void popScope(QCString &_name, QCString &_type)
{
if (m_defList.count()>1)
{
DBG_CTX((stderr,"** Pop call context %d\n",m_defList.count()));
Ctx *ctx = m_defList.getLast();
if (ctx)
{
g_name = ctx->name;
g_type = ctx->type;
_name = ctx->name;
_type = ctx->type;
}
m_defList.removeLast();
}
Expand All @@ -386,7 +386,7 @@ class CallContext
{
DBG_CTX((stderr,"** Clear call context\n"));
m_defList.clear();
m_defList.append(new Ctx);
m_defList.append(new Ctx("",""));
}
const Definition *getScope() const
{
Expand Down Expand Up @@ -2510,7 +2510,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
}
<Body>"*"{B}*")" { // end of cast?
g_code->codify(yytext);
g_theCallContext.popScope();
g_theCallContext.popScope(g_name, g_type);
g_bracketCount--;
g_parmType = g_name;
BEGIN(FuncCall);
Expand All @@ -2520,7 +2520,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_name.resize(0);g_type.resize(0);
if (*yytext==')')
{
g_theCallContext.popScope();
g_theCallContext.popScope(g_name, g_type);
g_bracketCount--;
BEGIN(FuncCall);
}
Expand Down Expand Up @@ -2852,7 +2852,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
}
else if (*yytext=='[')
{
g_theCallContext.pushScope();
g_theCallContext.pushScope(g_name, g_type);
}
g_args.resize(0);
g_parmType.resize(0);
Expand All @@ -2878,7 +2878,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
}
<ObjCMemberCall>"[" {
g_code->codify(yytext);
g_theCallContext.pushScope();
g_theCallContext.pushScope(g_name, g_type);
}
<ObjCMemberCall2>{ID}":"? {
g_name+=yytext;
Expand All @@ -2900,7 +2900,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
BEGIN(ObjCMemberCall3);
}
<ObjCMemberCall2,ObjCMemberCall3>"]" {
g_theCallContext.popScope();
g_theCallContext.popScope(g_name, g_type);
g_code->codify(yytext);
BEGIN(Body);
}
Expand Down Expand Up @@ -2990,7 +2990,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
<ObjCCall,ObjCMName,ObjCSkipStr>\n { g_currentCtx->format+=*yytext; }

<Body>"]" {
g_theCallContext.popScope();
g_theCallContext.popScope(g_name, g_type);
g_code->codify(yytext);
// TODO: nested arrays like: a[b[0]->func()]->func()
g_name = g_saveName.copy();
Expand Down Expand Up @@ -3093,7 +3093,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_parmType.resize(0);g_parmName.resize(0);
g_code->codify(yytext);
g_bracketCount++;
g_theCallContext.pushScope();
g_theCallContext.pushScope(g_name, g_type);
if (YY_START==FuncCall && !g_insideBody)
{
g_theVarContext.pushScope();
Expand Down Expand Up @@ -3127,7 +3127,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_parmName.resize(0);
g_theVarContext.addVariable(g_parmType,g_parmName);
}
g_theCallContext.popScope();
g_theCallContext.popScope(g_name, g_type);
g_inForEachExpression = FALSE;
//g_theCallContext.setClass(0); // commented out, otherwise a()->b() does not work for b().
g_code->codify(yytext);
Expand Down Expand Up @@ -3184,7 +3184,7 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
g_theVarContext.pushScope();
}
g_theVarContext.addVariable(g_parmType,g_parmName);
//g_theCallContext.popScope();
//g_theCallContext.popScope(g_name, g_type);
g_parmType.resize(0);g_parmName.resize(0);
int index = g_name.findRev("::");
DBG_CTX((stderr,"g_name=%s\n",g_name.data()));
Expand Down Expand Up @@ -3644,11 +3644,11 @@ RAWEND ")"[^ \t\(\)\\]{0,16}\"
}
<*>"("|"[" {
g_code->codify(yytext);
g_theCallContext.pushScope();
g_theCallContext.pushScope(g_name, g_type);
}
<*>")"|"]" {
g_code->codify(yytext);
g_theCallContext.popScope();
g_theCallContext.popScope(g_name, g_type);
}
<*>\n {
g_yyColNr++;
Expand Down

0 comments on commit 632fc63

Please sign in to comment.