void initSymTable (void) { //--------------------------------- // Init the level-0 symbol table... SymTableDisplay[0] = NULL; //---------------------------------------------------------------------- // Set up the basic variable types as identifiers in the symbol table... SymTableNodePtr integerIdPtr; enterNameLocalSymTable(integerIdPtr, "integer"); SymTableNodePtr charIdPtr; enterNameLocalSymTable(charIdPtr, "char"); SymTableNodePtr realIdPtr; enterNameLocalSymTable(realIdPtr, "real"); SymTableNodePtr booleanIdPtr; enterNameLocalSymTable(booleanIdPtr, "boolean"); SymTableNodePtr falseIdPtr; enterNameLocalSymTable(falseIdPtr, "false"); SymTableNodePtr trueIdPtr; enterNameLocalSymTable(trueIdPtr, "true"); //------------------------------------------------------------------ // Now, create the basic variable TYPEs, and point their identifiers // to their proper type definition... IntegerTypePtr = createType(); if (!IntegerTypePtr) ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Integer Type "); CharTypePtr = createType(); if (!CharTypePtr) ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Char Type "); RealTypePtr = createType(); if (!RealTypePtr) ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Real Type "); BooleanTypePtr = createType(); if (!BooleanTypePtr) ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Boolean Type "); integerIdPtr->defn.key = DFN_TYPE; integerIdPtr->typePtr = IntegerTypePtr; IntegerTypePtr->form = FRM_SCALAR; IntegerTypePtr->size = sizeof(long); IntegerTypePtr->typeIdPtr = integerIdPtr; charIdPtr->defn.key = DFN_TYPE; charIdPtr->typePtr = CharTypePtr; CharTypePtr->form = FRM_SCALAR; CharTypePtr->size = sizeof(char); CharTypePtr->typeIdPtr = charIdPtr; realIdPtr->defn.key = DFN_TYPE; realIdPtr->typePtr = RealTypePtr; RealTypePtr->form = FRM_SCALAR; RealTypePtr->size = sizeof(float); RealTypePtr->typeIdPtr = realIdPtr; booleanIdPtr->defn.key = DFN_TYPE; booleanIdPtr->typePtr = BooleanTypePtr; BooleanTypePtr->form = FRM_ENUM; BooleanTypePtr->size = sizeof(long); BooleanTypePtr->typeIdPtr = booleanIdPtr; //---------------------------------------------------- // Set up the FALSE identifier for the boolean type... BooleanTypePtr->info.enumeration.max = 1; ((TypePtr)(booleanIdPtr->typePtr))->info.enumeration.constIdPtr = falseIdPtr; falseIdPtr->defn.key = DFN_CONST; falseIdPtr->defn.info.constant.value.integer = 0; falseIdPtr->typePtr = BooleanTypePtr; //---------------------------------------------------- // Set up the TRUE identifier for the boolean type... falseIdPtr->next = trueIdPtr; trueIdPtr->defn.key = DFN_CONST; trueIdPtr->defn.info.constant.value.integer = 1; trueIdPtr->typePtr = BooleanTypePtr; //------------------------------------------- // Set up the standard, built-in functions... //(char* name, long routineKey, bool isOrder, char* paramList, char* returnType, void* callback); enterStandardRoutine("return", RTN_RETURN, false, NULL, NULL, NULL); enterStandardRoutine("print", RTN_PRINT, false, NULL, NULL, NULL); enterStandardRoutine("concat", RTN_CONCAT, false, NULL, NULL, NULL); enterStandardRoutine("getstatehandle", RTN_GET_STATE_HANDLE, false, NULL, NULL, NULL); //----------------------------------- // Honor Bound-specific extensions... //----------------------------------- initStandardRoutines(); }
void initStandardRoutines (void) { //------------------------------------------------------------- // Fatal and Assert will have hardcoded keys so we can look for // 'em in the rest of the ABL code (example: ignore asserts if // the assert_off option has been set). enterStandardRoutine("fatal", RTN_FATAL, false, "iC", NULL, execStdFatal); enterStandardRoutine("assert", RTN_ASSERT, false, "biC", NULL, execStdAssert); enterStandardRoutine("getstatehandle", RTN_GET_STATE_HANDLE, false, "C", "i", execStdGetStateHandle); enterStandardRoutine("getcurrentstatehandle", -1, false, NULL, "i", execStdGetCurrentStateHandle); enterStandardRoutine("abs", -1, false, "*", "r", execStdAbs); enterStandardRoutine("sqrt", -1, false, "*", "r", execStdSqrt); enterStandardRoutine("round", -1, false, "r", "i", execStdRound); enterStandardRoutine("trunc", -1, false, "r", "i", execStdTrunc); enterStandardRoutine("random", -1, false, "i", "i", execStdRandom); enterStandardRoutine("seedrandom", -1, false, "i", NULL, execStdSeedRandom); enterStandardRoutine("setmaxloops", -1, false, "i", NULL, execStdSetMaxLoops); enterStandardRoutine("fileopen", -1, false, "C", "i", execStdFileOpen); enterStandardRoutine("filewrite", -1, false, "iC", NULL, execStdFileWrite); enterStandardRoutine("fileclose", -1, false, "i", NULL, execStdFileClose); enterStandardRoutine("getmodule", -1, false, "CC", "i", execStdGetModule); enterStandardRoutine("resetorders", -1, false, "i", NULL, execStdResetOrders); enterStandardRoutine("setstate", -1, false, "i", NULL, execStdSetState); enterStandardRoutine("getfunctionhandle", -1, false, "C", "i", execStdGetFunctionHandle); enterStandardRoutine("callfunction", -1, false, "i", NULL, execStdCallFunction); enterStandardRoutine("setflag", -1, false, "iib", "i", execStdSetFlag); enterStandardRoutine("getflag", -1, false, "ii", "b", execStdGetFlag); }