/* include one of a number of predefined libraries, or perhaps an actual file */ void IncludeFile(char *FileName) { struct IncludeLibrary *LInclude; /* scan for the include file name to see if it's in our list of predefined includes */ for (LInclude = IncludeLibList; LInclude != NULL; LInclude = LInclude->NextLib) { if (strcmp(LInclude->IncludeName, FileName) == 0) { /* found it - protect against multiple inclusion */ if (!VariableDefined(FileName)) { VariableDefine(NULL, FileName, NULL, &VoidType, FALSE); /* run an extra startup function if there is one */ if (LInclude->SetupFunction != NULL) (*LInclude->SetupFunction)(); /* parse the setup C source code - may define types etc. */ if (LInclude->SetupCSource != NULL) PicocParse(FileName, LInclude->SetupCSource, strlen(LInclude->SetupCSource), TRUE, TRUE, FALSE); /* set up the library functions */ if (LInclude->FuncList != NULL) LibraryAdd(&GlobalTable, FileName, LInclude->FuncList); } return; } } /* not a predefined file, read a real file */ PicocPlatformScanFile(FileName); }
/* initialise everything */ void PicocInitialise(Picoc *pc, int StackSize) { memset(pc, '\0', sizeof(*pc)); PlatformInit(pc); BasicIOInit(pc); HeapInit(pc, StackSize); TableInit(pc); VariableInit(pc); LexInit(pc); TypeInit(pc); #ifndef NO_HASH_INCLUDE IncludeInit(pc); #endif LibraryInit(pc); #ifdef BUILTIN_MINI_STDLIB LibraryAdd(pc, &pc->GlobalTable, "c library", &CLibrary[0]); CLibraryInit(pc); #endif PlatformLibraryInit(pc); DebugInit(pc); }
/* initialise everything */ void PicocInitialise(int StackSize) { BasicIOInit(); HeapInit(StackSize); TableInit(); VariableInit(); LexInit(); TypeInit(); #ifndef NO_HASH_INCLUDE IncludeInit(); #endif LibraryInit(); #ifdef BUILTIN_MINI_STDLIB LibraryAdd(&GlobalTable, "c library", &CLibrary[0]); CLibraryInit(); #endif PlatformLibraryInit(); }
/* include one of a number of predefined libraries, or perhaps an actual file */ void IncludeFile(Picoc *pc, char *FileName) { struct IncludeLibrary *LInclude; struct InteractiveState_Struct OldState; /* scan for the include file name to see if it's in our list of predefined includes */ for (LInclude = pc->IncludeLibList; LInclude != NULL; LInclude = LInclude->NextLib) { if (strcmp(LInclude->IncludeName, FileName) == 0) { /* found it - protect against multiple inclusion */ if (!VariableDefined(pc, FileName)) { VariableDefine(pc, NULL, FileName, NULL, &pc->VoidType, FALSE); /* run an extra startup function if there is one */ if (LInclude->SetupFunction != NULL) (*LInclude->SetupFunction)(pc); /* parse the setup C source code - may define types etc. */ if (LInclude->SetupCSource != NULL) PicocParse(pc, FileName, LInclude->SetupCSource, (int) strlen(LInclude->SetupCSource), TRUE, TRUE, FALSE, FALSE); /* set up the library functions */ if (LInclude->FuncList != NULL) LibraryAdd(pc, &pc->GlobalTable, FileName, LInclude->FuncList); } return; } } /* not a predefined file, read a real file */ OldState = pc->InteractiveState; memset(&pc->InteractiveState, 0, sizeof(pc->InteractiveState)); PicocPlatformScanFile(pc, FileName); pc->InteractiveState = OldState; }
void PlatformLibraryInit() { LibraryAdd(&GlobalTable, "platform library", &PlatformLibrary); }