Beispiel #1
0
byte *
_CfrTil_UsingToString ( )
{
    Buffer * buffer = Buffer_New ( BUFFER_SIZE ) ;
    byte * b = Buffer_Data ( buffer ) ;
    strcpy ( ( char* ) b, "" ) ;
    _Tree_Map_State_2 ( _Q_->OVT_CfrTil->Namespaces->Lo_List, USING, ( MapSymbolFunction2 ) _Namespace_Symbol_Print, 0, ( int32 ) b ) ;
    b = String_New ( ( byte* ) b, TEMPORARY ) ;
    Buffer_SetAsUnused ( buffer ) ;
    return b ;
}
Beispiel #2
0
void
_CfrTil_SystemState_Print ( int32 pflag )
{
    Buffer * buffer = Buffer_New ( BUFFER_SIZE ) ;
    char * buf = ( char* ) Buffer_Data ( buffer ) ;
    buf = _CfrTil_GetSystemState_String0 ( buf ) ;
    Printf ( ( byte* ) buf ) ;
    buf = _CfrTil_GetSystemState_String1 ( buf ) ;
    Printf ( ( byte* ) buf ) ;
    if ( pflag ) OpenVmTil_Print_DataSizeofInfo ( pflag ) ;
    Buffer_SetAsUnused ( buffer ) ;
}
Beispiel #3
0
void
ReadLine_DeleteChar ( ReadLiner * rl )
{
    Buffer * buffer = Buffer_New ( BUFFER_SIZE ) ;
    byte * b = Buffer_Data ( buffer ) ;
    if ( -- rl->EndPosition < 0 ) rl->EndPosition = 0 ;
    if ( rl->i32_CursorPosition > rl->EndPosition )// shouldn't ever be greater but this will be more robust
    {
        if ( -- rl->i32_CursorPosition < 0 ) _ReadLine_CursorToStart ( rl ) ;
    }
    rl->InputLine [ rl->i32_CursorPosition ] = 0 ;
    // prevent string overwriting itself while coping ...
    strcpy ( ( char* ) b, ( char* ) & rl->InputLine [ rl->i32_CursorPosition + 1 ] ) ;
    if ( rl->i32_CursorPosition < rl->EndPosition ) strcat ( ( char* ) rl->InputLine, ( char* ) b ) ;
    ReadLine_ClearAndShowPadWithCursor ( rl ) ;
    Buffer_SetAsUnused ( buffer ) ;
}
Beispiel #4
0
void
ReadLine_Init ( ReadLiner * rl, ReadLiner_KeyFunction ipf, int32 type )
{
    ReadLine_SetInputLine ( rl, Buffer_Data (_CfrTil_->InputLineB) ) ; // set where the actual memory buffer is located
    ReadLine_RunInit ( rl ) ;
    ReadLiner_SetState ( rl, CHAR_ECHO, true ) ; // this is how we see our input at the command line!
    rl->i32_LineNumber = 0 ;
    rl->InputFile = stdin ;
    rl->OutputFile = stdout ;
    rl->bp_Filename = 0 ;
    rl->FileCharacterNumber = 0 ;
    rl->NormalPrompt = ( byte* ) "<: " ;
    rl->AltPrompt = ( byte* ) ":> " ;
    rl->DebugPrompt = ( byte* ) "dbg=> " ;
    rl->Prompt = rl->NormalPrompt ;
    rl->InputStringOriginal = 0 ;
    if ( ipf ) ReadLine_SetRawInputFunction ( rl, ipf ) ;
}
Beispiel #5
0
void
_CfrTil_PrintNReturnStack ( int32 size )
{
    // Intel SoftwareDevelopersManual-253665.pdf section 6.2 : a push decrements ESP, a pop increments ESP
    // therefore TOS is in lower mem addresses, bottom of stack is in higher memory addresses
    Buffer * b = Buffer_New ( BUFFER_SIZE ) ;
    int32 * esp, i, saveSize = size ;
    byte * buffer = Buffer_Data ( b ) ;
    _CfrTil_WordName_Run ( ( byte* ) "getESP" ) ;
    esp = ( int32 * ) _DataStack_Pop ( ) ;
    if ( esp )
    {
        Printf ( ( byte* ) "\nReturnStack   :%3i  : Esp (ESP) = " UINT_FRMT_0x08 " : Top = " UINT_FRMT_0x08 "", size, ( uint ) esp, ( uint ) esp ) ;
        // print return stack in reverse of usual order first
        for ( i = 0 ; size -- > 0 ; i ++ )
        {
            Word * word = Word_GetFromCodeAddress ( ( byte* ) ( esp [ size ] ) ) ;
            if ( word ) sprintf ( ( char* ) buffer, "< %s.%s >", word->ContainingNamespace->Name, word->Name ) ;
            Printf ( ( byte* ) "\n\t\t    ReturnStack   [ %3d ] < " UINT_FRMT_0x08 " > = " UINT_FRMT_0x08 "\t\t%s", size, ( uint ) & esp [ size ], esp [ size ], word ? ( char* ) buffer : "" ) ;
        }
        _Stack_PrintValues ( "ReturnStack", esp, saveSize ) ;
    }
    Buffer_SetAsUnused ( b ) ;
}
Beispiel #6
0
void
_CfrTil_Init ( CfrTil * cfrTil, Namespace * nss )
{
    uint32 type = CFRTIL ;
    _Q_->OVT_CfrTil = cfrTil ;
    // TODO : organize these buffers and their use 
    cfrTil->OriginalInputLineB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->InputLineB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->SourceCodeSPB = _Buffer_NewPermanent ( SOURCE_CODE_BUFFER_SIZE ) ;
    cfrTil->LambdaCalculusPB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->TokenB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->PrintfB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->Scratch1B = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->StringB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->DebugB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->DebugB1 = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->DebugB2 = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->StringInsertB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->StringInsertB2 = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->StringInsertB3 = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->TabCompletionBuf = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->StringMacroB = _Buffer_NewPermanent ( BUFFER_SIZE ) ;
    cfrTil->OriginalInputLine = Buffer_Data ( cfrTil->OriginalInputLineB ) ;
    cfrTil->SourceCodeScratchPad = Buffer_Data ( cfrTil->SourceCodeSPB ) ;
    cfrTil->LispPrintBuffer = Buffer_Data ( cfrTil->LambdaCalculusPB ) ;
    cfrTil->TokenBuffer = Buffer_Data ( cfrTil->TokenB ) ;
    SetState ( cfrTil, CFRTIL_RUN | OPTIMIZE_ON | INLINE_ON, true ) ;
    if ( _Q_->Verbosity > 2 ) Printf ( ( byte* ) "\nSystem Memory is being reallocated.  " ) ;
    cfrTil->ContextStack = Stack_New ( 256, type ) ;
    cfrTil->ObjectStack = Stack_New ( 1 * K, type ) ;
    cfrTil->DebugStateStack = Stack_New ( 1 * K, type ) ;
    _Stack_Push ( cfrTil->DebugStateStack, 0 ) ;
    cfrTil->TokenList = _dllist_New ( type ) ;
    cfrTil->DebugWordList = _dllist_New ( type ) ;
    _Context_ = cfrTil->Context0 = _Context_New ( cfrTil, type ) ;
    cfrTil->Debugger0 = _Debugger_New ( type ) ; // nb : must be after System_NamespacesInit
    cfrTil->cs_CpuState = CpuState_New ( type ) ;
    if ( cfrTil->SaveDsp && cfrTil->DataStack )// with _Q_->RestartCondition = STOP from Debugger_Stop
    {
        Dsp = cfrTil->SaveDsp ;
    }
    else
    {
        cfrTil->DataStack = Stack_New ( _Q_->DataStackSize, CFRTIL ) ;
        _CfrTil_DataStack_Init ( cfrTil ) ;
    }
    if ( nss )
    {
        cfrTil->Namespaces = nss ;
    }
    else
    {
        _CfrTil_NamespacesInit ( cfrTil ) ;
    }
    cfrTil->StoreWord = _Word_FindAny ( ( byte* ) "store" ) ;
    cfrTil->PokeWord = _Word_FindAny ( ( byte* ) "poke" ) ;
    cfrTil->LispNamespace = Namespace_Find ( ( byte* ) "Lisp" ) ;
    CfrTil_MachineCodePrimitive_AddWords ( ) ; // in any case we need to reinit these for eg. debugger->SaveCpuState (), etc.
    CfrTil_ReadTables_Setup ( cfrTil ) ;
    CfrTil_LexerTables_Setup ( cfrTil ) ;
    cfrTil->LC = 0 ; //LC_New ( ) ;
    //cfrTil->SCA_BlockedIndex = - 1 ;
}