engine/source/scriptlib/Interpreter.c
/******************************************************************************
*  EvaluateImmediate -- This method scans the instruction list and evaluates
*  any immediate code that may be present.  In the instruction list, immediate
*  code is preceeded by an IMMEDIATE instruction, and followed by a DEFERRED
*  instruction.
*  Parameters: none
*  Returns: S_OK
*           E_FAIL
******************************************************************************/
- This method scans the instruction list and evaluates
any immediate code that may be present.  In the instruction list, immediate
code is preceeded by an IMMEDIATE instruction, and followed by a DEFERRED
instruction.
- This method scans the instruction list and evaluates any immediate code that may be present . In the instruction list immediate code is preceeded by an IMMEDIATE instruction and followed by a DEFERRED instruction .
HRESULT Interpreter_EvaluateImmediate(Interpreter *pinterpreter)
{
    BOOL bImmediate = FALSE;
    HRESULT hr = S_OK;
    Instruction *pInstruction = NULL;
    int size, index;
    if(pinterpreter->bHasImmediateCode)
    {
        size = pinterpreter->theInstructionList.size;
        for(index = 0; index < size; index++)
        {
            pInstruction = (Instruction *)(pinterpreter->theInstructionList.solidlist[index]);
            if (pInstruction->OpCode == IMMEDIATE)
            {
                bImmediate = TRUE;
            }
            else if (pInstruction->OpCode == DEFERRED)
            {
                bImmediate = FALSE;
            }
            if (bImmediate)
            {
                pinterpreter->pCurrentInstruction = ((Instruction **)pinterpreter->theInstructionList.solidlist) + index;
                hr = Interpreter_EvalInstruction(pinterpreter);
            }
            if (FAILED(hr))
            {
                break;
            }
        }
    }
    if (!pinterpreter->bMainCompleted)
    {
        if(pinterpreter->pMainEntry)
        {
            pinterpreter->pCurrentInstruction = pinterpreter->pMainEntry;
            hr = Interpreter_EvaluateCall(pinterpreter);
        }
        else
        {
            hr = E_FAIL;
        }
        if (SUCCEEDED(hr))
        {
            pinterpreter->bMainCompleted = TRUE;
        }
        pinterpreter->bCallCompleted = FALSE;
    }
    pinterpreter->bReset = FALSE;
    return hr;
}
HRESULT Interpreter_EvaluateImmediate ( Interpreter * pinterpreter ) { BOOL bImmediate = FALSE ; HRESULT hr = S_OK ; Instruction * pInstruction = NULL ; int size , index ; if ( pinterpreter -> bHasImmediateCode ) { size = pinterpreter -> theInstructionList . size ; for ( index = 0 ; index < size ; index ++ ) { pInstruction = ( Instruction * ) ( pinterpreter -> theInstructionList . solidlist [ index ] ) ; if ( pInstruction -> OpCode == IMMEDIATE ) { bImmediate = TRUE ; } else if ( pInstruction -> OpCode == DEFERRED ) { bImmediate = FALSE ; } if ( bImmediate ) { pinterpreter -> pCurrentInstruction = ( ( Instruction * * ) pinterpreter -> theInstructionList . solidlist ) + index ; hr = Interpreter_EvalInstruction ( pinterpreter ) ; } if ( FAILED ( hr ) ) { break ; } } } if ( ! pinterpreter -> bMainCompleted ) { if ( pinterpreter -> pMainEntry ) { pinterpreter -> pCurrentInstruction = pinterpreter -> pMainEntry ; hr = Interpreter_EvaluateCall ( pinterpreter ) ; } else { hr = E_FAIL ; } if ( SUCCEEDED ( hr ) ) { pinterpreter -> bMainCompleted = TRUE ; } pinterpreter -> bCallCompleted = FALSE ; } pinterpreter -> bReset = FALSE ; return hr ; }
EvaluateImmediate -- This method scans the instruction list and evaluates
any immediate code that may be present.
EvaluateImmediate -- This method scans the instruction list and evaluates any immediate code that may be present .
//Run through all the instructions in the list, only executing those wrapped //by IMMEDIATE and DEFERRED. //Check the current mode //If the current mode is Immediate, then evaluate the instruction //If we failed, then we need to break out of this loop //The "main" function isn't technically immediate code, but it is the well //known entry point into C code, so we call it as part of immediate execution. //Don't call "main" if it has already been called once. //Set the m_bMainCompleted flag //else printf("error: %s\n", pinterpreter->theSymbolTable.name);