Skip to content

Commit

Permalink
assign codes for array, user/define function tokens
Browse files Browse the repository at this point in the history
codes were not previously assigned to these tokens, but codes are needed
for proper recreation of these tokens for testing with the translator
tests; so preliminary codes were added to the table so that the codes
are available for the translator to set codes for these tokens

previously the  attached count was set to zero for array tokens, but a
count is required for the recreator (the decoder will also need to set
the count for array tokens), so this count is not set to zero for array
tokens (the attached array pointer now determine if there are attached
tokens)

the rpn item text function was modified to use the attached array
pointer to determine if there are attached tokens, and there was no
reason to use access functions for the members of the item, so these
were replaced with the actual members
  • Loading branch information
thunder422 committed Nov 9, 2013
1 parent ac9ab47 commit e191995
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
10 changes: 5 additions & 5 deletions rpnlist.cpp
Expand Up @@ -35,14 +35,14 @@ RpnList::~RpnList(void)
// function to recreate text (abbreviated contents) of item
QString RpnItem::text(bool withIndexes)
{
QString string = token()->text(withIndexes);
if (attachedCount() > 0)
QString string = m_token->text(withIndexes);
if (m_attached != NULL)
{
QChar separator('[');
for (int i = 0; i < attachedCount(); i++)
for (int i = 0; i < m_attachedCount; i++)
{
string += separator + QString("%1:%2").arg(attached(i)->index())
.arg(attached(i)->token()->text());
string += separator + QString("%1:%2").arg(m_attached[i]->m_index)
.arg(m_attached[i]->m_token->text());
separator = ',';
}
string += ']';
Expand Down
24 changes: 24 additions & 0 deletions table.cpp
Expand Up @@ -1383,6 +1383,30 @@ static TableEntry tableEntries[] =
NULL, "VarRefStr", NULL,
Reference_Flag, 2, String_DataType, &Str_ExprInfo,
NULL, varStrEncode, varStrOperandText, varStrRemove, operandRecreate
},
{ // Array_Code
// TODO preliminary until full array support is implemented
Paren_TokenType, OneWord_Multiple,
NULL, "Array", NULL,
Null_Flag, 2, Double_DataType, NULL
},
{ // DefFuncN_Code
// TODO preliminary until full define function support is implemented
DefFuncN_TokenType, OneWord_Multiple,
NULL, "DefFuncN", NULL,
Null_Flag, 2, Double_DataType, NULL
},
{ // DefFuncP_Code
// TODO preliminary until full define function support is implemented
DefFuncP_TokenType, OneWord_Multiple,
NULL, "DefFuncP", NULL,
Null_Flag, 2, Double_DataType, NULL
},
{ // Function_Code
// TODO preliminary until full user function support is implemented
Paren_TokenType, OneWord_Multiple,
NULL, "Function", NULL,
Null_Flag, 2, Double_DataType, NULL
}
};

Expand Down
19 changes: 16 additions & 3 deletions translator.cpp
Expand Up @@ -468,6 +468,10 @@ TokenStatus Translator::getOperand(Token *&token, DataType dataType,
{
token->setReference();
}
// TODO temporary until define functions are fully implemented
dataType = token->dataType(); // preserve data type
m_table.setToken(token, DefFuncN_Code);
token->setDataType(dataType);
break; // go add token to output and push to done stack

case NoParen_TokenType:
Expand Down Expand Up @@ -526,6 +530,10 @@ TokenStatus Translator::getOperand(Token *&token, DataType dataType,
delete m_holdStack.pop().token;
return status;
}
// TODO temporary until define functions are fully implemented
dataType = token->dataType(); // preserve data type
m_table.setToken(token, DefFuncP_Code);
token->setDataType(dataType);
doneAppend = false; // already appended
break;

Expand Down Expand Up @@ -818,8 +826,14 @@ TokenStatus Translator::processParenToken(Token *&token)
DataType dataType;
// TODO need to check test mode once dictionaries are implemented
// REMOVE for now assume functions start with an 'F'
if (token->isType(Paren_TokenType) && (token->reference()
|| !token->string().startsWith('F', Qt::CaseInsensitive)))
// TODO temporary until array and functions are fully implemented
bool isArray;
if (token->isType(Paren_TokenType))
{
isArray = !token->string().startsWith('F', Qt::CaseInsensitive);
token->setCode(isArray ? Array_Code : Function_Code);
}
if (token->isType(Paren_TokenType) && (token->reference() || isArray))
{
dataType = Integer_DataType; // array subscripts
}
Expand Down Expand Up @@ -880,7 +894,6 @@ TokenStatus Translator::processParenToken(Token *&token)
if (dataType == Integer_DataType) // array subscript?
{
// don't save operands on array references
count = 0;
attached = NULL;
}
else // pop and save operands
Expand Down

0 comments on commit e191995

Please sign in to comment.