Skip to content

Commit

Permalink
old translator remove - reference flag cleanup
Browse files Browse the repository at this point in the history
processDoneStackTop() no longer needs to handle tokens with the
reference flag set (specifically for sub-string assignments) as this is
now handled elsewhere, therefore this code was removed; and the
temporary in-line variableErrStatus() previously called was removed

getOperand() was modified to clear the reference flag for an internal
function after it was set for a sub-string function for an reference
request since the reference flag is not needed after this point

removed the setting and clearing of the reference flag for tokens in
inputTranslate() and letTranslate()
  • Loading branch information
thunder422 committed Aug 24, 2013
1 parent ca3b513 commit 010789b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 55 deletions.
2 changes: 0 additions & 2 deletions basic/input.cpp
Expand Up @@ -114,13 +114,11 @@ TokenStatus inputTranslate(Translator &translator, Token *commandToken,

// change token to appropriate assign code and append to output
translator.table().setToken(inputToken, InputAssign_Code);
inputToken->setReference(); // FIXME remove with old translator
status = translator.processFinalOperand(inputToken);
if (status != Good_TokenStatus)
{
break;
}
inputToken->setReference(false); // FIXME remove with old translator

// create and insert input parse code at beginning
// (inserted in reverse order for each input variable)
Expand Down
8 changes: 2 additions & 6 deletions basic/let.cpp
Expand Up @@ -122,16 +122,13 @@ TokenStatus letTranslate(Translator &translator, Token *commandToken,
{
// change token to appropriate assign code
translator.table().setToken(token, Assign_Code);
token->setReference(); // FIXME remove with old translator
status = translator.processDoneStackTop(token);
if (status != Good_TokenStatus)
{
return status;
}
}
// reset reference, no longer needed, and save token
token->setReference(false); // FIXME remove with old translator
letStack.push(token);
letStack.push(token); // save token

// get data type for assignment
if (dataType == Any_DataType)
Expand Down Expand Up @@ -183,8 +180,7 @@ TokenStatus letTranslate(Translator &translator, Token *commandToken,
translator.doneStackDrop();
translator.outputAppend(letToken);

// reset reference, no longer needed, and set hidden LET flag if needed
letToken->setReference(false);
// set hidden LET flag if needed
if (!hidden)
{
letToken->setSubCodeMask(Let_SubCode);
Expand Down
48 changes: 5 additions & 43 deletions translator.cpp
Expand Up @@ -181,37 +181,6 @@ TokenStatus Translator::processDoneStackTop(Token *&token, int operandIndex,
m_doneStack.top().last = NULL; // prevent deletion below
}

// FIXME remove section with old translator
// check if reference is required for first operand
if (operandIndex == 0 && token->reference())
{
if (!topToken->reference())
{
// need a reference, so return error

// only delete token if it's not an internal function
if (!token->isType(IntFuncP_TokenType))
{
// (internal function is on hold stack, will be deleted later)
delete token; // delete the token
}
// return non-reference operand
// (report entire expression)
token = localFirst->setThrough(localLast);

// delete last token if close paren
DoneItem::deleteCloseParen(localLast);

// XXX check command on top of command stack XXX
return ExpAssignItem_TokenStatus;
}
}
else
{
// reset reference flag of operand
topToken->setReference(false);
}

// see if main code's data type matches
DataType dataType = topToken->dataType();
Code cvtCode = m_table.findCode(token, dataType, operandIndex);
Expand All @@ -233,19 +202,10 @@ TokenStatus Translator::processDoneStackTop(Token *&token, int operandIndex,
}

// no match found, report error
// change token to token with invalid data type and return error
// use main code's expected data type for operand
// (return expected variable error for references and sub-strings)
TokenStatus status;
if (!token->reference())
{
status = expectedErrStatus(dataType);
// sub-string no longer needed with first/last operands
}
else
{
status = variableErrStatus(dataType);
}
TokenStatus status = expectedErrStatus(dataType);

// change token to token with invalid data type and return error
// report entire expression
token = localFirst->setThrough(localLast);

Expand Down Expand Up @@ -846,6 +806,8 @@ TokenStatus Translator::getOperand(Token *&token, DataType dataType,
delete m_holdStack.pop().token;
return status;
}
// reset reference if it was set above, no longer needed
token->setReference(false);
doneAppend = false; // already appended
break;

Expand Down
4 changes: 0 additions & 4 deletions translator.h
Expand Up @@ -148,10 +148,6 @@ class Translator
// Determine Error Funtions (By DataType)
static TokenStatus expectedErrStatus(DataType dataType,
Reference reference = None_Reference);
static TokenStatus variableErrStatus(DataType dataType)
{ // FIXME remove with old translator routines
return expectedErrStatus(dataType, All_Reference);
}

private:
// New Translator Functions
Expand Down

0 comments on commit 010789b

Please sign in to comment.