Ablsymt.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. //===========================================================================//
  2. // Copyright (C) Microsoft Corporation. All rights reserved. //
  3. //===========================================================================//
  4. //***************************************************************************
  5. //
  6. // ABLSYMT.CPP
  7. //
  8. //***************************************************************************
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #ifndef ABLGEN_H
  13. #include "ablgen.h"
  14. #endif
  15. #ifndef ABLERR_H
  16. #include "ablerr.h"
  17. #endif
  18. #ifndef ABLSYMT_H
  19. #include "ablsymt.h"
  20. #endif
  21. #ifndef ABLSCAN_H
  22. #include "ablscan.h"
  23. #endif
  24. #ifndef ABLENV_H
  25. #include "ablenv.h"
  26. #endif
  27. //***************************************************************************
  28. //----------
  29. // EXTERNALS
  30. extern long level; // current nesting/scope level
  31. //--------
  32. // GLOBALS
  33. SymTableNodePtr SymTableDisplay[MAX_NESTING_LEVEL];
  34. ABLModulePtr LibrariesUsed[MAX_LIBRARIES_USED];
  35. long NumLibrariesUsed = 0;
  36. //------------------
  37. // Pre-defined types
  38. TypePtr IntegerTypePtr;
  39. TypePtr CharTypePtr;
  40. TypePtr RealTypePtr;
  41. TypePtr BooleanTypePtr;
  42. Type DummyType = { // for erroneous type definitions
  43. 0,
  44. FRM_NONE,
  45. 0,
  46. NULL
  47. };
  48. StandardFunctionInfo FunctionInfoTable[MAX_STANDARD_FUNCTIONS];
  49. //void* FunctionCallbackTable[MAX_STANDARD_FUNCTIONS];
  50. void (*FunctionCallbackTable[MAX_STANDARD_FUNCTIONS])(void);
  51. long NumStandardFunctions = NUM_ABL_ROUTINES;
  52. void execStdRandom (void);
  53. //***************************************************************************
  54. // MISC. (initially were macros)
  55. //***************************************************************************
  56. void searchLocalSymTable (SymTableNodePtr& IdPtr) {
  57. IdPtr = searchSymTable(wordString, SymTableDisplay[level]);
  58. }
  59. //***************************************************************************
  60. inline void searchThisSymTable (SymTableNodePtr& IdPtr, SymTableNodePtr thisTable) {
  61. IdPtr = searchSymTable(wordString, thisTable);
  62. }
  63. //***************************************************************************
  64. void searchAllSymTables (SymTableNodePtr& IdPtr) {
  65. IdPtr = searchSymTableDisplay(wordString);
  66. }
  67. //***************************************************************************
  68. void enterLocalSymTable (SymTableNodePtr& IdPtr) {
  69. IdPtr = enterSymTable(wordString, &SymTableDisplay[level]);
  70. }
  71. //***************************************************************************
  72. inline void enterNameLocalSymTable (SymTableNodePtr& IdPtr, char* name) {
  73. IdPtr = enterSymTable(name, &SymTableDisplay[level]);
  74. }
  75. //***************************************************************************
  76. void searchAndFindAllSymTables (SymTableNodePtr& IdPtr) {
  77. if ((IdPtr = searchSymTableDisplay(wordString)) == NULL) {
  78. syntaxError(ABL_ERR_SYNTAX_UNDEFINED_IDENTIFIER);
  79. IdPtr = enterSymTable(wordString, &SymTableDisplay[level]);
  80. IdPtr->defn.key = DFN_UNDEFINED;
  81. IdPtr->typePtr = &DummyType;
  82. }
  83. }
  84. //***************************************************************************
  85. void searchAndEnterLocalSymTable (SymTableNodePtr& IdPtr) {
  86. if ((IdPtr = searchSymTable(wordString, SymTableDisplay[level])) == NULL)
  87. IdPtr = enterSymTable(wordString, &SymTableDisplay[level]);
  88. else
  89. syntaxError(ABL_ERR_SYNTAX_REDEFINED_IDENTIFIER);
  90. }
  91. //***************************************************************************
  92. void searchAndEnterThisTable (SymTableNodePtr& IdPtr, SymTableNodePtr thisTable) {
  93. if ((IdPtr = searchSymTable(wordString, thisTable)) == NULL)
  94. IdPtr = enterSymTable(wordString, &thisTable);
  95. else
  96. syntaxError(ABL_ERR_SYNTAX_REDEFINED_IDENTIFIER);
  97. }
  98. //***************************************************************************
  99. inline SymTableNodePtr symTableSuccessor (SymTableNodePtr nodeX) {
  100. if (nodeX->right) {
  101. // return the treeMin...
  102. while (nodeX->left)
  103. nodeX = nodeX->left;
  104. return(nodeX);
  105. }
  106. SymTableNodePtr nodeY = nodeX->parent;
  107. while (nodeY && (nodeX == nodeY->right)) {
  108. nodeX = nodeY;
  109. nodeY = nodeY->parent;
  110. }
  111. return(nodeY);
  112. }
  113. //***************************************************************************
  114. // TYPE management routines
  115. //***************************************************************************
  116. TypePtr createType (void) {
  117. TypePtr newType = (TypePtr)ABLSymbolMallocCallback(sizeof(Type));
  118. if (!newType)
  119. ABL_Fatal(0, " ABL: Unable to AblStackHeap->malloc newType ");
  120. newType->numInstances = 1;
  121. newType->form = FRM_NONE;
  122. newType->size = 0;
  123. newType->typeIdPtr = NULL;
  124. return(newType);
  125. }
  126. //---------------------------------------------------------------------------
  127. TypePtr setType (TypePtr type) {
  128. if (type)
  129. type->numInstances++;
  130. return(type);
  131. }
  132. //---------------------------------------------------------------------------
  133. void clearType (TypePtr& type) {
  134. if (type) {
  135. type->numInstances--;
  136. if (type->numInstances == 0) {
  137. ABLSymbolFreeCallback(type);
  138. type = NULL;
  139. }
  140. }
  141. }
  142. //***************************************************************************
  143. // SYMBOL TABLE routines
  144. //***************************************************************************
  145. void recordLibraryUsed (SymTableNodePtr memberNodePtr) {
  146. //------------------------------------------------------------------
  147. // If the library already on our list, then don't bother. Otherwise,
  148. // add it to our list...
  149. ABLModulePtr library = memberNodePtr->library;
  150. for (long i = 0; i < NumLibrariesUsed; i++)
  151. if (LibrariesUsed[i] == library)
  152. return;
  153. //---------------------------------------------------
  154. // New library, so record it if we still have room...
  155. if (NumLibrariesUsed > MAX_LIBRARIES_USED)
  156. ABL_Fatal(0, " ABL: Too many libraries referenced from module ");
  157. LibrariesUsed[NumLibrariesUsed++] = library;
  158. }
  159. //***************************************************************************
  160. SymTableNodePtr searchSymTable (char* name, SymTableNodePtr nodePtr) {
  161. while (nodePtr) {
  162. long compareResult = strcmp(name, nodePtr->name);
  163. if (compareResult == 0)
  164. return(nodePtr);
  165. if (compareResult < 0)
  166. nodePtr = nodePtr->left;
  167. else
  168. nodePtr = nodePtr->right;
  169. }
  170. return(NULL);
  171. }
  172. //***************************************************************************
  173. SymTableNodePtr searchSymTableForFunction (char* name, SymTableNodePtr nodePtr) {
  174. while (nodePtr) {
  175. long compareResult = strcmp(name, nodePtr->name);
  176. if (compareResult == 0) {
  177. if (nodePtr->typePtr == NULL)
  178. if (nodePtr->defn.key == DFN_FUNCTION)
  179. return(nodePtr);
  180. nodePtr = nodePtr->right;
  181. }
  182. else if (compareResult < 0)
  183. nodePtr = nodePtr->left;
  184. else
  185. nodePtr = nodePtr->right;
  186. }
  187. return(NULL);
  188. }
  189. //***************************************************************************
  190. SymTableNodePtr searchSymTableForState (char* name, SymTableNodePtr nodePtr) {
  191. while (nodePtr) {
  192. long compareResult = strcmp(name, nodePtr->name);
  193. if (compareResult == 0) {
  194. if (nodePtr->typePtr == NULL)
  195. if (nodePtr->defn.key == DFN_FUNCTION)
  196. if (nodePtr->defn.info.routine.flags & ROUTINE_FLAG_STATE)
  197. return(nodePtr);
  198. nodePtr = nodePtr->right;
  199. }
  200. else if (compareResult < 0)
  201. nodePtr = nodePtr->left;
  202. else
  203. nodePtr = nodePtr->right;
  204. }
  205. return(NULL);
  206. }
  207. //***************************************************************************
  208. SymTableNodePtr searchSymTableForString (char* name, SymTableNodePtr nodePtr) {
  209. while (nodePtr) {
  210. long compareResult = strcmp(name, nodePtr->name);
  211. if (compareResult == 0) {
  212. if (nodePtr->typePtr)
  213. if (nodePtr->typePtr->form == FRM_ARRAY)
  214. if (nodePtr->typePtr->info.array.elementTypePtr == CharTypePtr)
  215. return(nodePtr);
  216. nodePtr = nodePtr->right;
  217. }
  218. else if (compareResult < 0)
  219. nodePtr = nodePtr->left;
  220. else
  221. nodePtr = nodePtr->right;
  222. }
  223. return(NULL);
  224. }
  225. //***************************************************************************
  226. SymTableNodePtr searchLibrarySymTable (char* name, SymTableNodePtr nodePtr) {
  227. //-------------------------------------------------------------
  228. // Since all libraries are at the symbol display 0-level, we'll
  229. // check the local symbol table of all libraries. WARNING: This
  230. // will find the FIRST instance of a symbol with that name,
  231. // so don't load two libraries with a similarly named function
  232. // or variable, otherwise you may not get the one you want
  233. // unless you explicitly reference the library you want
  234. // (e.g. testLib.fudge, rather than just fudge). This is WAY
  235. // inefficient compared to simply knowing the library we want,
  236. // so any ABL programmer that causes this function to be called
  237. // should be shot --gd 9/29/97
  238. if (nodePtr) {
  239. long compareResult = strcmp(name, nodePtr->name);
  240. if (compareResult == 0)
  241. return(nodePtr);
  242. else {
  243. if (nodePtr->library && (nodePtr->defn.key == DFN_MODULE)) {
  244. SymTableNodePtr memberNodePtr = searchSymTable(name, nodePtr->defn.info.routine.localSymTable);
  245. if (memberNodePtr)
  246. return(memberNodePtr);
  247. }
  248. SymTableNodePtr nodeFoundPtr = searchLibrarySymTable(name, nodePtr->left);
  249. if (nodeFoundPtr)
  250. return(nodeFoundPtr);
  251. nodeFoundPtr = searchLibrarySymTable(name, nodePtr->right);
  252. if (nodeFoundPtr)
  253. return(nodeFoundPtr);
  254. }
  255. }
  256. return(NULL);
  257. }
  258. //***************************************************************************
  259. SymTableNodePtr searchLibrarySymTableDisplay (char* name) {
  260. SymTableNodePtr nodePtr = searchLibrarySymTable(name, SymTableDisplay[0]);
  261. return(nodePtr);
  262. }
  263. //***************************************************************************
  264. SymTableNodePtr searchSymTableDisplay (char* name) {
  265. //---------------------------------------------------------------------
  266. // First check if this is an explicit library reference. If so, we need
  267. // to determine which library and which identifier in that library...
  268. char* separator = strchr(name, '.');
  269. SymTableNodePtr nodePtr = NULL;
  270. if (separator) {
  271. *separator = NULL;
  272. SymTableNodePtr libraryNodePtr = searchSymTable(name, SymTableDisplay[0]);
  273. if (!libraryNodePtr)
  274. return(NULL);
  275. //-------------------------------------
  276. // Now, search for the member symbol...
  277. char* memberName = separator + 1;
  278. SymTableNodePtr memberNodePtr = searchSymTable(memberName, libraryNodePtr->defn.info.routine.localSymTable);
  279. if (memberNodePtr)
  280. recordLibraryUsed(memberNodePtr);
  281. return(memberNodePtr);
  282. }
  283. else {
  284. for (long i = level; i >= 0; i--) {
  285. SymTableNodePtr nodePtr = searchSymTable(name, SymTableDisplay[i]);
  286. if (nodePtr)
  287. return(nodePtr);
  288. }
  289. //------------------------------------------------------------
  290. // We haven't found it, so maybe it's from a library but just
  291. // is not explicitly called with the library name. Since all
  292. // libraries are at the symbol table's 0-level, we'll check
  293. // the local symbol table of all libraries. WARNING: This
  294. // will find the FIRST instance of a symbol with that name,
  295. // so don't load two libraries with a similarly named function
  296. // or variable, otherwise you may not get the one you want
  297. // unless you explicitly reference the library you want
  298. // (e.g. testLib.fudge, rather than just fudge)...
  299. nodePtr = searchLibrarySymTableDisplay(name);
  300. if (nodePtr)
  301. recordLibraryUsed(nodePtr);
  302. }
  303. return(nodePtr);
  304. }
  305. //***************************************************************************
  306. SymTableNodePtr enterSymTable (char* name, SymTableNodePtr* ptrToNodePtr) {
  307. //-------------------------------------
  308. // First, create the new symbol node...
  309. SymTableNodePtr newNode = (SymTableNodePtr)ABLSymbolMallocCallback(sizeof(SymTableNode));
  310. if (!newNode)
  311. ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc symbol ");
  312. newNode->name = (char*)ABLSymbolMallocCallback(strlen(name) + 1);
  313. if (!newNode->name)
  314. ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc symbol name ");
  315. strcpy(newNode->name, name);
  316. newNode->left = NULL;
  317. newNode->parent = NULL;
  318. newNode->right = NULL;
  319. newNode->next = NULL;
  320. newNode->info = NULL;
  321. newNode->defn.key = DFN_UNDEFINED;
  322. newNode->defn.info.data.varType = VAR_TYPE_NORMAL;
  323. newNode->defn.info.data.offset = 0;
  324. newNode->typePtr = NULL;
  325. newNode->level = (unsigned char)level;
  326. newNode->labelIndex = 0;
  327. //-------------------------------------
  328. // Find where to put this new symbol...
  329. SymTableNodePtr curNode = *ptrToNodePtr;
  330. SymTableNodePtr parentNode = NULL;
  331. while (curNode) {
  332. if (strcmp(name, curNode->name) < 0)
  333. ptrToNodePtr = &(curNode->left);
  334. else
  335. ptrToNodePtr = &(curNode->right);
  336. parentNode = curNode;
  337. curNode = *ptrToNodePtr;
  338. }
  339. newNode->parent = parentNode;
  340. *ptrToNodePtr = newNode;
  341. return(newNode);
  342. }
  343. //***************************************************************************
  344. SymTableNodePtr insertSymTable (SymTableNodePtr* tableRoot, SymTableNodePtr newNode) {
  345. newNode->left = NULL;
  346. newNode->parent = NULL;
  347. newNode->right = NULL;
  348. //------------------------------------
  349. // Find where to insert this symbol...
  350. SymTableNodePtr curNode = *tableRoot;
  351. SymTableNodePtr parentNode = NULL;
  352. while (curNode) {
  353. if (strcmp(newNode->name, curNode->name) < 0)
  354. tableRoot = &(curNode->left);
  355. else
  356. tableRoot = &(curNode->right);
  357. parentNode = curNode;
  358. curNode = *tableRoot;
  359. }
  360. newNode->parent = parentNode;
  361. *tableRoot = newNode;
  362. return(newNode);
  363. }
  364. //***************************************************************************
  365. SymTableNodePtr extractSymTable (SymTableNodePtr* tableRoot, SymTableNodePtr nodeKill) {
  366. //------------------------------------------------------------------------
  367. // NOTE: While this routine extracts a node from the symbol table,
  368. // it does not account for other nodes in the table that may be pointing
  369. // to the now-extracted node. Currently, this is not a problem as this
  370. // routine is really just used to extract the module's Identifier at level
  371. // 0 in the SymTable Display. Do we want to eliminate the use of the
  372. // parent pointer, and just hardcode something that may be more efficient
  373. // for this level-0 special case?
  374. SymTableNodePtr nodeX = NULL;
  375. SymTableNodePtr nodeY = NULL;
  376. if ((nodeKill->left == NULL) || (nodeKill->right == NULL))
  377. nodeY = nodeKill;
  378. else
  379. nodeY = symTableSuccessor(nodeKill);
  380. if (nodeY->left)
  381. nodeX = nodeY->left;
  382. else
  383. nodeX = nodeY->right;
  384. if (nodeX)
  385. nodeX->parent = nodeY->parent;
  386. if (nodeY->parent == NULL)
  387. *tableRoot = nodeX;
  388. else if (nodeY == nodeY->parent->left)
  389. nodeY->parent->left = nodeX;
  390. else
  391. nodeY->parent->right = nodeX;
  392. if (nodeY != nodeKill) {
  393. //--------------------------------------
  394. // Copy y data to nodeKill's position...
  395. nodeKill->next = nodeY->next;
  396. nodeKill->name = nodeY->name;
  397. nodeKill->info = nodeY->info;
  398. memcpy(&nodeKill->defn, &nodeY->defn, sizeof(Definition));
  399. nodeKill->typePtr = nodeY->typePtr;
  400. nodeKill->level = nodeY->level;
  401. nodeKill->labelIndex = nodeY->labelIndex;
  402. }
  403. return(nodeY);
  404. }
  405. //***************************************************************************
  406. void enterStandardRoutine (char* name, long routineKey, bool isOrder, char* paramList, char* returnType, void (*callback)(void)) {
  407. long tableIndex = routineKey;
  408. if (tableIndex == -1) {
  409. if (NumStandardFunctions == MAX_STANDARD_FUNCTIONS)
  410. ABL_Fatal(0, " ABL.enterStandardRoutine: Too Many Standard Functions ");
  411. tableIndex = NumStandardFunctions++;
  412. }
  413. SymTableNodePtr routineIdPtr;
  414. enterNameLocalSymTable(routineIdPtr, name);
  415. routineIdPtr->defn.key = DFN_FUNCTION;
  416. routineIdPtr->defn.info.routine.key = (RoutineKey)tableIndex;
  417. routineIdPtr->defn.info.routine.flags = isOrder ? ROUTINE_FLAG_ORDER : 0;
  418. routineIdPtr->defn.info.routine.params = NULL;
  419. routineIdPtr->defn.info.routine.localSymTable = NULL;
  420. routineIdPtr->library = NULL;
  421. routineIdPtr->typePtr = NULL;
  422. FunctionInfoTable[tableIndex].numParams = 0;
  423. if (paramList) {
  424. FunctionInfoTable[tableIndex].numParams = strlen(paramList);
  425. if (FunctionInfoTable[tableIndex].numParams > MAX_FUNCTION_PARAMS)
  426. ABL_Fatal(0, " ABL.enterStandardRoutine: Too Many Standard Function Params ");
  427. for (long i = 0; i < FunctionInfoTable[tableIndex].numParams; i++)
  428. switch (paramList[i]) {
  429. case '?':
  430. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_ANYTHING;
  431. break;
  432. case 'c':
  433. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_CHAR;
  434. break;
  435. case 'i':
  436. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_INTEGER;
  437. break;
  438. case 'r':
  439. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_REAL;
  440. break;
  441. case 'b':
  442. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_BOOLEAN;
  443. break;
  444. case '*':
  445. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_INTEGER_REAL;
  446. break;
  447. case 'C':
  448. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_CHAR_ARRAY;
  449. break;
  450. case 'I':
  451. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_INTEGER_ARRAY;
  452. break;
  453. case 'R':
  454. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_REAL_ARRAY;
  455. break;
  456. case 'B':
  457. FunctionInfoTable[tableIndex].params[i] = PARAM_TYPE_BOOLEAN_ARRAY;
  458. break;
  459. default: {
  460. char err[255];
  461. sprintf(err, " ABL.enterStandardRoutine: bad param type (%c) for (%s)", paramList[i], name);
  462. ABL_Fatal(0, err);
  463. }
  464. }
  465. }
  466. FunctionInfoTable[tableIndex].returnType = RETURN_TYPE_NONE;
  467. if (returnType)
  468. switch (returnType[0]) {
  469. //case 'c':
  470. // FunctionInfoTable[NumStandardFunctions].returnType = RETURN_TYPE_CHAR;
  471. // break;
  472. case 'i':
  473. FunctionInfoTable[tableIndex].returnType = RETURN_TYPE_INTEGER;
  474. break;
  475. case 'r':
  476. FunctionInfoTable[tableIndex].returnType = RETURN_TYPE_REAL;
  477. break;
  478. case 'b':
  479. FunctionInfoTable[tableIndex].returnType = RETURN_TYPE_BOOLEAN;
  480. break;
  481. default: {
  482. char err[255];
  483. sprintf(err, " ABL.enterStandardRoutine: bad return type for (%s)", name);
  484. ABL_Fatal(0, err);
  485. }
  486. }
  487. FunctionCallbackTable[tableIndex] = callback;
  488. }
  489. //***************************************************************************
  490. void enterScope (SymTableNodePtr symTableRoot) {
  491. if (++level >= MAX_NESTING_LEVEL)
  492. syntaxError(ABL_ERR_SYNTAX_NESTING_TOO_DEEP);
  493. SymTableDisplay[level] = symTableRoot;
  494. }
  495. //***************************************************************************
  496. SymTableNodePtr exitScope (void) {
  497. return(SymTableDisplay[level--]);
  498. }
  499. //***************************************************************************
  500. void initStandardRoutines (void);
  501. void initSymTable (void) {
  502. //---------------------------------
  503. // Init the level-0 symbol table...
  504. SymTableDisplay[0] = NULL;
  505. //----------------------------------------------------------------------
  506. // Set up the basic variable types as identifiers in the symbol table...
  507. SymTableNodePtr integerIdPtr;
  508. enterNameLocalSymTable(integerIdPtr, "integer");
  509. SymTableNodePtr charIdPtr;
  510. enterNameLocalSymTable(charIdPtr, "char");
  511. SymTableNodePtr realIdPtr;
  512. enterNameLocalSymTable(realIdPtr, "real");
  513. SymTableNodePtr booleanIdPtr;
  514. enterNameLocalSymTable(booleanIdPtr, "boolean");
  515. SymTableNodePtr falseIdPtr;
  516. enterNameLocalSymTable(falseIdPtr, "false");
  517. SymTableNodePtr trueIdPtr;
  518. enterNameLocalSymTable(trueIdPtr, "true");
  519. //------------------------------------------------------------------
  520. // Now, create the basic variable TYPEs, and point their identifiers
  521. // to their proper type definition...
  522. IntegerTypePtr = createType();
  523. if (!IntegerTypePtr)
  524. ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Integer Type ");
  525. CharTypePtr = createType();
  526. if (!CharTypePtr)
  527. ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Char Type ");
  528. RealTypePtr = createType();
  529. if (!RealTypePtr)
  530. ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Real Type ");
  531. BooleanTypePtr = createType();
  532. if (!BooleanTypePtr)
  533. ABL_Fatal(0, " ABL: Unable to AblSymTableHeap->malloc Boolean Type ");
  534. integerIdPtr->defn.key = DFN_TYPE;
  535. integerIdPtr->typePtr = IntegerTypePtr;
  536. IntegerTypePtr->form = FRM_SCALAR;
  537. IntegerTypePtr->size = sizeof(long);
  538. IntegerTypePtr->typeIdPtr = integerIdPtr;
  539. charIdPtr->defn.key = DFN_TYPE;
  540. charIdPtr->typePtr = CharTypePtr;
  541. CharTypePtr->form = FRM_SCALAR;
  542. CharTypePtr->size = sizeof(char);
  543. CharTypePtr->typeIdPtr = charIdPtr;
  544. realIdPtr->defn.key = DFN_TYPE;
  545. realIdPtr->typePtr = RealTypePtr;
  546. RealTypePtr->form = FRM_SCALAR;
  547. RealTypePtr->size = sizeof(float);
  548. RealTypePtr->typeIdPtr = realIdPtr;
  549. booleanIdPtr->defn.key = DFN_TYPE;
  550. booleanIdPtr->typePtr = BooleanTypePtr;
  551. BooleanTypePtr->form = FRM_ENUM;
  552. BooleanTypePtr->size = sizeof(long);
  553. BooleanTypePtr->typeIdPtr = booleanIdPtr;
  554. //----------------------------------------------------
  555. // Set up the FALSE identifier for the boolean type...
  556. BooleanTypePtr->info.enumeration.max = 1;
  557. ((TypePtr)(booleanIdPtr->typePtr))->info.enumeration.constIdPtr = falseIdPtr;
  558. falseIdPtr->defn.key = DFN_CONST;
  559. falseIdPtr->defn.info.constant.value.integer = 0;
  560. falseIdPtr->typePtr = BooleanTypePtr;
  561. //----------------------------------------------------
  562. // Set up the TRUE identifier for the boolean type...
  563. falseIdPtr->next = trueIdPtr;
  564. trueIdPtr->defn.key = DFN_CONST;
  565. trueIdPtr->defn.info.constant.value.integer = 1;
  566. trueIdPtr->typePtr = BooleanTypePtr;
  567. //-------------------------------------------
  568. // Set up the standard, built-in functions...
  569. //(char* name, long routineKey, bool isOrder, char* paramList, char* returnType, void* callback);
  570. enterStandardRoutine("return", RTN_RETURN, false, NULL, NULL, NULL);
  571. enterStandardRoutine("print", RTN_PRINT, false, NULL, NULL, NULL);
  572. enterStandardRoutine("concat", RTN_CONCAT, false, NULL, NULL, NULL);
  573. enterStandardRoutine("getstatehandle", RTN_GET_STATE_HANDLE, false, NULL, NULL, NULL);
  574. //-----------------------------------
  575. // Honor Bound-specific extensions...
  576. //-----------------------------------
  577. initStandardRoutines();
  578. }
  579. //***************************************************************************