diff options
Diffstat (limited to 'misc/pascal')
55 files changed, 1556 insertions, 1556 deletions
diff --git a/misc/pascal/ChangeLog b/misc/pascal/ChangeLog index 39d9c413c..8f081d012 100644 --- a/misc/pascal/ChangeLog +++ b/misc/pascal/ChangeLog @@ -26,7 +26,7 @@ pascal-3.0 2010-05-15 Gregory Nutt <gnutt@nuttx.org> * nuttx/: The Pascal add-on module now installs and builds under the apps/interpreters directory. This means that the pascal-3.0 module is - incompatible with will all releases of NuttX prior to nuttx-6.0 where the + incompatible with will all releases of NuttX prior to nuttx-6.0 where the apps/ module was introduced. pascal-3.1 2012-xx-xx Gregory Nutt <gnutt@nuttx.org> diff --git a/misc/pascal/Make.defs b/misc/pascal/Make.defs index 0348bf4d3..a1115b3c7 100644 --- a/misc/pascal/Make.defs +++ b/misc/pascal/Make.defs @@ -43,7 +43,7 @@ AR = /usr/bin/ar RM = /bin/rm -f -DEFINES = +DEFINES = INCLUDES = -I. -I$(INCDIR) CFLAGS = -Wall -g $(DEFINES) $(INCLUDES) LDFLAGS = -L$(LIBDIR) diff --git a/misc/pascal/doc/PascalGrammar.txt b/misc/pascal/doc/PascalGrammar.txt index 8049f536f..54b1edf4b 100644 --- a/misc/pascal/doc/PascalGrammar.txt +++ b/misc/pascal/doc/PascalGrammar.txt @@ -82,7 +82,7 @@ The start symbol for this grammar is pascal. constant-definition-group | type-definition-group | variable-declaration-group | - function-declaration | + function-declaration | procedure-declaration digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' @@ -180,7 +180,7 @@ The start symbol for this grammar is pascal. goto-statement = 'goto' label hex-digit = digit | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' - + hex-digit-sequence = hex-digit { hex-digit } hexadecimal-integer = '$' hex-digit-sequence diff --git a/misc/pascal/doc/PascalNotes.txt b/misc/pascal/doc/PascalNotes.txt index 360986c59..dc7ca8df4 100644 --- a/misc/pascal/doc/PascalNotes.txt +++ b/misc/pascal/doc/PascalNotes.txt @@ -1,135 +1,135 @@ - AS OF 1/18/04
-
-TYPES
-- Only types INT, BOOLEAN, CHAR, REAL, SCALAR, SUBRANGE, RECORD and SET
- implemented
- - No PACKED types (actually, types are always packed).
- - FILE OF and TEXT types partially supported
- - Not supported in TYPE block
- - TEXT is defined as FILE OF CHAR vs PACKED FILE OF CHAR
- - No function returning FILE OF; No FILE OF
- procedure/function arguments
- - Only PROGRAM arguments can be declared type FILE OF
- - Only one file identifier per FILE OF declaration in type
- block.
- - SET is limit to 16/32 (# bits in int) adjacent elements
- - Expressions are not strongly typed across different SCALAR types
- (see exprEnum in expr.h)
- - In RECORD CASE, there is no verification that the type of the tag
- is consistent with a case selector; the is check if the case selector
- constants are of the same type as the tag type identifier.
-
-- No range checks on array indices
-- Pointers
- - Can't pass pointers as VAR parameters
- - No pointer functions ??
- - No pointers to pointers
-
-STATEMENTS
-- The following statements not implemented:
- - No PROCEDURE call with PROCEDUREs or FUNCTIONs as parameters
-- The following statements are only partially implemented
- - WITH statements cannot be nested.
- - Cannot reference "up the chain" in WITH statements. Eg.
- suppose RECORD "a" contains RECORD "b" which contains "c" and
- that RECORD "a" also contains "d" so that we could write
- a.b.c OR a.d
- Then the following should work but is not yet supported:
- WITH a DO
- BEGIN
- WITH b DO
- BEGIN
- c := ..
- d := .. <== SHOULD WORK!!!
- - GOTO only partially implemented -- no stack corrections
- for GOTOs between loops, blocks, etc. Use is DANGEROUS.
-
-STANDARD PROCEDURES and FUNCTIONS
-- The following statement procedures/functions not implemented:
- - GET, PUT, PACK, UNPACK, NEW
- - TBD
-- No fieldwidth colon operator on WRITE arguments
-
-Extended Pascal Features
-- Type STRING is partially implemented.
-- PACKED ARRAY[..] OF CHAR is not a a string.
-
-NON-standard Pascal extensions/differences
-
-TYPES
-- ARRAY index type is integer constant specifying size of array
-- Hexadecimal constants.
-- INPUT and OUTPUT parameters in PROGRAM statement are
- predeclared and optional.
-
-OPERATORS
-- Binary shift operators -- << and >> like in C
-- '#', "<>", and "><" are all equivalent
-
-COMPILER PSEUDO-OPERATIONS
-- INCLUDE
-
-STATEMENTS
-- CASE statement expects integer expression for the switch
- variable
-- ELSE in CASE statement
-
-EXPRESSIONS
-
-- Assumes sizeof(pointer) == sizeof(integer)
-
-TODO LIST
-
-o BUGS
-- Implement PUT and GET.
-- In FUNC/PROC calls, if simpleExpression fails to find a parameter (eg.,
- proc (,,), no error is detected.
-- Type FILE OF is totally busted -- fix it
-- Need to get max string size into stack somehow. Runtime routines like
- strcat and strcatc need to know how big the string storage space is.
-- Need logic to release string stack used by actual parameters after
- function/procedure call.
-- Can't declare new parameters / variables with same name as another
- variable at higher stock. Tokenizer does not return tIDENT.
-- There are lots of cases where the string stack is not being managed
- correctly (e.g., usesSection()).
-- Redirection of input and output is not supported (e.g. see setting of
- input and output in CONST section of pageutils.pas).
-
-o IMPROVEMENTS
-- In PTKN, verify that string stack does not overflow when
- character added.
-- Option to turn on listing
-- Option to interleave assembly language with listing
-- Option to select string stack size (or let it grow dynamically)
-- Option to select symbol table size (or let it grow dynamically)
-- List file should only be produced if option provided.
-- Provide instrumentation to use the line number data in the
- object files. In debugger, display source line. Allow stepping
- from source line to source line.
-- Optimizer needs to be incorporated into compiler.
-- arrayIndex needs to conform with Pascal standard.
-- Need to have 32-bit integers and address
-- Translation to register model
-- Native code translator
-- Linker and support multiple source files
-- Runtime package
-- Full extended pascal string support
-- Other things from extended pascal: 'list of' 'uses' 'unit'
-- Need to optimize out JMP .+1
-- For compatibility, let 'packed array [n..m] of char;' be equivalent to
- string.
-- Need to review all uses of string stack for identifiers and strings
- that get discarded. Probably should get a get infrastructure.
-- Add 16-bit word type
-
-o ISSUES
-- What happens in TYPE block if type is sTYPE or sFILE_OF? Need
- to re-think all typing. Maybe replace sTYPE and sFILE_OF with
- sINT_TYPE, sINT_ARRAY_TYPE, ..., sFILE_OF_INT,
- sFILE_OF_INT_ARRAY, etc.
-- Is it really necessary or meaningful to allocate dstack for
- file buffers.
-- Revisit procedure call logic in pexec.c & pdbg.c. First stack parameter
- is calculated but never used.
-- Decide what to do about type filename in tests/src/cgimail.pas
+ AS OF 1/18/04 + +TYPES +- Only types INT, BOOLEAN, CHAR, REAL, SCALAR, SUBRANGE, RECORD and SET + implemented + - No PACKED types (actually, types are always packed). + - FILE OF and TEXT types partially supported + - Not supported in TYPE block + - TEXT is defined as FILE OF CHAR vs PACKED FILE OF CHAR + - No function returning FILE OF; No FILE OF + procedure/function arguments + - Only PROGRAM arguments can be declared type FILE OF + - Only one file identifier per FILE OF declaration in type + block. + - SET is limit to 16/32 (# bits in int) adjacent elements + - Expressions are not strongly typed across different SCALAR types + (see exprEnum in expr.h) + - In RECORD CASE, there is no verification that the type of the tag + is consistent with a case selector; the is check if the case selector + constants are of the same type as the tag type identifier. + +- No range checks on array indices +- Pointers + - Can't pass pointers as VAR parameters + - No pointer functions ?? + - No pointers to pointers + +STATEMENTS +- The following statements not implemented: + - No PROCEDURE call with PROCEDUREs or FUNCTIONs as parameters +- The following statements are only partially implemented + - WITH statements cannot be nested. + - Cannot reference "up the chain" in WITH statements. Eg. + suppose RECORD "a" contains RECORD "b" which contains "c" and + that RECORD "a" also contains "d" so that we could write + a.b.c OR a.d + Then the following should work but is not yet supported: + WITH a DO + BEGIN + WITH b DO + BEGIN + c := .. + d := .. <== SHOULD WORK!!! + - GOTO only partially implemented -- no stack corrections + for GOTOs between loops, blocks, etc. Use is DANGEROUS. + +STANDARD PROCEDURES and FUNCTIONS +- The following statement procedures/functions not implemented: + - GET, PUT, PACK, UNPACK, NEW + - TBD +- No fieldwidth colon operator on WRITE arguments + +Extended Pascal Features +- Type STRING is partially implemented. +- PACKED ARRAY[..] OF CHAR is not a a string. + +NON-standard Pascal extensions/differences + +TYPES +- ARRAY index type is integer constant specifying size of array +- Hexadecimal constants. +- INPUT and OUTPUT parameters in PROGRAM statement are + predeclared and optional. + +OPERATORS +- Binary shift operators -- << and >> like in C +- '#', "<>", and "><" are all equivalent + +COMPILER PSEUDO-OPERATIONS +- INCLUDE + +STATEMENTS +- CASE statement expects integer expression for the switch + variable +- ELSE in CASE statement + +EXPRESSIONS + +- Assumes sizeof(pointer) == sizeof(integer) + +TODO LIST + +o BUGS +- Implement PUT and GET. +- In FUNC/PROC calls, if simpleExpression fails to find a parameter (eg., + proc (,,), no error is detected. +- Type FILE OF is totally busted -- fix it +- Need to get max string size into stack somehow. Runtime routines like + strcat and strcatc need to know how big the string storage space is. +- Need logic to release string stack used by actual parameters after + function/procedure call. +- Can't declare new parameters / variables with same name as another + variable at higher stock. Tokenizer does not return tIDENT. +- There are lots of cases where the string stack is not being managed + correctly (e.g., usesSection()). +- Redirection of input and output is not supported (e.g. see setting of + input and output in CONST section of pageutils.pas). + +o IMPROVEMENTS +- In PTKN, verify that string stack does not overflow when + character added. +- Option to turn on listing +- Option to interleave assembly language with listing +- Option to select string stack size (or let it grow dynamically) +- Option to select symbol table size (or let it grow dynamically) +- List file should only be produced if option provided. +- Provide instrumentation to use the line number data in the + object files. In debugger, display source line. Allow stepping + from source line to source line. +- Optimizer needs to be incorporated into compiler. +- arrayIndex needs to conform with Pascal standard. +- Need to have 32-bit integers and address +- Translation to register model +- Native code translator +- Linker and support multiple source files +- Runtime package +- Full extended pascal string support +- Other things from extended pascal: 'list of' 'uses' 'unit' +- Need to optimize out JMP .+1 +- For compatibility, let 'packed array [n..m] of char;' be equivalent to + string. +- Need to review all uses of string stack for identifiers and strings + that get discarded. Probably should get a get infrastructure. +- Add 16-bit word type + +o ISSUES +- What happens in TYPE block if type is sTYPE or sFILE_OF? Need + to re-think all typing. Maybe replace sTYPE and sFILE_OF with + sINT_TYPE, sINT_ARRAY_TYPE, ..., sFILE_OF_INT, + sFILE_OF_INT_ARRAY, etc. +- Is it really necessary or meaningful to allocate dstack for + file buffers. +- Revisit procedure call logic in pexec.c & pdbg.c. First stack parameter + is calculated but never used. +- Decide what to do about type filename in tests/src/cgimail.pas diff --git a/misc/pascal/include/perr.h b/misc/pascal/include/perr.h index a272ce89c..1e3fe42dc 100644 --- a/misc/pascal/include/perr.h +++ b/misc/pascal/include/perr.h @@ -46,7 +46,7 @@ /*********************************************************************** * Public Function Prototypes ***********************************************************************/ - + extern void errmsg(char *fmt, ...); extern void warn(uint16_t errcode); extern void error(uint16_t errcode); diff --git a/misc/pascal/include/podefs.h b/misc/pascal/include/podefs.h index fc25d62a4..a301b7956 100644 --- a/misc/pascal/include/podefs.h +++ b/misc/pascal/include/podefs.h @@ -170,7 +170,7 @@ enum pcode_e /* Store: arg1 = level; arg2 = signed frame offset */ - opSTS, opSTSB, opSTSM, + opSTS, opSTSB, opSTSM, /* Load Indexed: arg1 = level; arg2 = signed frame offset */ diff --git a/misc/pascal/include/poff.h b/misc/pascal/include/poff.h index 7cc33b290..00cc5c8b0 100644 --- a/misc/pascal/include/poff.h +++ b/misc/pascal/include/poff.h @@ -256,7 +256,7 @@ struct poffSectionHeader_s /* sh_name is an offset into the string table section data. * It refers to a name associated with section. */ - + uint32_t sh_name; /* If the section is loaded into memory (SHF_ALLOC), then this @@ -330,7 +330,7 @@ struct poffSymbol_s /* st_name is an offset into the string table section data. * It refers to a name associated with symbol. */ - + uint32_t st_name; /* st_value is the value associated with symbol. For defined data diff --git a/misc/pascal/include/pofflib.h b/misc/pascal/include/pofflib.h index 3547fca60..0f547d9ae 100644 --- a/misc/pascal/include/pofflib.h +++ b/misc/pascal/include/pofflib.h @@ -90,7 +90,7 @@ struct poffLibSymbol_s /* name is a reference to the symbol name in the string table * section data. */ - + const char *name; /* value is the value associated with symbol. For defined data diff --git a/misc/pascal/include/pxdefs.h b/misc/pascal/include/pxdefs.h index 8c9ab834d..66eedd609 100644 --- a/misc/pascal/include/pxdefs.h +++ b/misc/pascal/include/pxdefs.h @@ -126,7 +126,7 @@ #define lbCSTR2RSTR (0x0004) /* Convert a string to a numeric value - * procedure val(const s : string; var v; var code : word); + * procedure val(const s : string; var v; var code : word); * * Description: * val() converts the value represented in the string S to a numerical @@ -222,7 +222,7 @@ * TOS(3)=length of string1 * TOS(4)=address of string1 data * ON OUTPUT - * TOS(0)=(-1=less than, 0=equal, 1=greater than} + * TOS(0)=(-1=less than, 0=equal, 1=greater than} */ #define lbSTRCMP (0x000b) diff --git a/misc/pascal/insn16/doc/PascalOptimizations.txt b/misc/pascal/insn16/doc/PascalOptimizations.txt index d197e73da..632b5f74f 100644 --- a/misc/pascal/insn16/doc/PascalOptimizations.txt +++ b/misc/pascal/insn16/doc/PascalOptimizations.txt @@ -1,6 +1,6 @@ P-Code optimizations: Let <push-ops> be oPUSH|oPUSHB - Let <load-ops> be oLOD|oLODB|PUSH|oLADR|oLCADR + Let <load-ops> be oLOD|oLODB|PUSH|oLADR|oLCADR pcopt.c:unaryOptimize STEP 1: @@ -211,7 +211,7 @@ pjopt.c: BranchOptimize oLTEZ + oNOT -> oGTZ oLTEZ + oJEQUZ -> oJGTZ oLTEZ + oJNEQZ -> oJLTEZ - + plopt.c:LoadOptimize() Eliminate duplicate loads oLOD arg1 + oLOAD arg1 -> oLOD arg1 + oDUP diff --git a/misc/pascal/insn16/include/pinsn16.h b/misc/pascal/insn16/include/pinsn16.h index 383ba6437..1a8a6ed4c 100644 --- a/misc/pascal/insn16/include/pinsn16.h +++ b/misc/pascal/insn16/include/pinsn16.h @@ -120,7 +120,7 @@ * xx11 1100 --- --- --- --- * xx11 1101 --- --- --- --- * xx11 1110 --- --- --- --- - * xx11 1111 END --- *LABEL ilbl *LINE fn,lineno + * xx11 1111 END --- *LABEL ilbl *LINE fn,lineno * * KEY: * n = 8-bit value (unsigned) diff --git a/misc/pascal/insn16/libinsn/paddopcode.c b/misc/pascal/insn16/libinsn/paddopcode.c index 1384577a9..b11c84201 100644 --- a/misc/pascal/insn16/libinsn/paddopcode.c +++ b/misc/pascal/insn16/libinsn/paddopcode.c @@ -76,7 +76,7 @@ void insn_AddOpCode(poffHandle_t handle, OPTYPE *ptr) /* Write the 8-bit argument if present */ - if (ptr->op & o8) + if (ptr->op & o8) { (void)poffAddProgByte(handle, ptr->arg1); } @@ -84,7 +84,7 @@ void insn_AddOpCode(poffHandle_t handle, OPTYPE *ptr) /* Write the 16-bit argument if present */ if (ptr->op & o16) - { + { (void)poffAddProgByte(handle, (ptr->arg2 >> 8)); (void)poffAddProgByte(handle, (ptr->arg2 & 0xff)); } diff --git a/misc/pascal/insn16/libinsn/paddtmpopcode.c b/misc/pascal/insn16/libinsn/paddtmpopcode.c index a04878d85..8b9f618f7 100644 --- a/misc/pascal/insn16/libinsn/paddtmpopcode.c +++ b/misc/pascal/insn16/libinsn/paddtmpopcode.c @@ -76,7 +76,7 @@ void insn_AddTmpOpCode(poffProgHandle_t progHandle, OPTYPE *ptr) /* Write the 8-bit argument if present */ - if (ptr->op & o8) + if (ptr->op & o8) { (void)poffAddTmpProgByte(progHandle, ptr->arg1); } @@ -84,7 +84,7 @@ void insn_AddTmpOpCode(poffProgHandle_t progHandle, OPTYPE *ptr) /* Write the 16-bit argument if present */ if (ptr->op & o16) - { + { (void)poffAddTmpProgByte(progHandle, (ptr->arg2 >> 8)); (void)poffAddTmpProgByte(progHandle, (ptr->arg2 & 0xff)); } diff --git a/misc/pascal/insn16/popt/pcopt.c b/misc/pascal/insn16/popt/pcopt.c index e37a2d367..0379c3b6a 100644 --- a/misc/pascal/insn16/popt/pcopt.c +++ b/misc/pascal/insn16/popt/pcopt.c @@ -419,7 +419,7 @@ int16_t unaryOptimize(void) pptr[i+1]->op = oJMP; deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -430,7 +430,7 @@ int16_t unaryOptimize(void) pptr[i+1]->op = oJMP; deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -441,7 +441,7 @@ int16_t unaryOptimize(void) pptr[i+1]->op = oJMP; deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -452,7 +452,7 @@ int16_t unaryOptimize(void) pptr[i+1]->op = oJMP; deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -463,7 +463,7 @@ int16_t unaryOptimize(void) pptr[i+1]->op = oJMP; deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -474,7 +474,7 @@ int16_t unaryOptimize(void) pptr[i+1]->op = oJMP; deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; diff --git a/misc/pascal/insn16/popt/plopt.c b/misc/pascal/insn16/popt/plopt.c index b01449f64..f9293bee3 100644 --- a/misc/pascal/insn16/popt/plopt.c +++ b/misc/pascal/insn16/popt/plopt.c @@ -102,7 +102,7 @@ int16_t LoadOptimize(void) * unindexed form. */ - if (pptr[i+1]->op == oLDSXH) + if (pptr[i+1]->op == oLDSXH) { pptr[i+1]->op = oLDSH; pptr[i+1]->arg2 += val; @@ -236,7 +236,7 @@ int16_t StoreOptimize (void) else i++; break; - default : + default : i++; break; } /* end switch */ diff --git a/misc/pascal/insn16/popt/polocal.c b/misc/pascal/insn16/popt/polocal.c index 9ef98c1ce..6d8c5303b 100644 --- a/misc/pascal/insn16/popt/polocal.c +++ b/misc/pascal/insn16/popt/polocal.c @@ -101,7 +101,7 @@ void localOptimization(poffHandle_t poffHandle, initPTable(); /* Outer loop traverse the file op-code by op-code until the oEND P-Code - * has been output. NOTE: it is assumed throughout that oEND is the + * has been output. NOTE: it is assumed throughout that oEND is the * final P-Code in the program data section. */ @@ -171,11 +171,11 @@ static void putPCodeFromTable(void) { (void)poffAddTmpProgByte(myPoffProgHandle, ptable[0].op); - if (ptable[0].op & o8) + if (ptable[0].op & o8) (void)poffAddTmpProgByte(myPoffProgHandle, ptable[0].arg1); if (ptable[0].op & o16) - { + { (void)poffAddTmpProgByte(myPoffProgHandle, (ptable[0].arg2 >> 8)); (void)poffAddTmpProgByte(myPoffProgHandle, @@ -213,7 +213,7 @@ static void setupPointer(void) for (pindex = 0; pindex < WINDOW; pindex++) pptr[pindex] = (OPTYPE *) NULL; - nops = 0; + nops = 0; for (pindex = 0; pindex < WINDOW; pindex++) { switch (ptable[pindex].op) @@ -276,13 +276,13 @@ static void initPTable(void) (void)poffAddTmpProgByte(myPoffProgHandle, ptable[0].op); - if (ptable[0].op & o8) + if (ptable[0].op & o8) { (void)poffAddTmpProgByte(myPoffProgHandle, ptable[0].arg1); } if (ptable[0].op & o16) - { + { (void)poffAddTmpProgByte(myPoffProgHandle, (ptable[0].arg2 >> 8)); (void)poffAddTmpProgByte(myPoffProgHandle, (ptable[0].arg2 & 0xff)); } /* end if */ diff --git a/misc/pascal/insn16/prun/pdbg.c b/misc/pascal/insn16/prun/pdbg.c index d941ebb6f..1865c571b 100644 --- a/misc/pascal/insn16/prun/pdbg.c +++ b/misc/pascal/insn16/prun/pdbg.c @@ -421,7 +421,7 @@ static int32_t pdbg_readdecimal(char *ptr) while (isspace(*ptr)) ptr++; for (; ((*ptr >= '0') && (*ptr <= '9')); ptr++) decimal = 10*decimal + (int32_t)*ptr - (int32_t)'0'; - + return decimal; } /* end pdbg_readdecimal */ @@ -495,7 +495,7 @@ static paddr_t pdbg_printpcode(struct pexec_s *st, paddr_t pc, int16_t nitems) printf("%02x", op.arg1); opsize++; } /* end if */ - else + else printf(".."); if ((op.op & o16) != 0) @@ -575,7 +575,7 @@ static void pdbg_printtracearray(struct pexec_s *st) for (nprinted = 0; nprinted < g_ntracepoints; nprinted++) { printf("SP:%04x %04x ", - g_tracearray[ index ].sp, g_tracearray[ index ].tos); + g_tracearray[ index ].sp, g_tracearray[ index ].tos); /* Print the instruction executed at this traced address */ (void)pdbg_printpcode(st, g_tracearray[ index ].pc, 1); @@ -627,7 +627,7 @@ static void pdbg_deletebreakpoint(int16_t bpno) for (; (bpno < g_nbreakpoints); bpno++) g_breakpoint[bpno-1] = g_breakpoint[bpno]; - + g_nbreakpoints--; } /* end if */ diff --git a/misc/pascal/insn16/prun/pexec.c b/misc/pascal/insn16/prun/pexec.c index b22e52835..07809f840 100644 --- a/misc/pascal/insn16/prun/pexec.c +++ b/misc/pascal/insn16/prun/pexec.c @@ -294,7 +294,7 @@ static uint16_t pexec_sysio(struct pexec_s *st, uint8_t fno, uint16_t subfunc) * Name: pexec_libcall * * Description: - * This function process a system I/O operation + * This function process a system I/O operation * ****************************************************************************/ @@ -327,7 +327,7 @@ static uint16_t pexec_libcall(struct pexec_s *st, uint16_t subfunc) case lbGETENV : len = TOS(st, 0); /* Number of bytes in string */ src = (uint8_t*)&GETSTACK(st, TOS(st, 1)); /* Pointer to string */ - + /* Make a C string out of the pascal string */ name = pexec_mkcstring(src, len); @@ -348,7 +348,7 @@ static uint16_t pexec_libcall(struct pexec_s *st, uint16_t subfunc) break; /* Copy pascal string to a pascal string - * + * * ON INPUT: * TOS(st, 0) = address of dest string hdr * TOS(st, 1) = length of source string @@ -408,7 +408,7 @@ static uint16_t pexec_libcall(struct pexec_s *st, uint16_t subfunc) break; /* Copy C string to a pascal string - * + * * ON INPUT: * TOS(st, 0) = address of dest hdr * TOS(st, 1) = MS 16-bits of 32-bit C string pointer @@ -571,7 +571,7 @@ static uint16_t pexec_libcall(struct pexec_s *st, uint16_t subfunc) break; /* Convert a string to a numeric value - * procedure val(const s : string; var v; var code : word); + * procedure val(const s : string; var v; var code : word); * * Description: * val() converts the value represented in the string S to a numerical @@ -668,7 +668,7 @@ static uint16_t pexec_libcall(struct pexec_s *st, uint16_t subfunc) uparm1 = TOS(st, 0); /* Original string size */ addr1 = TOS(st, 1); /* Original string data pointer */ - + /* Check if there is space on the string stack for the new string * FIXME: This logic does not handle strings with other than the * default size! @@ -842,7 +842,7 @@ static uint16_t pexec_libcall(struct pexec_s *st, uint16_t subfunc) * TOS(st, 3)=length of string1 * TOS(st, 4)=address of string1 data * ON OUTPUT - * TOS(st, 0)=(-1=less than, 0=equal, 1=greater than} + * TOS(st, 0)=(-1=less than, 0=equal, 1=greater than} */ case lbSTRCMP : diff --git a/misc/pascal/insn32/doc/insn32.txt b/misc/pascal/insn32/doc/insn32.txt index 3bb7bc700..cca44639d 100644 --- a/misc/pascal/insn32/doc/insn32.txt +++ b/misc/pascal/insn32/doc/insn32.txt @@ -57,7 +57,7 @@ xr01 0111 --- PUSH nn xr01 1000 EQU JEQU ilbl xr01 1001 NEQ JNEQ ilbl xr01 1010 LT JLT ilbl -xr01 1011 GTE JGTE ilbl +xr01 1011 GTE JGTE ilbl xr01 1100 GT JGT ilbl xr01 1101 LTE JLTE ilbl xr01 1110 --- --- @@ -80,7 +80,7 @@ xr10 1101 --- STSXH offs2 xr10 1110 --- STSXB offs xr10 1111 RET STSXM offs -xr11 0000 --- LA uoffs +xr11 0000 --- LA uoffs xr11 0001 --- LAS offs xr11 0010 --- LAC dlbl xr11 0011 --- --- @@ -95,7 +95,7 @@ xr11 1011 --- LIB lop xr11 1100 --- FLOAT fop xr11 1101 --- *LABEL ilbl xr11 1110 --- *INCLUDE fn -xr11 1111 END *LINE lineno +xr11 1111 END *LINE lineno KEY: r = Reserved bit (must be zero) diff --git a/misc/pascal/insn32/include/pinsn32.h b/misc/pascal/insn32/include/pinsn32.h index eaceeba7e..1b161b196 100644 --- a/misc/pascal/insn32/include/pinsn32.h +++ b/misc/pascal/insn32/include/pinsn32.h @@ -72,7 +72,7 @@ * | GT | 0 | 0 | * | LTE | 1 | 1 | * +=====+=====+=====+ - * + * * Opcode Encoding Summary: * * 0rxx xxxx 1rxxx xxxx @@ -104,7 +104,7 @@ * xr01 1000 EQU JEQU ilbl * xr01 1001 NEQ JNEQ ilbl * xr01 1010 LT JLT ilbl - * xr01 1011 GTE JGTE ilbl + * xr01 1011 GTE JGTE ilbl * xr01 1100 GT JGT ilbl * xr01 1101 LTE JLTE ilbl * xr01 1110 --- --- @@ -127,7 +127,7 @@ * xr10 1110 --- STSXB offs * xr10 1111 RET STSXM offs * - * xr11 0000 --- LA uoffs + * xr11 0000 --- LA uoffs * xr11 0001 --- LAS offs * xr11 0010 --- LAC dlbl * xr11 0011 --- --- @@ -142,7 +142,7 @@ * xr11 1100 --- FLOAT fop * xr11 1101 --- *LABEL ilbl * xr11 1110 --- *INCLUDE fn - * xr11 1111 END *LINE lineno + * xr11 1111 END *LINE lineno * * KEY: * r = Reserved bit (must be zero) diff --git a/misc/pascal/insn32/libinsn/paddopcode.c b/misc/pascal/insn32/libinsn/paddopcode.c index 6799fdbc6..f3e6dd80e 100644 --- a/misc/pascal/insn32/libinsn/paddopcode.c +++ b/misc/pascal/insn32/libinsn/paddopcode.c @@ -78,7 +78,7 @@ void insn_AddOpCode(poffHandle_t hProg, OPTYPE *ptr) /* Write the 32-bit argument if present */ - if (ptr->op & o32) + if (ptr->op & o32) { uint8_t *pb = (uint8_t*)&ptr->arg; diff --git a/misc/pascal/insn32/libinsn/paddtmpopcode.c b/misc/pascal/insn32/libinsn/paddtmpopcode.c index e08cccc51..4b31ae2cb 100644 --- a/misc/pascal/insn32/libinsn/paddtmpopcode.c +++ b/misc/pascal/insn32/libinsn/paddtmpopcode.c @@ -78,7 +78,7 @@ void insn_AddTmpOpCode(poffProgHandle_t hProg, OPTYPE *ptr) /* Write the 32-bit argument if present */ - if (ptr->op & o32) + if (ptr->op & o32) { uint8_t *pb = (uint8_t*)&ptr->arg; diff --git a/misc/pascal/insn32/libinsn/presettmpopcodewrite.c b/misc/pascal/insn32/libinsn/presettmpopcodewrite.c index e08cccc51..4b31ae2cb 100644 --- a/misc/pascal/insn32/libinsn/presettmpopcodewrite.c +++ b/misc/pascal/insn32/libinsn/presettmpopcodewrite.c @@ -78,7 +78,7 @@ void insn_AddTmpOpCode(poffProgHandle_t hProg, OPTYPE *ptr) /* Write the 32-bit argument if present */ - if (ptr->op & o32) + if (ptr->op & o32) { uint8_t *pb = (uint8_t*)&ptr->arg; diff --git a/misc/pascal/insn32/popt/pcopt.c b/misc/pascal/insn32/popt/pcopt.c index a0c0a0226..91e60d845 100644 --- a/misc/pascal/insn32/popt/pcopt.c +++ b/misc/pascal/insn32/popt/pcopt.c @@ -235,7 +235,7 @@ int unaryOptimize(void) deletePcode(i+1); nchanges++; break; - + case oGTEZ : if ((int32_t)GETARG(pptr[i]) >= 0) PUTARG(pptr[i], -1); @@ -253,7 +253,7 @@ int unaryOptimize(void) deletePcode(i+1); nchanges++; break; - + case oLTEZ : if (GETARG(pptr[i]) <= 0) PUTARG(pptr[i], -1); @@ -417,7 +417,7 @@ int unaryOptimize(void) PUTOP(pptr[i+1], oJMP); deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -428,7 +428,7 @@ int unaryOptimize(void) PUTOP(pptr[i+1], oJMP); deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -439,7 +439,7 @@ int unaryOptimize(void) PUTOP(pptr[i+1], oJMP); deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -450,7 +450,7 @@ int unaryOptimize(void) PUTOP(pptr[i+1], oJMP); deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -461,7 +461,7 @@ int unaryOptimize(void) PUTOP(pptr[i+1], oJMP); deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; @@ -472,7 +472,7 @@ int unaryOptimize(void) PUTOP(pptr[i+1], oJMP); deletePcode(i); } /* end if */ - else + else deletePcodePair(i, (i+1)); nchanges++; break; diff --git a/misc/pascal/insn32/popt/plopt.c b/misc/pascal/insn32/popt/plopt.c index 05e8559ef..fdd25f308 100644 --- a/misc/pascal/insn32/popt/plopt.c +++ b/misc/pascal/insn32/popt/plopt.c @@ -92,7 +92,7 @@ int LoadOptimize(void) * unindexed form. */ - if (GETOP(pptr[i+1]) == oLDSXH) + if (GETOP(pptr[i+1]) == oLDSXH) { PUTOP(pptr[i+1], oLDSH); val += GETARG(pptr[i+1]); @@ -201,7 +201,7 @@ int StoreOptimize (void) else i++; break; - default : + default : i++; break; } /* end switch */ diff --git a/misc/pascal/insn32/popt/polocal.c b/misc/pascal/insn32/popt/polocal.c index 036182372..2af7f6f05 100644 --- a/misc/pascal/insn32/popt/polocal.c +++ b/misc/pascal/insn32/popt/polocal.c @@ -100,7 +100,7 @@ void localOptimization(poffHandle_t poffHandle, initPTable(); /* Outer loop traverse the file op-code by op-code until the oEND P-Code - * has been output. NOTE: it is assumed throughout that oEND is the + * has been output. NOTE: it is assumed throughout that oEND is the * final P-Code in the program data section. */ @@ -195,7 +195,7 @@ static void setupPointer(void) for (pindex = 0; pindex < WINDOW; pindex++) pptr[pindex] = (OPTYPE *) NULL; - nops = 0; + nops = 0; for (pindex = 0; pindex < WINDOW; pindex++) { switch (GETOP(&ptable[pindex])) diff --git a/misc/pascal/insn32/regm/regm_pass1.c b/misc/pascal/insn32/regm/regm_pass1.c index dcc7c572c..08194194c 100644 --- a/misc/pascal/insn32/regm/regm_pass1.c +++ b/misc/pascal/insn32/regm/regm_pass1.c @@ -104,7 +104,7 @@ static void regm_Pass1Child(poffHandle_t hPoff, struct procdata_s *pParent, pNode = regm_Pass1Node(hPoff, dwStartOffset, dwEndOffset, oRET); /* Put the func/proc body section into the tree */ - + regm_AddProgChild(pParent, pNode); /* Handle nested and child proc/func blocks */ @@ -127,7 +127,7 @@ static void regm_Pass1Peer(poffHandle_t hPoff, struct procdata_s *pPeer, pNode = regm_Pass1Node(hPoff, dwStartOffset, dwEndOffset, oRET); /* Put the func/proc body section into the tree */ - + regm_AddProgPeer(pPeer, pNode); /* Handle nested and child proc/func blocks */ @@ -266,7 +266,7 @@ void regm_Pass1(poffHandle_t hPoff) pNode = regm_Pass1Node(hPoff, dwEntryPoint, 0xffffffff, oEND); /* Put the main program section into the tree (at the root) */ - + regm_SetProgRoot(pNode); /* Then process any nested functions */ diff --git a/misc/pascal/insn32/regm/regm_pass2.c b/misc/pascal/insn32/regm/regm_pass2.c index 619d06501..e97be4325 100644 --- a/misc/pascal/insn32/regm/regm_pass2.c +++ b/misc/pascal/insn32/regm/regm_pass2.c @@ -210,7 +210,7 @@ int g_bRegisterCountValid = 0; * Private Variables **********************************************************************/ -static const struct regm_opmap_s vrgOpMap1[64] = +static const struct regm_opmap_s vrgOpMap1[64] = { /* 0x00: oNOP */ {0, 0, 0, regm_NoOperation}, /* 0x01: oNEG */ {rRSBI, 0, 0, regm_UnaryOperation}, @@ -281,7 +281,7 @@ static const struct regm_opmap_s vrgOpMap1[64] = /* 0x3f: oEND */ {0, 0, 0, regm_Return} }; -static const struct regm_opmap_s vrgOpMap2[64] = +static const struct regm_opmap_s vrgOpMap2[64] = { /* 0x80: oLD */ {rLD, 2, SPB, regm_LoadOffset}, /* 0x81: oLDH */ {rLDH, 1, SPB, regm_LoadOffset}, @@ -354,25 +354,25 @@ static const struct regm_opmap_s vrgOpMap2[64] = static const struct regm_builtin_s g_rgSysIoBuiltIns[MAX_XOP] = { - /* 0x00 */ ILLEGAL_BUILTIN_INIT, xEOF_INIT, - /* 0x02 */ xEOLN_INIT, xRESET_INIT, + /* 0x00 */ ILLEGAL_BUILTIN_INIT, xEOF_INIT, + /* 0x02 */ xEOLN_INIT, xRESET_INIT, /* 0x04 */ xREWRITE_INIT, ILLEGAL_BUILTIN_INIT, /* 0x06 */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x08 */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x0a */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x0c */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x0e */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, - /* 0x10 */ xREADLN_INIT, xREAD_PAGE_INIT, - /* 0x12 */ xREAD_BINARY_INIT, xREAD_INT_INIT, - /* 0x14 */ xREAD_CHAR_INIT, xREAD_STRING_INIT, + /* 0x10 */ xREADLN_INIT, xREAD_PAGE_INIT, + /* 0x12 */ xREAD_BINARY_INIT, xREAD_INT_INIT, + /* 0x14 */ xREAD_CHAR_INIT, xREAD_STRING_INIT, /* 0x16 */ xREAD_REAL_INIT, ILLEGAL_BUILTIN_INIT, /* 0x18 */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x1a */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x1c */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, /* 0x1e */ ILLEGAL_BUILTIN_INIT, ILLEGAL_BUILTIN_INIT, - /* 0x20 */ xWRITELN_INIT, xWRITE_PAGE_INIT, - /* 0x22 */ xWRITE_BINARY_INIT, xWRITE_INT_INIT, - /* 0x24 */ xWRITE_CHAR_INIT, xWRITE_STRING_INIT, + /* 0x20 */ xWRITELN_INIT, xWRITE_PAGE_INIT, + /* 0x22 */ xWRITE_BINARY_INIT, xWRITE_INT_INIT, + /* 0x24 */ xWRITE_CHAR_INIT, xWRITE_STRING_INIT, /* 0x25 */ xWRITE_REAL_INIT }; @@ -389,68 +389,68 @@ static const struct regm_builtin_s g_rgLibCallBuiltIns[MAX_LBOP] = static const struct regm_builtin_s g_rgRrFopBuiltIns[MAX_FOP] = { /* 0x00 */ ILLEGAL_BUILTIN_INIT, fpFLOAT_INIT, - /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, - /* 0x04 */ fpADD_RR_INIT, fpSUB_RR_INIT, - /* 0x06 */ fpMUL_RR_INIT, fpDIV_RR_INIT, + /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, + /* 0x04 */ fpADD_RR_INIT, fpSUB_RR_INIT, + /* 0x06 */ fpMUL_RR_INIT, fpDIV_RR_INIT, /* 0x00 */ fpMOD_RR_INIT, ILLEGAL_BUILTIN_INIT, - /* 0x0a */ fpEQU_RR_INIT, fpNEQ_RR_INIT, - /* 0x0c */ fpLT_RR_INIT, fpGTE_RR_INIT, - /* 0x0e */ fpGT_RR_INIT, fpLTE_RR_INIT, - /* 0x10 */ fpNEG_R_INIT, fpABS_R_INIT, - /* 0x12 */ fpSQR_R_INIT, fpSQRT_R_INIT, - /* 0x14 */ fpSIN_R_INIT, fpCOS_R_INIT, - /* 0x16 */ fpATAN_R_INIT, fpLN_R_INIT, + /* 0x0a */ fpEQU_RR_INIT, fpNEQ_RR_INIT, + /* 0x0c */ fpLT_RR_INIT, fpGTE_RR_INIT, + /* 0x0e */ fpGT_RR_INIT, fpLTE_RR_INIT, + /* 0x10 */ fpNEG_R_INIT, fpABS_R_INIT, + /* 0x12 */ fpSQR_R_INIT, fpSQRT_R_INIT, + /* 0x14 */ fpSIN_R_INIT, fpCOS_R_INIT, + /* 0x16 */ fpATAN_R_INIT, fpLN_R_INIT, /* 0x18 */ fpEXP_R_INIT }; static const struct regm_builtin_s g_rgRiFopBuiltIns[MAX_FOP] = { /* 0x00 */ ILLEGAL_BUILTIN_INIT, fpFLOAT_INIT, - /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, - /* 0x04 */ fpADD_RI_INIT, fpSUB_RI_INIT, - /* 0x06 */ fpMUL_RI_INIT, fpDIV_RI_INIT, + /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, + /* 0x04 */ fpADD_RI_INIT, fpSUB_RI_INIT, + /* 0x06 */ fpMUL_RI_INIT, fpDIV_RI_INIT, /* 0x00 */ fpMOD_RI_INIT, ILLEGAL_BUILTIN_INIT, - /* 0x0a */ fpEQU_RI_INIT, fpNEQ_RI_INIT, - /* 0x0c */ fpLT_RI_INIT, fpGTE_RI_INIT, - /* 0x0e */ fpGT_RI_INIT, fpLTE_RI_INIT, - /* 0x10 */ fpNEG_I_INIT, fpABS_I_INIT, - /* 0x12 */ fpSQR_I_INIT, fpSQRT_I_INIT, - /* 0x14 */ fpSIN_I_INIT, fpCOS_I_INIT, - /* 0x16 */ fpATAN_I_INIT, fpLN_I_INIT, + /* 0x0a */ fpEQU_RI_INIT, fpNEQ_RI_INIT, + /* 0x0c */ fpLT_RI_INIT, fpGTE_RI_INIT, + /* 0x0e */ fpGT_RI_INIT, fpLTE_RI_INIT, + /* 0x10 */ fpNEG_I_INIT, fpABS_I_INIT, + /* 0x12 */ fpSQR_I_INIT, fpSQRT_I_INIT, + /* 0x14 */ fpSIN_I_INIT, fpCOS_I_INIT, + /* 0x16 */ fpATAN_I_INIT, fpLN_I_INIT, /* 0x18 */ fpEXP_I_INIT }; static const struct regm_builtin_s g_rgIrFopBuiltIns[MAX_FOP] = { /* 0x00 */ ILLEGAL_BUILTIN_INIT, fpFLOAT_INIT, - /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, - /* 0x04 */ fpADD_IR_INIT, fpSUB_IR_INIT, - /* 0x06 */ fpMUL_IR_INIT, fpDIV_IR_INIT, + /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, + /* 0x04 */ fpADD_IR_INIT, fpSUB_IR_INIT, + /* 0x06 */ fpMUL_IR_INIT, fpDIV_IR_INIT, /* 0x00 */ fpMOD_IR_INIT, ILLEGAL_BUILTIN_INIT, - /* 0x0a */ fpEQU_IR_INIT, fpNEQ_IR_INIT, - /* 0x0c */ fpLT_IR_INIT, fpGTE_IR_INIT, - /* 0x0e */ fpGT_IR_INIT, fpLTE_IR_INIT, - /* 0x10 */ fpNEG_R_INIT, fpABS_R_INIT, - /* 0x12 */ fpSQR_R_INIT, fpSQRT_R_INIT, - /* 0x14 */ fpSIN_R_INIT, fpCOS_R_INIT, - /* 0x16 */ fpATAN_R_INIT, fpLN_R_INIT, + /* 0x0a */ fpEQU_IR_INIT, fpNEQ_IR_INIT, + /* 0x0c */ fpLT_IR_INIT, fpGTE_IR_INIT, + /* 0x0e */ fpGT_IR_INIT, fpLTE_IR_INIT, + /* 0x10 */ fpNEG_R_INIT, fpABS_R_INIT, + /* 0x12 */ fpSQR_R_INIT, fpSQRT_R_INIT, + /* 0x14 */ fpSIN_R_INIT, fpCOS_R_INIT, + /* 0x16 */ fpATAN_R_INIT, fpLN_R_INIT, /* 0x18 */ fpEXP_R_INIT }; static const struct regm_builtin_s g_rgIiFopBuiltIns[MAX_FOP] = { /* 0x00 */ ILLEGAL_BUILTIN_INIT, fpFLOAT_INIT, - /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, - /* 0x04 */ fpADD_II_INIT, fpSUB_II_INIT, - /* 0x06 */ fpMUL_II_INIT, fpDIV_II_INIT, + /* 0x02 */ fpTRUNC_INIT, fpROUND_INIT, + /* 0x04 */ fpADD_II_INIT, fpSUB_II_INIT, + /* 0x06 */ fpMUL_II_INIT, fpDIV_II_INIT, /* 0x00 */ fpMOD_II_INIT, ILLEGAL_BUILTIN_INIT, - /* 0x0a */ fpEQU_II_INIT, fpNEQ_II_INIT, - /* 0x0c */ fpLT_II_INIT, fpGTE_II_INIT, - /* 0x0e */ fpGT_II_INIT, fpLTE_II_INIT, - /* 0x10 */ fpNEG_I_INIT, fpABS_I_INIT, - /* 0x12 */ fpSQR_I_INIT, fpSQRT_I_INIT, - /* 0x14 */ fpSIN_I_INIT, fpCOS_I_INIT, - /* 0x16 */ fpATAN_I_INIT, fpLN_I_INIT, + /* 0x0a */ fpEQU_II_INIT, fpNEQ_II_INIT, + /* 0x0c */ fpLT_II_INIT, fpGTE_II_INIT, + /* 0x0e */ fpGT_II_INIT, fpLTE_II_INIT, + /* 0x10 */ fpNEG_I_INIT, fpABS_I_INIT, + /* 0x12 */ fpSQR_I_INIT, fpSQRT_I_INIT, + /* 0x14 */ fpSIN_I_INIT, fpCOS_I_INIT, + /* 0x16 */ fpATAN_I_INIT, fpLN_I_INIT, /* 0x18 */ fpEXP_I_INIT }; @@ -530,7 +530,7 @@ static void regm_BinaryOperation(const struct regm_opmap_s *pEntry, /* Generate the binary operation */ regm_GenerateForm3R(pEntry->chOpCode, dwRDest, dwROperand1, dwROperand2); - + /* Reduce stack */ g_dwStackOffset -= sINT_SIZE; @@ -608,7 +608,7 @@ static void regm_BinaryComparison(const struct regm_opmap_s *pEntry, regm_GenerateForm2I(rMOVI, dwRDest, 0); regm_GenerateForm4ICc(pEntry->chOpCode, 2, dwCcRegister); regm_GenerateForm2I(rMOVI, dwRDest, 1); - + /* Reduce stack */ g_dwStackOffset -= sINT_SIZE; @@ -699,7 +699,7 @@ static void regm_StoreImmediate(const struct regm_opmap_s *pEntry, regm_GenerateForm3R(pEntry->chOpCode, dwRSrc, dwROperand1, MKSPECIAL(pEntry->chSpecial)); - + /* Reduce stack */ g_dwStackOffset -= 2*sINT_SIZE; @@ -838,7 +838,7 @@ static void regm_PopSpecial(const struct regm_opmap_s *pEntry, /***********************************************************************/ /* Save the immediate value in the data count register */ -static void regm_SetDataCount(const struct regm_opmap_s *pEntry, +static void regm_SetDataCount(const struct regm_opmap_s *pEntry, OPTYPE *pOpCode, struct procdata_s *pNode) { @@ -878,7 +878,7 @@ static void regm_LoadOffset(const struct regm_opmap_s *pEntry, regm_GenerateForm3I(pEntry->chOpCode, dwRDest, MKSPECIAL(pEntry->chSpecial), GETARG(pOpCode) >> pEntry->chImmediate); - + /* Increment the stack */ g_dwStackOffset += sINT_SIZE; @@ -919,7 +919,7 @@ static void regm_StoreOffset(const struct regm_opmap_s *pEntry, regm_GenerateForm3I(pEntry->chOpCode, dwRSrc, MKSPECIAL(pEntry->chSpecial), GETARG(pOpCode) >> pEntry->chImmediate); - + /* Decrement the stack */ g_dwStackOffset -= sINT_SIZE; @@ -1098,7 +1098,7 @@ static void regm_ConditionalBranchBinary(const struct regm_opmap_s *pEntry, regm_GenerateForm1RCc(rCMP, dwROperand1, dwROperand2, dwCcRegister); regm_GenerateForm4ICc(pEntry->chOpCode, GETARG(pOpCode), dwCcRegister); - + /* Reduce stack */ g_dwStackOffset -= 2*sINT_SIZE; @@ -1160,7 +1160,7 @@ static void regm_LoadAddress(const struct regm_opmap_s *pEntry, regm_GenerateForm3I(rADD, dwRDest, MKSPECIAL(pEntry->chSpecial), GETARG(pOpCode)); - + /* Increment the stack */ g_dwStackOffset += sINT_SIZE; @@ -1201,7 +1201,7 @@ static void regm_SetupOutArgs(uint32_t nParms, const uint32_t *pwArgSize) } /* Emit move instructions to handle each */ - + dwOffset = g_dwStackOffset - sINT_SIZE; for (i = 0; i < nArgRegs; i++) { @@ -1427,7 +1427,7 @@ static void regm_GenerateRegm(struct procdata_s *pNode, void *pvArg) uint8_t chOpCode = GETOP(&pNode->pPCode[i]); /* Select the right decode table */ - + if ((chOpCode & o32) != 0) { rgOpMap = vrgOpMap2; @@ -1450,7 +1450,7 @@ static void regm_GenerateRegm(struct procdata_s *pNode, void *pvArg) rgOpMap->pMapper(rgOpMap, &pNode->pPCode[i], pNode); } - /* If a frame was obtained at the beginning, make sure that + /* If a frame was obtained at the beginning, make sure that * there is matching frame release logic at the end. */ @@ -1463,7 +1463,7 @@ static void regm_GenerateRegm(struct procdata_s *pNode, void *pvArg) } i++; } - + /* Analyze the proc/func epilogue */ if ((GETOP(&pNode->pPCode[i]) != oRET) && diff --git a/misc/pascal/libpas/Make.defs b/misc/pascal/libpas/Make.defs index 2a0fbed8c..436dce569 100644 --- a/misc/pascal/libpas/Make.defs +++ b/misc/pascal/libpas/Make.defs @@ -34,5 +34,5 @@ # ############################################################################ -PAS_ASRCS = +PAS_ASRCS = PAS_CSRCS = psignextend16.c pswap.c diff --git a/misc/pascal/libpoff/Make.defs b/misc/pascal/libpoff/Make.defs index 41f0a63f0..f7ce4236a 100644 --- a/misc/pascal/libpoff/Make.defs +++ b/misc/pascal/libpoff/Make.defs @@ -34,7 +34,7 @@ # ############################################################################ -POFF_ASRCS = +POFF_ASRCS = POFF_CSRCS = pfhandle.c pfproghandle.c pftprog.c \ pfsymhandle.c pftsymbol.c pofferr.c \ pfwhdr.c pfwrodata.c pfwsymbol.c pfwfname.c \ diff --git a/misc/pascal/libpoff/pflabel.c b/misc/pascal/libpoff/pflabel.c index 973366466..a124051e3 100644 --- a/misc/pascal/libpoff/pflabel.c +++ b/misc/pascal/libpoff/pflabel.c @@ -128,7 +128,7 @@ static void poffCheckDefinedLabelRealloc(void) { /* Check if there is room for the new data */ - if (((nDefinedLabelRefs + 1)*sizeof(optDefinedLabelRef_t)) > + if (((nDefinedLabelRefs + 1)*sizeof(optDefinedLabelRef_t)) > definedLabelRefAlloc) { uint32_t newAlloc = definedLabelRefAlloc + DEFINED_INCREMENT; diff --git a/misc/pascal/libpoff/pflineno.c b/misc/pascal/libpoff/pflineno.c index 983a74554..ea682f891 100644 --- a/misc/pascal/libpoff/pflineno.c +++ b/misc/pascal/libpoff/pflineno.c @@ -277,7 +277,7 @@ poffLibLineNumber_t *poffFindLineNumber(uint32_t offset) * for offset, then we can safely set the upper search index * to the midpoint. */ - + if (lineNumberTable[lineNumberIndex].offset > offset) lastLineNumberIndex = lineNumberIndex; diff --git a/misc/pascal/pascal/pas.c b/misc/pascal/pascal/pas.c index b0975c42f..c80002a2c 100644 --- a/misc/pascal/pascal/pas.c +++ b/misc/pascal/pascal/pas.c @@ -203,7 +203,7 @@ static void openOutputFiles(void) { fprintf(stderr, "Could not open output file '%s': %s\n", tmpname, strerror(errno)); - showUsage(); + showUsage(); } } } @@ -266,7 +266,7 @@ static void parseArguments(int argc, char **argv) if (argc < 2) { fprintf(stderr, "Invalid number of arguments\n"); - showUsage(); + showUsage(); } /* Parse any optional command line arguments */ @@ -282,7 +282,7 @@ static void parseArguments(int argc, char **argv) if (nIncPathes >= MAX_INCPATHES) { fprintf(stderr, "Unrecognized [option]\n"); - showUsage(); + showUsage(); } else { @@ -292,13 +292,13 @@ static void parseArguments(int argc, char **argv) break; default: fprintf(stderr, "Unrecognized [option]\n"); - showUsage(); + showUsage(); } } else { fprintf(stderr, "Unrecognized [option]\n"); - showUsage(); + showUsage(); } } @@ -338,9 +338,9 @@ int main(int argc, char *argv[]) { errmsg("Could not open source file '%s': %s\n", filename, strerror(errno)); - showUsage(); + showUsage(); } - + /* Initialization */ primeSignalHandlers(); @@ -387,7 +387,7 @@ int main(int argc, char *argv[]) getToken(); if (token == tPROGRAM) - { + { /* Compile a pascal program */ FP->kind = eIsProgram; diff --git a/misc/pascal/pascal/pasdefs.h b/misc/pascal/pascal/pasdefs.h index ade1b7ed0..95d9acf01 100644 --- a/misc/pascal/pascal/pasdefs.h +++ b/misc/pascal/pascal/pasdefs.h @@ -76,7 +76,7 @@ ***********************************************************************/ /* This enumeration identies what kind of binary object we are creating - * with the compilation. At present, we may be generating either a + * with the compilation. At present, we may be generating either a * program binary or a unit binary. */ diff --git a/misc/pascal/pascal/pblck.c b/misc/pascal/pascal/pblck.c index b32701cc7..87f3304b6 100644 --- a/misc/pascal/pascal/pblck.c +++ b/misc/pascal/pascal/pblck.c @@ -107,7 +107,7 @@ static bool pas_IntAlignRequired (STYPE *typePtr); ***************************************************************/ static int32_t g_nParms; -static int32_t g_dwVarSize; +static int32_t g_dwVarSize; /*************************************************************** * Public Functions @@ -190,7 +190,7 @@ void block() pas_GenerateDataOperation(opLABEL, (int32_t)beginLabel); /* Since we don't know for certain how we got here, invalidate - * the level stack pointer (LSP). This is, of course, only + * the level stack pointer (LSP). This is, of course, only * meaningful on architectures that implement an LSP. */ @@ -318,7 +318,7 @@ void declarationGroup(int32_t beginLabel) variableDeclarationGroup(); } - /* Process procedure/function-declaration(s) if present + /* Process procedure/function-declaration(s) if present * FORM: function-declaration = * function-heading ';' directive | * function-heading ';' function-block @@ -531,7 +531,7 @@ int16_t formalParameterList(STYPE *procPtr) { pointerType = 1; getToken(); - } + } else pointerType = 0; /* Process the common part of the variable-parameter-specification @@ -833,7 +833,7 @@ static STYPE *pas_DeclareVar(void) /* IMPORT the symbol; assign an offset relative to * the dstack at the beginning of this file */ - + pas_GenerateStackImport(varPtr); } else /* if (FP0->kind == eIsProgram) */ @@ -844,7 +844,7 @@ static STYPE *pas_DeclareVar(void) } } - /* In any event, bump the stack offset to include space for + /* In any event, bump the stack offset to include space for * this new symbol. The 'bumped' stack offset will be the * offset for the next variable that is declared. */ @@ -1564,7 +1564,7 @@ static STYPE *pas_NewComplexType(char *typeName) else typeIdPtr = pas_DeclareOrdinalType(NULL); - /* Verify that the ordinal-type is either a scalar or a + /* Verify that the ordinal-type is either a scalar or a * subrange type. These are the only valid types for 'set of' */ @@ -1605,7 +1605,7 @@ static STYPE *pas_NewComplexType(char *typeName) else error(eSET); break; - + /* File Types * FORM: file-type = 'file' 'of' type-denoter */ @@ -1858,7 +1858,7 @@ static STYPE *pas_DeclareRecord(char *recordName) recordOffset += recordPtr[symbolIndex].sParm.r.size; recordCount++; } - } + } /* Update the RECORD entry for the total size of all fields */ @@ -1883,7 +1883,7 @@ static STYPE *pas_DeclareRecord(char *recordName) if (token != tIDENT) error(eRECORDDECLARE); - /* Add a variant-selector to the fixed-part of the record */ + /* Add a variant-selector to the fixed-part of the record */ else { @@ -2088,7 +2088,7 @@ static STYPE *pas_DeclareRecord(char *recordName) if (recordOffset > maxRecordSize) maxRecordSize = recordOffset; - } + } /* Verify that the <field list> is enclosed in parentheses */ @@ -2175,7 +2175,7 @@ static STYPE *pas_DeclareField(STYPE *recordPtr) return typePtr; } - + /***************************************************************/ /* Process VAR/value Parameter Declaration */ /* NOTE: This function increments the global variable g_nParms */ diff --git a/misc/pascal/pascal/pcexpr.c b/misc/pascal/pascal/pcexpr.c index c14b6b1ee..2247e2bcf 100644 --- a/misc/pascal/pascal/pcexpr.c +++ b/misc/pascal/pascal/pcexpr.c @@ -441,7 +441,7 @@ void constantTerm(void) { constantReal = (double)constantInt; } - + /* Handle the case where the 1st argument is Integer and the * second is REAL. */ @@ -573,4 +573,4 @@ static void constantFactor(void) error(eINVFACTOR); break; } -} +} diff --git a/misc/pascal/pascal/pcfunc.c b/misc/pascal/pascal/pcfunc.c index c4188ca2b..a07f0e623 100644 --- a/misc/pascal/pascal/pcfunc.c +++ b/misc/pascal/pascal/pcfunc.c @@ -107,7 +107,7 @@ void builtInFunctionOfConstant(void) case txROUND : constantReal2IntFunc(fpROUND); - break; + break; case txTRUNC : constantReal2IntFunc(fpTRUNC); break; diff --git a/misc/pascal/pascal/pexpr.c b/misc/pascal/pascal/pexpr.c index 855e519f3..5f9fe0b10 100644 --- a/misc/pascal/pascal/pexpr.c +++ b/misc/pascal/pascal/pexpr.c @@ -112,7 +112,7 @@ static bool isStringReference (exprType testExprType); /* The abstract types - SETs, RECORDS, etc - require an exact */ /* match in type. This variable points to the symbol table */ /* sTYPE entry associated with the expression. */ - + static STYPE *abstractType; /***************************************************************/ @@ -178,14 +178,14 @@ exprType expression(exprType findExprType, STYPE *typePtr) break; case tIN : if ((!abstractType) || - ((abstractType->sParm.t.type != sSCALAR) && - (abstractType->sParm.t.type != sSUBRANGE))) - error(eEXPRTYPE); + ((abstractType->sParm.t.type != sSCALAR) && + (abstractType->sParm.t.type != sSUBRANGE))) + error(eEXPRTYPE); else if (abstractType->sParm.t.minValue) - { - pas_GenerateDataOperation(opPUSH, abstractType->sParm.t.minValue); - pas_GenerateSimple(opSUB); - } /* end else if */ + { + pas_GenerateDataOperation(opPUSH, abstractType->sParm.t.minValue); + pas_GenerateSimple(opSUB); + } /* end else if */ intOpCode = opBIT; fpOpCode = fpINVLD; strOpCode = opNOP; @@ -207,67 +207,67 @@ exprType expression(exprType findExprType, STYPE *typePtr) simple2Type = simpleExpression(findExprType); /* Perform automatic type conversion from INTEGER to REAL - * for integer vs. real comparisons. - */ + * for integer vs. real comparisons. + */ if (simple1Type != simple2Type) - { - /* Handle the case where the 1st argument is REAL and the - * second is INTEGER. */ - - if ((simple1Type == exprReal) && - (simple2Type == exprInteger) && - (fpOpCode != fpINVLD)) - { - fpOpCode |= fpARG2; - simple2Type = exprReal; - } /* end if */ - - /* Handle the case where the 1st argument is Integer and the - * second is REAL. */ - - else if ((simple1Type == exprInteger) && - (simple2Type == exprReal) && - (fpOpCode != fpINVLD)) - { - fpOpCode |= fpARG1; - simple1Type = exprReal; - } /* end else if */ - - /* Allow the case of <scalar type> IN <set type> */ - /* Otherwise, the two terms must agree in type */ - - else if ((operation != tIN) || (simple2Type != exprSet)) - { - error(eEXPRTYPE); - } - } /* end if */ + { + /* Handle the case where the 1st argument is REAL and the + * second is INTEGER. */ + + if ((simple1Type == exprReal) && + (simple2Type == exprInteger) && + (fpOpCode != fpINVLD)) + { + fpOpCode |= fpARG2; + simple2Type = exprReal; + } /* end if */ + + /* Handle the case where the 1st argument is Integer and the + * second is REAL. */ + + else if ((simple1Type == exprInteger) && + (simple2Type == exprReal) && + (fpOpCode != fpINVLD)) + { + fpOpCode |= fpARG1; + simple1Type = exprReal; + } /* end else if */ + + /* Allow the case of <scalar type> IN <set type> */ + /* Otherwise, the two terms must agree in type */ + + else if ((operation != tIN) || (simple2Type != exprSet)) + { + error(eEXPRTYPE); + } + } /* end if */ /* Generate the comparison */ if (simple1Type == exprReal) - { - if (fpOpCode == fpINVLD) - error(eEXPRTYPE); - else - pas_GenerateFpOperation(fpOpCode); - } /* end if */ + { + if (fpOpCode == fpINVLD) + error(eEXPRTYPE); + else + pas_GenerateFpOperation(fpOpCode); + } /* end if */ else if ((simple1Type == exprString) || (simple1Type == exprString)) - { - if (strOpCode != opNOP) - { - pas_BuiltInFunctionCall(lbSTRCMP); - pas_GenerateSimple(strOpCode); - } - else - { - error(eEXPRTYPE); - } - } + { + if (strOpCode != opNOP) + { + pas_BuiltInFunctionCall(lbSTRCMP); + pas_GenerateSimple(strOpCode); + } + else + { + error(eEXPRTYPE); + } + } else - { - pas_GenerateSimple(intOpCode); - } + { + pas_GenerateSimple(intOpCode); + } /* The type resulting from these operations becomes BOOLEAN */ @@ -312,28 +312,28 @@ exprType expression(exprType findExprType, STYPE *typePtr) (findExprType != simple1Type) && /* 2)NOT Matched expression */ ((findExprType != exprAnyOrdinal) || /* 3)NOT any ordinal type */ - (!isOrdinalType(simple1Type))) && /* OR type is not ordinal */ + (!isOrdinalType(simple1Type))) && /* OR type is not ordinal */ ((findExprType != exprAnyString) || /* 4)NOT any string type */ - (!isAnyStringType(simple1Type))) && /* OR type is not string */ + (!isAnyStringType(simple1Type))) && /* OR type is not string */ ((findExprType != exprString) || /* 5)Not looking for string ref */ - (!isStringReference(simple1Type)))) /* OR type is not string ref */ + (!isStringReference(simple1Type)))) /* OR type is not string ref */ { /* Automatic conversions from INTEGER to REAL will be performed */ if ((findExprType == exprReal) && (simple1Type == exprInteger)) - { - pas_GenerateFpOperation(fpFLOAT); - simple1Type = exprReal; - } + { + pas_GenerateFpOperation(fpFLOAT); + simple1Type = exprReal; + } /* Any other type mismatch is an error */ else - { - error(eEXPRTYPE); - } + { + error(eEXPRTYPE); + } } /* end if */ return simple1Type; @@ -367,7 +367,7 @@ exprType varParm (exprType varExprType, STYPE *typePtr) return factorType; } /* end varParm */ - + /**********************************************************************/ /* Process Array Index */ void arrayIndex (int32_t size) @@ -386,7 +386,7 @@ void arrayIndex (int32_t size) /* Correct for size of array element */ if (size > 1) { - pas_GenerateDataOperation(opPUSH, size); + pas_GenerateDataOperation(opPUSH, size); pas_GenerateSimple(opMUL); } /* end if */ @@ -411,74 +411,74 @@ exprType getExprType(STYPE *sType) if ((sType) && (sType->sKind == sTYPE)) { switch (sType->sParm.t.type) - { - case sINT : - factorType = exprInteger; - break; - case sBOOLEAN : - factorType = exprBoolean; - break; - case sCHAR : - factorType = exprChar; - break; - case sREAL : - factorType = exprReal; - break; - case sSCALAR : - factorType = exprScalar; - break; - case sSTRING : - case sRSTRING : - factorType = exprString; - break; - case sSUBRANGE : - switch (sType->sParm.t.subType) - { - case sINT : - factorType = exprInteger; - break; - case sCHAR : - factorType = exprChar; - break; - case sSCALAR : - factorType = exprScalar; - break; - default : - error(eSUBRANGETYPE); - break; - } /* end switch */ - break; - case sPOINTER : - sType = sType->sParm.t.parent; - if (sType) - { - switch (sType->sKind) - { - case sINT : - factorType = exprIntegerPtr; - break; - case sBOOLEAN : - factorType = exprBooleanPtr; - break; - case sCHAR : - factorType = exprCharPtr; - break; - case sREAL : - factorType = exprRealPtr; - break; - case sSCALAR : - factorType = exprScalarPtr; - break; - default : - error(eINVTYPE); - break; - } /* end switch */ - } /* end if */ - break; - default : - error(eINVTYPE); - break; - } /* end switch */ + { + case sINT : + factorType = exprInteger; + break; + case sBOOLEAN : + factorType = exprBoolean; + break; + case sCHAR : + factorType = exprChar; + break; + case sREAL : + factorType = exprReal; + break; + case sSCALAR : + factorType = exprScalar; + break; + case sSTRING : + case sRSTRING : + factorType = exprString; + break; + case sSUBRANGE : + switch (sType->sParm.t.subType) + { + case sINT : + factorType = exprInteger; + break; + case sCHAR : + factorType = exprChar; + break; + case sSCALAR : + factorType = exprScalar; + break; + default : + error(eSUBRANGETYPE); + break; + } /* end switch */ + break; + case sPOINTER : + sType = sType->sParm.t.parent; + if (sType) + { + switch (sType->sKind) + { + case sINT : + factorType = exprIntegerPtr; + break; + case sBOOLEAN : + factorType = exprBooleanPtr; + break; + case sCHAR : + factorType = exprCharPtr; + break; + case sREAL : + factorType = exprRealPtr; + break; + case sSCALAR : + factorType = exprScalarPtr; + break; + default : + error(eINVTYPE); + break; + } /* end switch */ + } /* end if */ + break; + default : + error(eINVTYPE); + break; + } /* end switch */ } /* end if */ return factorType; @@ -512,11 +512,11 @@ static exprType simpleExpression(exprType findExprType) if (operation == '-') { if (term1Type == exprInteger) - pas_GenerateSimple(opNEG); + pas_GenerateSimple(opNEG); else if (term1Type == exprReal) - pas_GenerateFpOperation(fpNEG); + pas_GenerateFpOperation(fpNEG); else - error(eTERMTYPE); + error(eTERMTYPE); } /* end if */ /* Process subsequent (optional) terms and binary operations */ @@ -526,41 +526,41 @@ static exprType simpleExpression(exprType findExprType) /* Check for binary operator */ if ((token == '+') || (token == '-') || (token == tOR)) - operation = token; + operation = token; else - break; + break; /* Special case for string types. So far, we have parsed - * '<string> +' At this point, it is safe to assume we - * going to modified string. So, if the string has not - * been copied to the string stack, we will have to do that - * now. - */ + * '<string> +' At this point, it is safe to assume we + * going to modified string. So, if the string has not + * been copied to the string stack, we will have to do that + * now. + */ if ((term1Type == exprString) && (operation == '+')) - { - /* Duplicate the string on the string stack. And - * change the expression type to reflect this. - */ + { + /* Duplicate the string on the string stack. And + * change the expression type to reflect this. + */ - pas_BuiltInFunctionCall(lbMKSTKSTR); - term1Type = exprStkString; - } + pas_BuiltInFunctionCall(lbMKSTKSTR); + term1Type = exprStkString; + } /* If we are going to add something to a char, then the - * result must be a string. We will similarly have to - * convert the character to a string. - */ + * result must be a string. We will similarly have to + * convert the character to a string. + */ else if ((term1Type == exprChar) && (operation == '+')) - { - /* Duplicate the string on the string stack. And - * change the expression type to reflect this. - */ + { + /* Duplicate the string on the string stack. And + * change the expression type to reflect this. + */ - pas_BuiltInFunctionCall(lbMKSTKC); - term1Type = exprStkString; - } + pas_BuiltInFunctionCall(lbMKSTKC); + term1Type = exprStkString; + } /* Get the 2nd term */ @@ -568,153 +568,153 @@ static exprType simpleExpression(exprType findExprType) term2Type = term(findExprType); /* Before generating the operation, verify that the types match. - * Perform automatic type conversion from INTEGER to REAL as - * necessary. - */ + * Perform automatic type conversion from INTEGER to REAL as + * necessary. + */ arg8FpBits = 0; /* Skip over string types. These will be handled below */ if (!isStringReference(term1Type)) - { - /* Handle the case where the type of the terms differ. */ - - if (term1Type != term2Type) - { - /* Handle the case where the 1st argument is REAL and the - * second is INTEGER. */ - - if ((term1Type == exprReal) && (term2Type == exprInteger)) - { - arg8FpBits = fpARG2; - term2Type = exprReal; - } /* end if */ - - /* Handle the case where the 1st argument is Integer and the - * second is REAL. */ - - else if ((term1Type == exprInteger) && (term2Type == exprReal)) - { - arg8FpBits = fpARG1; - term1Type = exprReal; - } /* end if */ - - /* Otherwise, the two terms must agree in type */ - - else - { - error(eTERMTYPE); - } - } /* end if */ - - /* We do not perform conversions for the cases where the two - * terms agree in type. There is only one interesting case: - * When the expected expression is real and both arguments are - * integer. Since addition an subtraction are exact, it would, - * in general, be more efficient to perform the conversion - * AFTER the operation (at the the risk of possible overflow - * conditions due to the limited range of integers). - */ - } + { + /* Handle the case where the type of the terms differ. */ + + if (term1Type != term2Type) + { + /* Handle the case where the 1st argument is REAL and the + * second is INTEGER. */ + + if ((term1Type == exprReal) && (term2Type == exprInteger)) + { + arg8FpBits = fpARG2; + term2Type = exprReal; + } /* end if */ + + /* Handle the case where the 1st argument is Integer and the + * second is REAL. */ + + else if ((term1Type == exprInteger) && (term2Type == exprReal)) + { + arg8FpBits = fpARG1; + term1Type = exprReal; + } /* end if */ + + /* Otherwise, the two terms must agree in type */ + + else + { + error(eTERMTYPE); + } + } /* end if */ + + /* We do not perform conversions for the cases where the two + * terms agree in type. There is only one interesting case: + * When the expected expression is real and both arguments are + * integer. Since addition an subtraction are exact, it would, + * in general, be more efficient to perform the conversion + * AFTER the operation (at the the risk of possible overflow + * conditions due to the limited range of integers). + */ + } /* Generate code to perform the selected binary operation */ switch (operation) - { - case '+' : - switch (term1Type) - { - /* Integer addition */ - - case exprInteger : - pas_GenerateSimple(opADD); - break; - - /* Floating point addition */ - - case exprReal : - pas_GenerateFpOperation(fpADD | arg8FpBits); - break; - - /* Set 'addition' */ - - case exprSet : - pas_GenerateSimple(opOR); - break; - - /* Handle the special cases where '+' indicates that we are - * concatenating a string or a character to the end of a - * string. Note that these operations can only be performed - * on stack copies of the strings. Logic above should have - * made the conversion for the case of exprString. - */ - - case exprStkString : - if ((term2Type == exprString) || (term2Type == exprStkString)) - { - /* We are concatenating one string with another.*/ - - pas_BuiltInFunctionCall(lbSTRCAT); - } - else if (term2Type == exprChar) - { - /* We are concatenating a character to the end of a string */ - - pas_BuiltInFunctionCall(lbSTRCATC); - } - else - { - error(eTERMTYPE); - } - break; - - /* Otherwise, the '+' operation is not permitted */ - - default : - error(eTERMTYPE); - break; - } - break; - - case '-' : - /* Integer subtraction */ - - if (term1Type == exprInteger) - pas_GenerateSimple(opSUB); - - /* Floating point subtraction */ - - else if (term1Type == exprReal) - pas_GenerateFpOperation(fpSUB | arg8FpBits); - - /* Set 'subtraction' */ - - else if (term1Type == exprSet) - { - pas_GenerateSimple(opNOT); - pas_GenerateSimple(opAND); - } /* end else if */ + { + case '+' : + switch (term1Type) + { + /* Integer addition */ + + case exprInteger : + pas_GenerateSimple(opADD); + break; + + /* Floating point addition */ + + case exprReal : + pas_GenerateFpOperation(fpADD | arg8FpBits); + break; + + /* Set 'addition' */ + + case exprSet : + pas_GenerateSimple(opOR); + break; + + /* Handle the special cases where '+' indicates that we are + * concatenating a string or a character to the end of a + * string. Note that these operations can only be performed + * on stack copies of the strings. Logic above should have + * made the conversion for the case of exprString. + */ + + case exprStkString : + if ((term2Type == exprString) || (term2Type == exprStkString)) + { + /* We are concatenating one string with another.*/ + + pas_BuiltInFunctionCall(lbSTRCAT); + } + else if (term2Type == exprChar) + { + /* We are concatenating a character to the end of a string */ + + pas_BuiltInFunctionCall(lbSTRCATC); + } + else + { + error(eTERMTYPE); + } + break; + + /* Otherwise, the '+' operation is not permitted */ + + default : + error(eTERMTYPE); + break; + } + break; + + case '-' : + /* Integer subtraction */ + + if (term1Type == exprInteger) + pas_GenerateSimple(opSUB); + + /* Floating point subtraction */ + + else if (term1Type == exprReal) + pas_GenerateFpOperation(fpSUB | arg8FpBits); + + /* Set 'subtraction' */ + + else if (term1Type == exprSet) + { + pas_GenerateSimple(opNOT); + pas_GenerateSimple(opAND); + } /* end else if */ - /* Otherwise, the '-' operation is not permitted */ + /* Otherwise, the '-' operation is not permitted */ - else - error(eTERMTYPE); - break; + else + error(eTERMTYPE); + break; - case tOR : - /* Integer/boolean 'OR' */ + case tOR : + /* Integer/boolean 'OR' */ - if ((term1Type == exprInteger) || (term1Type == exprBoolean)) - pas_GenerateSimple(opOR); + if ((term1Type == exprInteger) || (term1Type == exprBoolean)) + pas_GenerateSimple(opOR); - /* Otherwise, the 'OR' operation is not permitted */ + /* Otherwise, the 'OR' operation is not permitted */ - else - error(eTERMTYPE); - break; + else + error(eTERMTYPE); + break; - } /* end switch */ + } /* end switch */ } /* end for */ return term1Type; @@ -741,9 +741,9 @@ static exprType term(exprType findExprType) /* Check for binary operator */ if ((token == tMUL) || (token == tDIV) || - (token == tFDIV) || (token == tMOD) || - (token == tAND) || (token == tSHL) || - (token == tSHR)) + (token == tFDIV) || (token == tMOD) || + (token == tAND) || (token == tSHL) || + (token == tSHR)) operation = token; else break; @@ -764,29 +764,29 @@ static exprType term(exprType findExprType) if (factor1Type != factor2Type) { - /* Handle the case where the 1st argument is REAL and the - * second is INTEGER. */ - - if ((factor1Type == exprReal) && (factor2Type == exprInteger)) - { - arg8FpBits = fpARG2; - } /* end if */ - - /* Handle the case where the 1st argument is Integer and the - * second is REAL. */ - - else if ((factor1Type == exprInteger) && (factor2Type == exprReal)) - { - arg8FpBits = fpARG1; - factor1Type = exprReal; - } /* end if */ - - /* Otherwise, the two factors must agree in type */ - - else - { - error(eFACTORTYPE); - } + /* Handle the case where the 1st argument is REAL and the + * second is INTEGER. */ + + if ((factor1Type == exprReal) && (factor2Type == exprInteger)) + { + arg8FpBits = fpARG2; + } /* end if */ + + /* Handle the case where the 1st argument is Integer and the + * second is REAL. */ + + else if ((factor1Type == exprInteger) && (factor2Type == exprReal)) + { + arg8FpBits = fpARG1; + factor1Type = exprReal; + } /* end if */ + + /* Otherwise, the two factors must agree in type */ + + else + { + error(eFACTORTYPE); + } } /* end if */ /* Handle the cases for conversions when the two string @@ -795,35 +795,35 @@ static exprType term(exprType findExprType) else { - /* There is only one interesting case: When the - * expected expression is real and both arguments are - * integer. In this case, for example, 1/2 must yield - * 0.5, not 0. - */ - - if ((factor1Type == exprInteger) && (findExprType == exprReal)) - { - /* However, we will perform this conversin only for the - * arithmetic operations: tMUL, tDIV/tFDIV, and tMOD. - * The logical operations must be performed on integer - * types with the result converted to a real type afterward. - */ - - if ((operation == tMUL) || (operation == tDIV) || - (operation == tFDIV) || (operation == tMOD)) - { - /* Perform the conversion of both terms */ - - arg8FpBits = fpARG1 | fpARG2; - factor1Type = exprReal; - - /* We will also have to switch the operation in - * the case of tDIV: We'll have to used tFDIV. - */ - - if (operation == tDIV) operation = tFDIV; - } - } + /* There is only one interesting case: When the + * expected expression is real and both arguments are + * integer. In this case, for example, 1/2 must yield + * 0.5, not 0. + */ + + if ((factor1Type == exprInteger) && (findExprType == exprReal)) + { + /* However, we will perform this conversin only for the + * arithmetic operations: tMUL, tDIV/tFDIV, and tMOD. + * The logical operations must be performed on integer + * types with the result converted to a real type afterward. + */ + + if ((operation == tMUL) || (operation == tDIV) || + (operation == tFDIV) || (operation == tMOD)) + { + /* Perform the conversion of both terms */ + + arg8FpBits = fpARG1 | fpARG2; + factor1Type = exprReal; + + /* We will also have to switch the operation in + * the case of tDIV: We'll have to used tFDIV. + */ + + if (operation == tDIV) operation = tFDIV; + } + } } /* Generate code to perform the selected binary operation */ @@ -831,59 +831,59 @@ static exprType term(exprType findExprType) switch (operation) { case tMUL : - if (factor1Type == exprInteger) - pas_GenerateSimple(opMUL); - else if (factor1Type == exprReal) - pas_GenerateFpOperation(fpMUL | arg8FpBits); - else if (factor1Type == exprSet) - pas_GenerateSimple(opAND); + if (factor1Type == exprInteger) + pas_GenerateSimple(opMUL); + else if (factor1Type == exprReal) + pas_GenerateFpOperation(fpMUL | arg8FpBits); + else if (factor1Type == exprSet) + pas_GenerateSimple(opAND); else - error(eFACTORTYPE); + error(eFACTORTYPE); break; case tDIV : - if (factor1Type == exprInteger) - pas_GenerateSimple(opDIV); + if (factor1Type == exprInteger) + pas_GenerateSimple(opDIV); else - error(eFACTORTYPE); - break; + error(eFACTORTYPE); + break; case tFDIV : - if (factor1Type == exprReal) - pas_GenerateFpOperation(fpDIV | arg8FpBits); - else - error(eFACTORTYPE); + if (factor1Type == exprReal) + pas_GenerateFpOperation(fpDIV | arg8FpBits); + else + error(eFACTORTYPE); break; case tMOD : - if (factor1Type == exprInteger) - pas_GenerateSimple(opMOD); - else if (factor1Type == exprReal) - pas_GenerateFpOperation(fpMOD | arg8FpBits); - else - error(eFACTORTYPE); + if (factor1Type == exprInteger) + pas_GenerateSimple(opMOD); + else if (factor1Type == exprReal) + pas_GenerateFpOperation(fpMOD | arg8FpBits); + else + error(eFACTORTYPE); break; case tAND : - if ((factor1Type == exprInteger) || (factor1Type == exprBoolean)) - pas_GenerateSimple(opAND); + if ((factor1Type == exprInteger) || (factor1Type == exprBoolean)) + pas_GenerateSimple(opAND); else - error(eFACTORTYPE); + error(eFACTORTYPE); break; case tSHL : - if (factor1Type == exprInteger) - pas_GenerateSimple(opSLL); + if (factor1Type == exprInteger) + pas_GenerateSimple(opSLL); else - error(eFACTORTYPE); + error(eFACTORTYPE); break; case tSHR : - if (factor1Type == exprInteger) - pas_GenerateSimple(opSRA); + if (factor1Type == exprInteger) + pas_GenerateSimple(opSRA); else - error(eFACTORTYPE); - break; + error(eFACTORTYPE); + break; } /* end switch */ } /* end for */ @@ -944,11 +944,11 @@ static exprType factor(exprType findExprType) case sSCALAR_OBJECT : if (abstractType) - { - if (tknPtr->sParm.c.parent != abstractType) error(eSCALARTYPE); - } /* end if */ + { + if (tknPtr->sParm.c.parent != abstractType) error(eSCALARTYPE); + } /* end if */ else - abstractType = tknPtr->sParm.c.parent; + abstractType = tknPtr->sParm.c.parent; pas_GenerateDataOperation(opPUSH, tknPtr->sParm.c.val.i); getToken(); @@ -986,26 +986,26 @@ static exprType factor(exprType findExprType) case tSTRING_CONST : { - /* Final stack representation is: - * TOS(0) : size in bytes - * TOS(1) : pointer to string - * - * Add the string to the RO data section of the output - * and get the offset to the string location. - */ + /* Final stack representation is: + * TOS(0) : size in bytes + * TOS(1) : pointer to string + * + * Add the string to the RO data section of the output + * and get the offset to the string location. + */ - uint32_t offset = poffAddRoDataString(poffHandle, tkn_strt); + uint32_t offset = poffAddRoDataString(poffHandle, tkn_strt); - /* Get the offset then size of the string on the stack */ + /* Get the offset then size of the string on the stack */ - pas_GenerateDataOperation(opLAC, offset); - pas_GenerateDataOperation(opPUSH, strlen(tkn_strt)); + pas_GenerateDataOperation(opLAC, offset); + pas_GenerateDataOperation(opPUSH, strlen(tkn_strt)); - /* Release the tokenized string */ + /* Release the tokenized string */ - stringSP = tkn_strt; - getToken(); - factorType = exprString; + stringSP = tkn_strt; + getToken(); + factorType = exprString; } break; @@ -1050,11 +1050,11 @@ static exprType factor(exprType findExprType) case sSCALAR : if (abstractType) - { - if (tknPtr->sParm.v.parent != abstractType) error(eSCALARTYPE); - } /* end if */ + { + if (tknPtr->sParm.v.parent != abstractType) error(eSCALARTYPE); + } /* end if */ else - abstractType = tknPtr->sParm.v.parent; + abstractType = tknPtr->sParm.v.parent; pas_GenerateStackReference(opLDS, tknPtr); getToken(); @@ -1066,13 +1066,13 @@ static exprType factor(exprType findExprType) /* same SET OF <object> -OR- the same <object> */ if (abstractType) - { - if ((tknPtr->sParm.v.parent != abstractType) && - (tknPtr->sParm.v.parent->sParm.t.parent != abstractType)) - error(eSET); - } /* end if */ + { + if ((tknPtr->sParm.v.parent != abstractType) && + (tknPtr->sParm.v.parent->sParm.t.parent != abstractType)) + error(eSET); + } /* end if */ else - abstractType = tknPtr->sParm.v.parent; + abstractType = tknPtr->sParm.v.parent; pas_GenerateStackReference(opLDS, tknPtr); getToken(); @@ -1120,7 +1120,7 @@ static exprType factor(exprType findExprType) case '^' : getToken(); factorType = ptrFactor(); - break; + break; /* Highest Priority Operators */ @@ -1128,7 +1128,7 @@ static exprType factor(exprType findExprType) getToken(); factorType = factor(findExprType); if ((factorType != exprInteger) && (factorType != exprBoolean)) - error(eFACTORTYPE); + error(eFACTORTYPE); pas_GenerateSimple(opNOT); break; @@ -1192,258 +1192,258 @@ static exprType simpleFactor(STYPE *varPtr, uint8_t factorFlags) case sINT : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprInteger; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprIntegerPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprInteger; - } /* end else */ - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprInteger; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprIntegerPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprInteger; + } /* end else */ + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprInteger; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprIntegerPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprInteger; - } /* end else */ - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprInteger; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprIntegerPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprInteger; + } /* end else */ + } /* end else */ break; case sCHAR : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - pas_GenerateSimple(opLDIB); - factorType = exprChar; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprCharPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDSXB, varPtr); - factorType = exprChar; - } /* end else */ - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + pas_GenerateSimple(opLDIB); + factorType = exprChar; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprCharPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDSXB, varPtr); + factorType = exprChar; + } /* end else */ + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateSimple(opLDIB); - factorType = exprChar; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprCharPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDSB, varPtr); - factorType = exprChar; - } /* end else */ - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateSimple(opLDIB); + factorType = exprChar; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprCharPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDSB, varPtr); + factorType = exprChar; + } /* end else */ + } /* end else */ break; case sBOOLEAN : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprBoolean; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprBooleanPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprBoolean; - } /* end else */ - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprBoolean; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprBooleanPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprBoolean; + } /* end else */ + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprBoolean; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprBooleanPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprBoolean; - } /* end else */ - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprBoolean; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprBooleanPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprBoolean; + } /* end else */ + } /* end else */ break; case sREAL : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateSimple(opLDIM); - factorType = exprReal; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprRealPtr; - } /* end else if */ - else - { - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateStackReference(opLDSXM, varPtr); - factorType = exprReal; - } /* end else */ - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateSimple(opLDIM); + factorType = exprReal; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprRealPtr; + } /* end else if */ + else + { + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateStackReference(opLDSXM, varPtr); + factorType = exprReal; + } /* end else */ + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateSimple(opLDIM); - factorType = exprReal; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprRealPtr; - } /* end else if */ - else - { - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateStackReference(opLDSM, varPtr); - factorType = exprReal; - } /* end else */ - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateSimple(opLDIM); + factorType = exprReal; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprRealPtr; + } /* end else if */ + else + { + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateStackReference(opLDSM, varPtr); + factorType = exprReal; + } /* end else */ + } /* end else */ break; case sSCALAR : if (!abstractType) - abstractType = typePtr; + abstractType = typePtr; else if (typePtr != abstractType) - error(eSCALARTYPE); + error(eSCALARTYPE); if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprScalar; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprScalarPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprScalar; - } /* end else */ - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprScalar; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprScalarPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprScalar; + } /* end else */ + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprScalar; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprScalarPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprScalar; - } /* end else */ - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprScalar; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprScalarPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprScalar; + } /* end else */ + } /* end else */ break; case sSET_OF : if (!abstractType) - abstractType = typePtr; + abstractType = typePtr; else if ((typePtr != abstractType) && - (typePtr->sParm.v.parent != abstractType)) - error(eSCALARTYPE); + (typePtr->sParm.v.parent != abstractType)) + error(eSCALARTYPE); if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprSet; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprSetPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDSX, varPtr); - factorType = exprSet; - } /* end else */ - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprSet; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprSetPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDSX, varPtr); + factorType = exprSet; + } /* end else */ + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateSimple(opLDI); - factorType = exprSet; - } /* end if */ - else if ((factorFlags & ADDRESS_FACTOR) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprSetPtr; - } /* end else if */ - else - { - pas_GenerateStackReference(opLDS, varPtr); - factorType = exprSet; - } /* end else */ - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateSimple(opLDI); + factorType = exprSet; + } /* end if */ + else if ((factorFlags & ADDRESS_FACTOR) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprSetPtr; + } /* end else if */ + else + { + pas_GenerateStackReference(opLDS, varPtr); + factorType = exprSet; + } /* end else */ + } /* end else */ break; /* NOPE... recurse until it becomes a simple factor */ @@ -1458,85 +1458,85 @@ static exprType simpleFactor(STYPE *varPtr, uint8_t factorFlags) /* Check if this is a pointer to a record */ if ((factorFlags & ADDRESS_FACTOR) != 0) - { - if (token == '.') error(ePOINTERTYPE); + { + if (token == '.') error(ePOINTERTYPE); - if ((factorFlags & INDEXED_FACTOR) != 0) - pas_GenerateStackReference(opLDSX, varPtr); - else - pas_GenerateStackReference(opLDS, varPtr); + if ((factorFlags & INDEXED_FACTOR) != 0) + pas_GenerateStackReference(opLDSX, varPtr); + else + pas_GenerateStackReference(opLDS, varPtr); - factorType = exprRecordPtr; - } /* end if */ + factorType = exprRecordPtr; + } /* end if */ /* Verify that a period separates the RECORD identifier from the */ /* record field identifier */ else if (token == '.') - { - if (((factorFlags & ADDRESS_DEREFERENCE) != 0) && - ((factorFlags & VAR_PARM_FACTOR) == 0)) - error(ePOINTERTYPE); - - /* Skip over the period. */ - - getToken(); - - /* Verify that a field identifier associated with this record */ - /* follows the period. */ - - if ((token != sRECORD_OBJECT) || - (tknPtr->sParm.r.record != typePtr)) - { - error(eRECORDOBJECT); - factorType = exprInteger; - } /* end if */ - else - { - /* Modify the variable so that it has the characteristics of the */ - /* the field but with level and offset associated with the record */ - - typePtr = tknPtr->sParm.r.parent; - varPtr->sKind = typePtr->sParm.t.type; - varPtr->sParm.v.parent = typePtr; - - /* Special case: The record is a VAR parameter. */ - - if (factorFlags == (INDEXED_FACTOR | ADDRESS_DEREFERENCE | VAR_PARM_FACTOR)) - { - pas_GenerateDataOperation(opPUSH, tknPtr->sParm.r.offset); - pas_GenerateSimple(opADD); - } /* end if */ - else - varPtr->sParm.v.offset += tknPtr->sParm.r.offset; - - getToken(); - factorType = simpleFactor(varPtr, factorFlags); - } /* end else */ - } /* end else if */ + { + if (((factorFlags & ADDRESS_DEREFERENCE) != 0) && + ((factorFlags & VAR_PARM_FACTOR) == 0)) + error(ePOINTERTYPE); + + /* Skip over the period. */ + + getToken(); + + /* Verify that a field identifier associated with this record */ + /* follows the period. */ + + if ((token != sRECORD_OBJECT) || + (tknPtr->sParm.r.record != typePtr)) + { + error(eRECORDOBJECT); + factorType = exprInteger; + } /* end if */ + else + { + /* Modify the variable so that it has the characteristics of the */ + /* the field but with level and offset associated with the record */ + + typePtr = tknPtr->sParm.r.parent; + varPtr->sKind = typePtr->sParm.t.type; + varPtr->sParm.v.parent = typePtr; + + /* Special case: The record is a VAR parameter. */ + + if (factorFlags == (INDEXED_FACTOR | ADDRESS_DEREFERENCE | VAR_PARM_FACTOR)) + { + pas_GenerateDataOperation(opPUSH, tknPtr->sParm.r.offset); + pas_GenerateSimple(opADD); + } /* end if */ + else + varPtr->sParm.v.offset += tknPtr->sParm.r.offset; + + getToken(); + factorType = simpleFactor(varPtr, factorFlags); + } /* end else */ + } /* end else if */ /* A RECORD name name be a valid factor -- as the input */ /* parameter of a function or in an assignment */ else if (abstractType == typePtr) - { - /* Special case: The record is a VAR parameter. */ - - if (factorFlags == (INDEXED_FACTOR | ADDRESS_DEREFERENCE | VAR_PARM_FACTOR)) - { - pas_GenerateStackReference(opLDS, varPtr); - pas_GenerateSimple(opADD); - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateSimple(opLDIM); - } /* end if */ - else - { - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateStackReference(opLDSM, varPtr); - } /* end else */ - - factorType = exprRecord; - } /* end else if */ + { + /* Special case: The record is a VAR parameter. */ + + if (factorFlags == (INDEXED_FACTOR | ADDRESS_DEREFERENCE | VAR_PARM_FACTOR)) + { + pas_GenerateStackReference(opLDS, varPtr); + pas_GenerateSimple(opADD); + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateSimple(opLDIM); + } /* end if */ + else + { + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateStackReference(opLDSM, varPtr); + } /* end else */ + + factorType = exprRecord; + } /* end else if */ else error(ePERIOD); break; @@ -1545,69 +1545,69 @@ static exprType simpleFactor(STYPE *varPtr, uint8_t factorFlags) /* defining the RECORD type */ if (!withRecord.parent) - error(eINVTYPE); + error(eINVTYPE); else if ((factorFlags && (ADDRESS_DEREFERENCE | ADDRESS_FACTOR)) != 0) - error(ePOINTERTYPE); + error(ePOINTERTYPE); else if ((factorFlags && INDEXED_FACTOR) != 0) - error(eARRAYTYPE); + error(eARRAYTYPE); /* Verify that a field identifier is associated with the RECORD */ /* specified by the WITH statement. */ else if (varPtr->sParm.r.record != withRecord.parent) - error(eRECORDOBJECT); + error(eRECORDOBJECT); else - { - int16_t tempOffset; - - /* Now there are two cases to consider: (1) the withRecord is a */ - /* pointer to a RECORD, or (2) the withRecord is the RECOR itself */ - - if (withRecord.pointer) - { - /* If the pointer is really a VAR parameter, then other syntax */ - /* rules will apply */ - - if (withRecord.varParm) - factorFlags |= (INDEXED_FACTOR | ADDRESS_DEREFERENCE | VAR_PARM_FACTOR); - else - factorFlags |= (INDEXED_FACTOR | ADDRESS_DEREFERENCE); - - pas_GenerateDataOperation(opPUSH, (varPtr->sParm.r.offset + withRecord.index)); - tempOffset = withRecord.offset; - } /* end if */ - else - { - tempOffset = varPtr->sParm.r.offset + withRecord.offset; - } /* end else */ - - /* Modify the variable so that it has the characteristics of the */ - /* the field but with level and offset associated with the record */ - /* NOTE: We have to be careful here because the structure */ - /* associated with sRECORD_OBJECT is not the same as for */ - /* variables! */ - - typePtr = varPtr->sParm.r.parent; - tempOffset = varPtr->sParm.r.offset; - - varPtr->sKind = typePtr->sParm.t.type; - varPtr->sLevel = withRecord.level; - varPtr->sParm.v.size = typePtr->sParm.t.asize; - varPtr->sParm.v.offset = tempOffset + withRecord.offset; - varPtr->sParm.v.parent = typePtr; - - factorType = simpleFactor(varPtr, factorFlags); - } /* end else */ + { + int16_t tempOffset; + + /* Now there are two cases to consider: (1) the withRecord is a */ + /* pointer to a RECORD, or (2) the withRecord is the RECOR itself */ + + if (withRecord.pointer) + { + /* If the pointer is really a VAR parameter, then other syntax */ + /* rules will apply */ + + if (withRecord.varParm) + factorFlags |= (INDEXED_FACTOR | ADDRESS_DEREFERENCE | VAR_PARM_FACTOR); + else + factorFlags |= (INDEXED_FACTOR | ADDRESS_DEREFERENCE); + + pas_GenerateDataOperation(opPUSH, (varPtr->sParm.r.offset + withRecord.index)); + tempOffset = withRecord.offset; + } /* end if */ + else + { + tempOffset = varPtr->sParm.r.offset + withRecord.offset; + } /* end else */ + + /* Modify the variable so that it has the characteristics of the */ + /* the field but with level and offset associated with the record */ + /* NOTE: We have to be careful here because the structure */ + /* associated with sRECORD_OBJECT is not the same as for */ + /* variables! */ + + typePtr = varPtr->sParm.r.parent; + tempOffset = varPtr->sParm.r.offset; + + varPtr->sKind = typePtr->sParm.t.type; + varPtr->sLevel = withRecord.level; + varPtr->sParm.v.size = typePtr->sParm.t.asize; + varPtr->sParm.v.offset = tempOffset + withRecord.offset; + varPtr->sParm.v.parent = typePtr; + + factorType = simpleFactor(varPtr, factorFlags); + } /* end else */ break; case sPOINTER : if (token == '^') - { - getToken(); - factorFlags |= ADDRESS_DEREFERENCE; - } /* end if */ + { + getToken(); + factorFlags |= ADDRESS_DEREFERENCE; + } /* end if */ else - factorFlags |= ADDRESS_FACTOR; + factorFlags |= ADDRESS_FACTOR; varPtr->sKind = typePtr->sParm.t.type; factorType = simpleFactor(varPtr, factorFlags); @@ -1625,23 +1625,23 @@ static exprType simpleFactor(STYPE *varPtr, uint8_t factorFlags) if (factorFlags != 0) error(eARRAYTYPE); if (token == '[') - { - factorFlags |= INDEXED_FACTOR; - arrayIndex(typePtr->sParm.t.asize); - varPtr->sKind = typePtr->sParm.t.type; - varPtr->sParm.v.size = typePtr->sParm.t.asize; - factorType = simpleFactor(varPtr, factorFlags); - } /* end if */ + { + factorFlags |= INDEXED_FACTOR; + arrayIndex(typePtr->sParm.t.asize); + varPtr->sKind = typePtr->sParm.t.type; + varPtr->sParm.v.size = typePtr->sParm.t.asize; + factorType = simpleFactor(varPtr, factorFlags); + } /* end if */ /* An ARRAY name name be a valid factor -- only as the input */ /* parameter of a function */ else if (abstractType == varPtr) - { - pas_GenerateDataSize(varPtr->sParm.v.size); - pas_GenerateStackReference(opLDSM, varPtr); - factorType = exprArray; - } /* end else if */ + { + pas_GenerateDataSize(varPtr->sParm.v.size); + pas_GenerateStackReference(opLDSM, varPtr); + factorType = exprArray; + } /* end else if */ else error(eLBRACKET); break; @@ -1693,11 +1693,11 @@ static exprType ptrFactor(void) break; case sSCALAR : if (abstractType) - { - if (tknPtr->sParm.v.parent != abstractType) error(eSCALARTYPE); - } /* end if */ + { + if (tknPtr->sParm.v.parent != abstractType) error(eSCALARTYPE); + } /* end if */ else - abstractType = tknPtr->sParm.v.parent; + abstractType = tknPtr->sParm.v.parent; pas_GenerateStackReference(opLAS, tknPtr); getToken(); @@ -1708,12 +1708,12 @@ static exprType ptrFactor(void) /* same SET OF <object> -OR- the same <object> */ if (abstractType) { - if ((tknPtr->sParm.v.parent != abstractType) - && (tknPtr->sParm.v.parent->sParm.t.parent != abstractType)) - error(eSET); + if ((tknPtr->sParm.v.parent != abstractType) + && (tknPtr->sParm.v.parent->sParm.t.parent != abstractType)) + error(eSET); } /* end if */ else - abstractType = tknPtr->sParm.v.parent; + abstractType = tknPtr->sParm.v.parent; pas_GenerateStackReference(opLAS, tknPtr); getToken(); factorType = exprSetPtr; @@ -1736,7 +1736,7 @@ static exprType ptrFactor(void) error(eNOTYET); getToken(); factorType = ptrFactor(); - break; + break; case '(' : getToken(); @@ -1796,170 +1796,170 @@ static exprType simplePtrFactor(STYPE *varPtr, uint8_t factorFlags) /* Check if we have reduced the complex factor to a simple factor */ case sINT : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLASX, varPtr); - } /* end else */ - factorType = exprIntegerPtr; - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLASX, varPtr); + } /* end else */ + factorType = exprIntegerPtr; + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLAS, varPtr); - } /* end else */ - factorType = exprIntegerPtr; - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLAS, varPtr); + } /* end else */ + factorType = exprIntegerPtr; + } /* end else */ break; case sCHAR : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLASX, varPtr); - } /* end else */ - factorType = exprCharPtr; - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLASX, varPtr); + } /* end else */ + factorType = exprCharPtr; + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLAS, varPtr); - } /* end else */ - factorType = exprCharPtr; - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLAS, varPtr); + } /* end else */ + factorType = exprCharPtr; + } /* end else */ break; case sBOOLEAN : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLASX, varPtr); - } /* end else */ - factorType = exprBooleanPtr; - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLASX, varPtr); + } /* end else */ + factorType = exprBooleanPtr; + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLAS, varPtr); - } /* end else */ - factorType = exprBooleanPtr; - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLAS, varPtr); + } /* end else */ + factorType = exprBooleanPtr; + } /* end else */ break; case sREAL : if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLASX, varPtr); - } /* end else */ - factorType = exprRealPtr; - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLASX, varPtr); + } /* end else */ + factorType = exprRealPtr; + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLAS, varPtr); - } /* end else */ - factorType = exprRealPtr; - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLAS, varPtr); + } /* end else */ + factorType = exprRealPtr; + } /* end else */ break; case sSCALAR : if (!abstractType) - abstractType = typePtr; + abstractType = typePtr; else if (typePtr != abstractType) - error(eSCALARTYPE); + error(eSCALARTYPE); if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLASX, varPtr); - } /* end else */ - factorType = exprScalarPtr; - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLASX, varPtr); + } /* end else */ + factorType = exprScalarPtr; + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLAS, varPtr); - } /* end else */ - factorType = exprScalarPtr; - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLAS, varPtr); + } /* end else */ + factorType = exprScalarPtr; + } /* end else */ break; case sSET_OF : if (!abstractType) - abstractType = typePtr; + abstractType = typePtr; else if ((typePtr != abstractType) && - (typePtr->sParm.v.parent != abstractType)) - error(eSCALARTYPE); + (typePtr->sParm.v.parent != abstractType)) + error(eSCALARTYPE); if ((factorFlags & INDEXED_FACTOR) != 0) - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDSX, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLASX, varPtr); - } /* end else */ - factorType = exprSetPtr; - } /* end if */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDSX, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLASX, varPtr); + } /* end else */ + factorType = exprSetPtr; + } /* end if */ else - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - { - pas_GenerateStackReference(opLDS, varPtr); - } /* end if */ - else - { - pas_GenerateStackReference(opLAS, varPtr); - } /* end else */ - factorType = exprSetPtr; - } /* end else */ + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + { + pas_GenerateStackReference(opLDS, varPtr); + } /* end if */ + else + { + pas_GenerateStackReference(opLAS, varPtr); + } /* end else */ + factorType = exprSetPtr; + } /* end else */ break; /* NOPE... recurse until it becomes a simple factor */ @@ -1974,53 +1974,53 @@ static exprType simplePtrFactor(STYPE *varPtr, uint8_t factorFlags) /* Check if this is a pointer to a record */ if (token != '.') - { - if ((factorFlags & ADDRESS_DEREFERENCE) != 0) - error(ePOINTERTYPE); + { + if ((factorFlags & ADDRESS_DEREFERENCE) != 0) + error(ePOINTERTYPE); - if ((factorFlags & INDEXED_FACTOR) != 0) - pas_GenerateStackReference(opLASX, varPtr); - else - pas_GenerateStackReference(opLAS, varPtr); + if ((factorFlags & INDEXED_FACTOR) != 0) + pas_GenerateStackReference(opLASX, varPtr); + else + pas_GenerateStackReference(opLAS, varPtr); - factorType = exprRecordPtr; - } /* end if */ + factorType = exprRecordPtr; + } /* end if */ else - { - /* Verify that a period separates the RECORD identifier from the - * record field identifier - */ - - if (token != '.') error(ePERIOD); - else getToken(); - - /* Verify that a field identifier associated with this record - * follows the period. - */ - - if ((token != sRECORD_OBJECT) || - (tknPtr->sParm.r.record != typePtr)) - { - error(eRECORDOBJECT); - factorType = exprInteger; - } /* end if */ - else - { - /* Modify the variable so that it has the characteristics - * of the field but with level and offset associated with - * the record - */ - - typePtr = tknPtr->sParm.r.parent; - varPtr->sKind = typePtr->sParm.t.type; - varPtr->sParm.v.offset += tknPtr->sParm.r.offset; - varPtr->sParm.v.parent = typePtr; - - getToken(); - factorType = simplePtrFactor(varPtr, factorFlags); - - } /* end else */ - } /* end else */ + { + /* Verify that a period separates the RECORD identifier from the + * record field identifier + */ + + if (token != '.') error(ePERIOD); + else getToken(); + + /* Verify that a field identifier associated with this record + * follows the period. + */ + + if ((token != sRECORD_OBJECT) || + (tknPtr->sParm.r.record != typePtr)) + { + error(eRECORDOBJECT); + factorType = exprInteger; + } /* end if */ + else + { + /* Modify the variable so that it has the characteristics + * of the field but with level and offset associated with + * the record + */ + + typePtr = tknPtr->sParm.r.parent; + varPtr->sKind = typePtr->sParm.t.type; + varPtr->sParm.v.offset += tknPtr->sParm.r.offset; + varPtr->sParm.v.parent = typePtr; + + getToken(); + factorType = simplePtrFactor(varPtr, factorFlags); + + } /* end else */ + } /* end else */ break; case sRECORD_OBJECT : @@ -2029,55 +2029,55 @@ static exprType simplePtrFactor(STYPE *varPtr, uint8_t factorFlags) */ if (!withRecord.parent) - error(eINVTYPE); + error(eINVTYPE); else if ((factorFlags && ADDRESS_DEREFERENCE) != 0) - error(ePOINTERTYPE); + error(ePOINTERTYPE); else if ((factorFlags && INDEXED_FACTOR) != 0) - error(eARRAYTYPE); + error(eARRAYTYPE); /* Verify that a field identifier is associated with the RECORD * specified by the WITH statement. */ else if (varPtr->sParm.r.record != withRecord.parent) - error(eRECORDOBJECT); + error(eRECORDOBJECT); else - { - int16_t tempOffset; - - /* Now there are two cases to consider: (1) the withRecord is a - * pointer to a RECORD, or (2) the withRecord is the RECOR itself - */ - - if (withRecord.pointer) - { - pas_GenerateDataOperation(opPUSH, (varPtr->sParm.r.offset + withRecord.index)); - factorFlags |= (INDEXED_FACTOR | ADDRESS_DEREFERENCE); - tempOffset = withRecord.offset; - } /* end if */ - else - { - tempOffset = varPtr->sParm.r.offset + withRecord.offset; - } /* end else */ - - /* Modify the variable so that it has the characteristics of the - * the field but with level and offset associated with the record - * NOTE: We have to be careful here because the structure - * associated with sRECORD_OBJECT is not the same as for - * variables! - */ - - typePtr = varPtr->sParm.r.parent; - tempOffset = varPtr->sParm.r.offset; - - varPtr->sKind = typePtr->sParm.t.type; - varPtr->sLevel = withRecord.level; - varPtr->sParm.v.size = typePtr->sParm.t.asize; - varPtr->sParm.v.offset = tempOffset + withRecord.offset; - varPtr->sParm.v.parent = typePtr; - - factorType = simplePtrFactor(varPtr, factorFlags); - } /* end else */ + { + int16_t tempOffset; + + /* Now there are two cases to consider: (1) the withRecord is a + * pointer to a RECORD, or (2) the withRecord is the RECOR itself + */ + + if (withRecord.pointer) + { + pas_GenerateDataOperation(opPUSH, (varPtr->sParm.r.offset + withRecord.index)); + factorFlags |= (INDEXED_FACTOR | ADDRESS_DEREFERENCE); + tempOffset = withRecord.offset; + } /* end if */ + else + { + tempOffset = varPtr->sParm.r.offset + withRecord.offset; + } /* end else */ + + /* Modify the variable so that it has the characteristics of the + * the field but with level and offset associated with the record + * NOTE: We have to be careful here because the structure + * associated with sRECORD_OBJECT is not the same as for + * variables! + */ + + typePtr = varPtr->sParm.r.parent; + tempOffset = varPtr->sParm.r.offset; + + varPtr->sKind = typePtr->sParm.t.type; + varPtr->sLevel = withRecord.level; + varPtr->sParm.v.size = typePtr->sParm.t.asize; + varPtr->sParm.v.offset = tempOffset + withRecord.offset; + varPtr->sParm.v.parent = typePtr; + + factorType = simplePtrFactor(varPtr, factorFlags); + } /* end else */ break; case sPOINTER : @@ -2100,19 +2100,19 @@ static exprType simplePtrFactor(STYPE *varPtr, uint8_t factorFlags) case sARRAY : if (factorFlags != 0) error(eARRAYTYPE); if (token == '[') - { - factorFlags |= INDEXED_FACTOR; - - arrayIndex(typePtr->sParm.t.asize); - varPtr->sKind = typePtr->sParm.t.type; - varPtr->sParm.v.size = typePtr->sParm.t.asize; - factorType = simplePtrFactor(varPtr, factorFlags); - } /* end if */ + { + factorFlags |= INDEXED_FACTOR; + + arrayIndex(typePtr->sParm.t.asize); + varPtr->sKind = typePtr->sParm.t.type; + varPtr->sParm.v.size = typePtr->sParm.t.asize; + factorType = simplePtrFactor(varPtr, factorFlags); + } /* end if */ else - { - pas_GenerateStackReference(opLAS, varPtr); - factorType = exprArrayPtr; - } /* end else */ + { + pas_GenerateStackReference(opLAS, varPtr); + factorType = exprArrayPtr; + } /* end else */ break; default : @@ -2205,34 +2205,34 @@ static void setAbstractType(STYPE *sType) if ((sType) && (sType->sKind == sTYPE) && (sType->sParm.t.type == sPOINTER)) sType = sType->sParm.t.parent; - + if ((sType) && (sType->sKind == sTYPE)) { switch (sType->sParm.t.type) { case sSCALAR : - if (abstractType) { + if (abstractType) { if (sType != abstractType) error(eSCALARTYPE); } /* end if */ else abstractType = sType; - break; + break; case sSUBRANGE : - if (!abstractType) - abstractType = sType; - else if ((abstractType->sParm.t.type != sSUBRANGE) + if (!abstractType) + abstractType = sType; + else if ((abstractType->sParm.t.type != sSUBRANGE) || (abstractType->sParm.t.subType != sType->sParm.t.subType)) error(eSUBRANGETYPE); - switch (sType->sParm.t.subType) { - case sINT : - case sCHAR : - break; - case sSCALAR : + switch (sType->sParm.t.subType) { + case sINT : + case sCHAR : + break; + case sSCALAR : if (abstractType != sType) error(eSUBRANGETYPE); - break; - default : - error(eSUBRANGETYPE); - break; - } /* end switch */ - break; + break; + default : + error(eSUBRANGETYPE); + break; + } /* end switch */ + break; } /* end switch */ } /* end if */ else error(eINVTYPE); @@ -2319,11 +2319,11 @@ static void getSetElement(setTypeStruct *s) case sSCALAR_OBJECT : /* A scalar or scalar subrange constant */ firstValue = tknPtr->sParm.c.val.i; if (!s->typeFound) { - s->typeFound = true; - s->typePtr = tknPtr->sParm.c.parent; - s->setType = sSCALAR; - s->minValue = s->typePtr->sParm.t.minValue; - s->maxValue = s->typePtr->sParm.t.maxValue; + s->typeFound = true; + s->typePtr = tknPtr->sParm.c.parent; + s->setType = sSCALAR; + s->minValue = s->typePtr->sParm.t.minValue; + s->maxValue = s->typePtr->sParm.t.maxValue; } /* end if */ else if ((s->setType != sSCALAR) || (s->typePtr != tknPtr->sParm.c.parent)) @@ -2333,8 +2333,8 @@ static void getSetElement(setTypeStruct *s) case tINT_CONST : /* An integer subrange constant ? */ firstValue = tknInt; if (!s->typeFound) { - s->typeFound = true; - s->setType = sINT; + s->typeFound = true; + s->setType = sINT; } /* end if */ else if (s->setType != sINT) error(eSET); @@ -2343,8 +2343,8 @@ static void getSetElement(setTypeStruct *s) case tCHAR_CONST : /* A character subrange constant */ firstValue = tknInt; if (!s->typeFound) { - s->typeFound = true; - s->setType = sCHAR; + s->typeFound = true; + s->setType = sCHAR; } /* end if */ else if (s->setType != sCHAR) error(eSET); @@ -2356,170 +2356,170 @@ static void getSetElement(setTypeStruct *s) getToken(); if (token != tSUBRANGE) { - /* Verify that the new value is in range */ + /* Verify that the new value is in range */ if ((firstValue < s->minValue) || (firstValue > s->maxValue)) { - error(eSETRANGE); - setValue = 0; + error(eSETRANGE); + setValue = 0; } /* end if */ else - setValue = (1 << (firstValue - s->minValue)); + setValue = (1 << (firstValue - s->minValue)); /* Now, generate P-Code to push the set value onto the stack */ - pas_GenerateDataOperation(opPUSH, setValue); + pas_GenerateDataOperation(opPUSH, setValue); } /* end if */ else { if (!s->typeFound) error(eSUBRANGETYPE); - /* Skip over the tSUBRANGE token */ + /* Skip over the tSUBRANGE token */ - getToken(); + getToken(); - /* TYPE check */ + /* TYPE check */ - switch (token) { + switch (token) { case sSCALAR_OBJECT : /* A scalar or scalar subrange constant */ - lastValue = tknPtr->sParm.c.val.i; - if ((s->setType != sSCALAR) - || (s->typePtr != tknPtr->sParm.c.parent)) - error(eSET); - goto addLottaBits; - - case tINT_CONST : /* An integer subrange constant ? */ - lastValue = tknInt; - if (s->setType != sINT) error(eSET); - goto addLottaBits; - - case tCHAR_CONST : /* A character subrange constant */ - lastValue = tknInt; - if (s->setType != sCHAR) error(eSET); - - addLottaBits : - /* Verify that the first value is in range */ - if (firstValue < s->minValue) { - error(eSETRANGE); - firstValue = s->minValue; + lastValue = tknPtr->sParm.c.val.i; + if ((s->setType != sSCALAR) + || (s->typePtr != tknPtr->sParm.c.parent)) + error(eSET); + goto addLottaBits; + + case tINT_CONST : /* An integer subrange constant ? */ + lastValue = tknInt; + if (s->setType != sINT) error(eSET); + goto addLottaBits; + + case tCHAR_CONST : /* A character subrange constant */ + lastValue = tknInt; + if (s->setType != sCHAR) error(eSET); + + addLottaBits : + /* Verify that the first value is in range */ + if (firstValue < s->minValue) { + error(eSETRANGE); + firstValue = s->minValue; } /* end if */ - else if (firstValue > s->maxValue) { - error(eSETRANGE); + else if (firstValue > s->maxValue) { + error(eSETRANGE); firstValue = s->maxValue; - } /* end else if */ + } /* end else if */ - /* Verify that the last value is in range */ - if (lastValue < firstValue) { + /* Verify that the last value is in range */ + if (lastValue < firstValue) { error(eSETRANGE); - lastValue = firstValue; + lastValue = firstValue; } /* end if */ - else if (lastValue > s->maxValue) { + else if (lastValue > s->maxValue) { error(eSETRANGE); - lastValue = s->maxValue; + lastValue = s->maxValue; } /* end else if */ - /* Set all bits from firstValue through lastValue */ + /* Set all bits from firstValue through lastValue */ - setValue = (0xffff << (firstValue - s->minValue)); - setValue &= (0xffff >> ((BITS_IN_INTEGER-1) - (lastValue - s->minValue))); + setValue = (0xffff << (firstValue - s->minValue)); + setValue &= (0xffff >> ((BITS_IN_INTEGER-1) - (lastValue - s->minValue))); /* Now, generate P-Code to push the set value onto the stack */ pas_GenerateDataOperation(opPUSH, setValue); - break; + break; case sSCALAR : - if ((!s->typePtr) - || (s->typePtr != tknPtr->sParm.v.parent)) { - error(eSET); + if ((!s->typePtr) + || (s->typePtr != tknPtr->sParm.v.parent)) { + error(eSET); if (!s->typePtr) { - s->typeFound = true; - s->typePtr = tknPtr->sParm.v.parent; - s->setType = sSCALAR; - s->minValue = s->typePtr->sParm.t.minValue; - s->maxValue = s->typePtr->sParm.t.maxValue; + s->typeFound = true; + s->typePtr = tknPtr->sParm.v.parent; + s->setType = sSCALAR; + s->minValue = s->typePtr->sParm.t.minValue; + s->maxValue = s->typePtr->sParm.t.maxValue; } /* end if */ - } /* end if */ + } /* end if */ goto addVarToBits; case sINT : /* An integer subrange variable ? */ - case sCHAR : /* A character subrange variable? */ - if (s->setType != token) error(eSET); + case sCHAR : /* A character subrange variable? */ + if (s->setType != token) error(eSET); goto addVarToBits; - case sSUBRANGE : - if ((!s->typePtr) - || (s->typePtr != tknPtr->sParm.v.parent)) { + case sSUBRANGE : + if ((!s->typePtr) + || (s->typePtr != tknPtr->sParm.v.parent)) { - if ((tknPtr->sParm.v.parent->sParm.t.subType == sSCALAR) - || (tknPtr->sParm.v.parent->sParm.t.subType != s->setType)) - error(eSET); + if ((tknPtr->sParm.v.parent->sParm.t.subType == sSCALAR) + || (tknPtr->sParm.v.parent->sParm.t.subType != s->setType)) + error(eSET); if (!s->typePtr) { - s->typeFound = true; - s->typePtr = tknPtr->sParm.v.parent; - s->setType = s->typePtr->sParm.t.subType; - s->minValue = s->typePtr->sParm.t.minValue; - s->maxValue = s->typePtr->sParm.t.maxValue; + s->typeFound = true; + s->typePtr = tknPtr->sParm.v.parent; + s->setType = s->typePtr->sParm.t.subType; + s->minValue = s->typePtr->sParm.t.minValue; + s->maxValue = s->typePtr->sParm.t.maxValue; } /* end if */ - } /* end if */ + } /* end if */ addVarToBits: - /* Verify that the first value is in range */ + /* Verify that the first value is in range */ - if (firstValue < s->minValue) { - error(eSETRANGE); - firstValue = s->minValue; + if (firstValue < s->minValue) { + error(eSETRANGE); + firstValue = s->minValue; } /* end if */ - else if (firstValue > s->maxValue) { - error(eSETRANGE); + else if (firstValue > s->maxValue) { + error(eSETRANGE); firstValue = s->maxValue; - } /* end else if */ + } /* end else if */ - /* Set all bits from firstValue through maxValue */ + /* Set all bits from firstValue through maxValue */ - setValue = (0xffff >> ((BITS_IN_INTEGER-1) - (s->maxValue - s->minValue))); - setValue &= (0xffff << (firstValue - s->minValue)); + setValue = (0xffff >> ((BITS_IN_INTEGER-1) - (s->maxValue - s->minValue))); + setValue &= (0xffff << (firstValue - s->minValue)); - /* Generate run-time logic to get all bits from firstValue */ - /* through last value, i.e., need to generate logic to get: */ - /* 0xffff >> ((BITS_IN_INTEGER-1)-(lastValue-minValue)) */ + /* Generate run-time logic to get all bits from firstValue */ + /* through last value, i.e., need to generate logic to get: */ + /* 0xffff >> ((BITS_IN_INTEGER-1)-(lastValue-minValue)) */ - pas_GenerateDataOperation(opPUSH, 0xffff); - pas_GenerateDataOperation(opPUSH, ((BITS_IN_INTEGER-1) + s->minValue)); - pas_GenerateStackReference(opLDS, tknPtr); - pas_GenerateSimple(opSUB); - pas_GenerateSimple(opSRL); + pas_GenerateDataOperation(opPUSH, 0xffff); + pas_GenerateDataOperation(opPUSH, ((BITS_IN_INTEGER-1) + s->minValue)); + pas_GenerateStackReference(opLDS, tknPtr); + pas_GenerateSimple(opSUB); + pas_GenerateSimple(opSRL); /* Then AND this with the setValue */ if (setValue != 0xffff) { - pas_GenerateDataOperation(opPUSH, setValue); - pas_GenerateSimple(opAND); + pas_GenerateDataOperation(opPUSH, setValue); + pas_GenerateSimple(opAND); } /* end if */ getToken(); break; - default : + default : error(eSET); - pas_GenerateDataOperation(opPUSH, 0); - break; + pas_GenerateDataOperation(opPUSH, 0); + break; - } /* end switch */ + } /* end switch */ } /* end else */ break; case sSCALAR : if (s->typeFound) { - if ((!s->typePtr) || (s->typePtr != tknPtr->sParm.v.parent)) + if ((!s->typePtr) || (s->typePtr != tknPtr->sParm.v.parent)) error(eSET); } /* end if */ else { s->typeFound = true; - s->typePtr = tknPtr->sParm.v.parent; - s->setType = sSCALAR; - s->minValue = s->typePtr->sParm.t.minValue; + s->typePtr = tknPtr->sParm.v.parent; + s->setType = sSCALAR; + s->minValue = s->typePtr->sParm.t.minValue; s->maxValue = s->typePtr->sParm.t.maxValue; } /* end if */ goto addVar; @@ -2527,8 +2527,8 @@ static void getSetElement(setTypeStruct *s) case sINT : /* An integer subrange variable ? */ case sCHAR : /* A character subrange variable? */ if (!s->typeFound) { - s->typeFound = true; - s->setType = token; + s->typeFound = true; + s->setType = token; } /* end if */ else if (s->setType != token) error(eSET); @@ -2536,14 +2536,14 @@ static void getSetElement(setTypeStruct *s) case sSUBRANGE : if (s->typeFound) { - if ((!s->typePtr) || (s->typePtr != tknPtr->sParm.v.parent)) + if ((!s->typePtr) || (s->typePtr != tknPtr->sParm.v.parent)) error(eSET); } /* end if */ else { s->typeFound = true; - s->typePtr = tknPtr->sParm.v.parent; - s->setType = s->typePtr->sParm.t.subType; - s->minValue = s->typePtr->sParm.t.minValue; + s->typePtr = tknPtr->sParm.v.parent; + s->setType = s->typePtr->sParm.t.subType; + s->minValue = s->typePtr->sParm.t.minValue; s->maxValue = s->typePtr->sParm.t.maxValue; } /* end if */ @@ -2555,130 +2555,130 @@ static void getSetElement(setTypeStruct *s) getToken(); if (token != tSUBRANGE) { - /* Generate P-Code to push the set value onto the stack */ + /* Generate P-Code to push the set value onto the stack */ /* FORM: 1 << (firstValue - minValue) */ pas_GenerateDataOperation(opPUSH, 1); - pas_GenerateStackReference(opLDS, setPtr); - pas_GenerateDataOperation(opPUSH, s->minValue); - pas_GenerateSimple(opSUB); - pas_GenerateSimple(opSLL); + pas_GenerateStackReference(opLDS, setPtr); + pas_GenerateDataOperation(opPUSH, s->minValue); + pas_GenerateSimple(opSUB); + pas_GenerateSimple(opSLL); } /* end if */ else { if (!s->typeFound) error(eSUBRANGETYPE); - /* Skip over the tSUBRANGE token */ + /* Skip over the tSUBRANGE token */ - getToken(); + getToken(); - /* TYPE check */ + /* TYPE check */ - switch (token) { + switch (token) { case sSCALAR_OBJECT : /* A scalar or scalar subrange constant */ - lastValue = tknPtr->sParm.c.val.i; - if ((s->setType != sSCALAR) - || (s->typePtr != tknPtr->sParm.c.parent)) - error(eSET); - goto addBitsToVar; + lastValue = tknPtr->sParm.c.val.i; + if ((s->setType != sSCALAR) + || (s->typePtr != tknPtr->sParm.c.parent)) + error(eSET); + goto addBitsToVar; - case tINT_CONST : /* An integer subrange constant ? */ - lastValue = tknInt; - if (s->setType != sINT) error(eSET); - goto addBitsToVar; + case tINT_CONST : /* An integer subrange constant ? */ + lastValue = tknInt; + if (s->setType != sINT) error(eSET); + goto addBitsToVar; - case tCHAR_CONST : /* A character subrange constant */ - lastValue = tknInt; - if (s->setType != sCHAR) error(eSET); + case tCHAR_CONST : /* A character subrange constant */ + lastValue = tknInt; + if (s->setType != sCHAR) error(eSET); - addBitsToVar : - /* Verify that the last value is in range */ + addBitsToVar : + /* Verify that the last value is in range */ - if (lastValue < s->minValue) { + if (lastValue < s->minValue) { error(eSETRANGE); - lastValue = s->minValue; + lastValue = s->minValue; } /* end if */ - else if (lastValue > s->maxValue) { + else if (lastValue > s->maxValue) { error(eSETRANGE); - lastValue = s->maxValue; + lastValue = s->maxValue; } /* end else if */ - /* Set all bits from minValue through lastValue */ + /* Set all bits from minValue through lastValue */ - setValue = (0xffff >> ((BITS_IN_INTEGER-1) - (lastValue - s->minValue))); + setValue = (0xffff >> ((BITS_IN_INTEGER-1) - (lastValue - s->minValue))); /* Now, generate P-Code to push the set value onto the stack */ - /* First generate: 0xffff << (firstValue-minValue) */ + /* First generate: 0xffff << (firstValue-minValue) */ - pas_GenerateDataOperation(opPUSH, 0xffff); - pas_GenerateStackReference(opLDS, setPtr); + pas_GenerateDataOperation(opPUSH, 0xffff); + pas_GenerateStackReference(opLDS, setPtr); if (s->minValue) { - pas_GenerateDataOperation(opPUSH, s->minValue); - pas_GenerateSimple(opSUB); + pas_GenerateDataOperation(opPUSH, s->minValue); + pas_GenerateSimple(opSUB); } /* end if */ - pas_GenerateSimple(opSLL); + pas_GenerateSimple(opSLL); /* Then and this with the pre-computed constant set value */ if (setValue != 0xffff) { - pas_GenerateDataOperation(opPUSH, setValue); - pas_GenerateSimple(opAND); + pas_GenerateDataOperation(opPUSH, setValue); + pas_GenerateSimple(opAND); } /* end if */ getToken(); - break; + break; case sINT : /* An integer subrange variable ? */ case sCHAR : /* A character subrange variable? */ if (s->setType != token) error(eSET); - goto addVarToVar; + goto addVarToVar; - case sSCALAR : - if (s->typePtr != tknPtr->sParm.v.parent) error(eSET); - goto addVarToVar; + case sSCALAR : + if (s->typePtr != tknPtr->sParm.v.parent) error(eSET); + goto addVarToVar; - case sSUBRANGE : - if ((s->typePtr != tknPtr->sParm.v.parent) - && ((tknPtr->sParm.v.parent->sParm.t.subType == sSCALAR) + case sSUBRANGE : + if ((s->typePtr != tknPtr->sParm.v.parent) + && ((tknPtr->sParm.v.parent->sParm.t.subType == sSCALAR) || (tknPtr->sParm.v.parent->sParm.t.subType != s->setType))) - error(eSET); + error(eSET); addVarToVar: - /* Generate run-time logic to get all bits from firstValue */ - /* through lastValue */ - /* First generate: 0xffff << (firstValue-minValue) */ + /* Generate run-time logic to get all bits from firstValue */ + /* through lastValue */ + /* First generate: 0xffff << (firstValue-minValue) */ - pas_GenerateDataOperation(opPUSH, 0xffff); - pas_GenerateStackReference(opLDS, setPtr); - if (s->minValue) { - pas_GenerateDataOperation(opPUSH, s->minValue); - pas_GenerateSimple(opSUB); + pas_GenerateDataOperation(opPUSH, 0xffff); + pas_GenerateStackReference(opLDS, setPtr); + if (s->minValue) { + pas_GenerateDataOperation(opPUSH, s->minValue); + pas_GenerateSimple(opSUB); } /* end if */ - pas_GenerateSimple(opSLL); + pas_GenerateSimple(opSLL); - /* Generate logic to get: */ - /* 0xffff >> ((BITS_IN_INTEGER-1)-(lastValue-minValue)) */ + /* Generate logic to get: */ + /* 0xffff >> ((BITS_IN_INTEGER-1)-(lastValue-minValue)) */ - pas_GenerateDataOperation(opPUSH, 0xffff); - pas_GenerateDataOperation(opPUSH, ((BITS_IN_INTEGER-1) + s->minValue)); - pas_GenerateStackReference(opLDS, tknPtr); - pas_GenerateSimple(opSUB); - pas_GenerateSimple(opSRL); + pas_GenerateDataOperation(opPUSH, 0xffff); + pas_GenerateDataOperation(opPUSH, ((BITS_IN_INTEGER-1) + s->minValue)); + pas_GenerateStackReference(opLDS, tknPtr); + pas_GenerateSimple(opSUB); + pas_GenerateSimple(opSRL); /* Then AND the two values */ - pas_GenerateSimple(opAND); + pas_GenerateSimple(opAND); - getToken(); + getToken(); break; - default : + default : error(eSET); - pas_GenerateDataOperation(opPUSH, 0); - break; + pas_GenerateDataOperation(opPUSH, 0); + break; - } /* end switch */ + } /* end switch */ } /* end else */ break; diff --git a/misc/pascal/pascal/pffunc.c b/misc/pascal/pascal/pffunc.c index 0820272ae..b2e985016 100644 --- a/misc/pascal/pascal/pffunc.c +++ b/misc/pascal/pascal/pffunc.c @@ -129,7 +129,7 @@ exprType builtInFunction(void) expression(exprReal, NULL); pas_GenerateFpOperation(fpROUND); funcType = exprInteger; - break; + break; case txTRUNC : getToken(); /* Skip over 'trunc' */ expression(exprReal, NULL); @@ -447,6 +447,6 @@ static exprType getenvFunc(void) pas_BuiltInFunctionCall(lbGETENV); checkRParen(); return exprCString; -} +} /***********************************************************************/ diff --git a/misc/pascal/pascal/pproc.c b/misc/pascal/pascal/pproc.c index df02e11a1..960b44a27 100644 --- a/misc/pascal/pascal/pproc.c +++ b/misc/pascal/pascal/pproc.c @@ -120,7 +120,7 @@ void builtInProcedure(void) fileProc(xWRITE_PAGE); break; - case txREAD : + case txREAD : getToken(); (void)readProc(); break; @@ -137,7 +137,7 @@ void builtInProcedure(void) fileProc(xREWRITE); break; - case txWRITE : + case txWRITE : getToken(); (void)writeProc(); break; @@ -146,11 +146,11 @@ void builtInProcedure(void) writelnProc(); break; - case txGET : - case txNEW : - case txPACK : - case txPUT : - case txUNPACK : + case txGET : + case txNEW : + case txPACK : + case txPUT : + case txUNPACK : error(eNOTYET); getToken(); break; @@ -161,7 +161,7 @@ void builtInProcedure(void) break; /* Its not a recognized procedure */ - + default : error(eINVALIDPROC); break; @@ -489,7 +489,7 @@ static void readlnProc(void) /* READLN procedure */ } /* end readlnProc */ /****************************************************************************/ -/* REWRITE/RESET/PAGE procedure call -- REWRITE sets the file pointer to the +/* REWRITE/RESET/PAGE procedure call -- REWRITE sets the file pointer to the * beginning of the file and prepares the file for write access; RESET is * similar except that it prepares the file for read access; PAGE simply * writes a form-feed to the file (no check is made, but is meaningful only @@ -698,7 +698,7 @@ static void valProc(void) /* VAL procedure */ TRACE(lstFile, "[valProc]"); /* Declaration: - * procedure val(const S : string; var V; var Code : word); + * procedure val(const S : string; var V; var Code : word); * * Description: * val() converts the value represented in the string S to a numerical @@ -713,7 +713,7 @@ static void valProc(void) /* VAL procedure */ * * Errors: * If the conversion doesn��t succeed, the value of Code indicates the - * position where the conversion went wrong. + * position where the conversion went wrong. */ /* Skip over the 'val' identifer */ diff --git a/misc/pascal/pascal/pstm.c b/misc/pascal/pascal/pstm.c index ee3730800..bac8a18fa 100644 --- a/misc/pascal/pascal/pstm.c +++ b/misc/pascal/pascal/pstm.c @@ -266,7 +266,7 @@ static void pas_SimpleAssignment(STYPE *varPtr, uint8_t assignFlags) } /* end if */ else if ((assignFlags & ADDRESS_ASSIGNMENT) != 0) pas_Assignment(opSTSX, exprIntegerPtr, varPtr, typePtr); - else + else pas_Assignment(opSTSX, exprInteger, varPtr, typePtr); } /* end if */ else @@ -292,7 +292,7 @@ static void pas_SimpleAssignment(STYPE *varPtr, uint8_t assignFlags) } /* end if */ else if ((assignFlags & ADDRESS_ASSIGNMENT) != 0) pas_Assignment(opSTSX, exprCharPtr, varPtr, typePtr); - else + else pas_Assignment(opSTSXB, exprChar, varPtr, typePtr); } /* end if */ else @@ -318,7 +318,7 @@ static void pas_SimpleAssignment(STYPE *varPtr, uint8_t assignFlags) } /* end if */ else if ((assignFlags & ADDRESS_ASSIGNMENT) != 0) pas_Assignment(opSTSX, exprBooleanPtr, varPtr, typePtr); - else + else pas_Assignment(opSTSX, exprBoolean, varPtr, NULL); } /* end if */ else @@ -344,7 +344,7 @@ static void pas_SimpleAssignment(STYPE *varPtr, uint8_t assignFlags) } /* end if */ else if ((assignFlags & ADDRESS_ASSIGNMENT) != 0) pas_Assignment(opSTSX, exprRealPtr, varPtr, typePtr); - else + else pas_LargeAssignment(opSTSXM, exprReal, varPtr, typePtr); } /* end if */ else @@ -370,7 +370,7 @@ static void pas_SimpleAssignment(STYPE *varPtr, uint8_t assignFlags) } /* end if */ else if ((assignFlags & ADDRESS_ASSIGNMENT) != 0) pas_Assignment(opSTSX, exprScalarPtr, varPtr, typePtr); - else + else pas_Assignment(opSTSX, exprScalar, varPtr, typePtr); } /* end if */ else @@ -396,7 +396,7 @@ static void pas_SimpleAssignment(STYPE *varPtr, uint8_t assignFlags) } /* end if */ else if ((assignFlags & ADDRESS_ASSIGNMENT) != 0) pas_Assignment(opSTSX, exprSetPtr, varPtr, typePtr); - else + else pas_Assignment(opSTSX, exprSet, varPtr, typePtr); } /* end if */ else @@ -888,7 +888,7 @@ static void pas_ProcStatement(void) /* Generate procedure call and stack adjustment (if required) * Upon return from the procedure, the level stack pointer (LSP) - * may also be invalid. However, we rely on level level logic in + * may also be invalid. However, we rely on level level logic in * pgen.c to manage this case (as well as the function call case). */ @@ -1143,7 +1143,7 @@ static void pas_WhileStatement(void) pas_GenerateDataOperation(opLABEL, endwhile_label); /* We always get here from the check at the top of the loop. - * Normally this will be from the branch from the bottom of + * Normally this will be from the branch from the bottom of * the loop to the top of the loop. Then from the conditional * branch at the top of the loop to here. * @@ -1290,7 +1290,7 @@ static void pas_CaseStatement(void) * NOTE: We accept any kind of constant for the case selector; there * really should be some check to assure that the constant is of the * same type as the expression! - */ + */ else { @@ -1518,7 +1518,7 @@ static void pas_ForStatement(void) pas_GenerateDataOperation(opINDS, -sINT_SIZE); /* We always get here from the check at the top of the loop. - * Normally this will be from the branch from the bottom of + * Normally this will be from the branch from the bottom of * the loop to the top of the loop. Then from the conditional * branch at the top of the loop to here. * diff --git a/misc/pascal/pascal/ptbl.c b/misc/pascal/pascal/ptbl.c index e77652aec..333feac99 100644 --- a/misc/pascal/pascal/ptbl.c +++ b/misc/pascal/pascal/ptbl.c @@ -175,7 +175,7 @@ const RTYPE *findReservedWord (char *name) return (RTYPE*)NULL; /* return NULL pointer if no match */ -} /* fnd findReservedWord */ +} /* fnd findReservedWord */ /***************************************************************/ @@ -681,7 +681,7 @@ void dumpTables(void) default : fprintf(lstFile, "Unknown sKind\n"); break; - + } /* end switch */ } /* end for */ diff --git a/misc/pascal/pascal/ptdefs.h b/misc/pascal/pascal/ptdefs.h index 7d3ce55c1..01f00079e 100644 --- a/misc/pascal/pascal/ptdefs.h +++ b/misc/pascal/pascal/ptdefs.h @@ -100,7 +100,7 @@ /* Token Values 0x80-0xef are for RESERVED WORDS */ -/* Standard constants (TRUE, FALSE, MAXINT) and standard files (INPUT, OUTPUT) +/* Standard constants (TRUE, FALSE, MAXINT) and standard files (INPUT, OUTPUT) * are hard initialized into the constant/symbol table and are transparent * to the compiler */ diff --git a/misc/pascal/pascal/ptkn.c b/misc/pascal/pascal/ptkn.c index 192f5f817..dad58fa23 100644 --- a/misc/pascal/pascal/ptkn.c +++ b/misc/pascal/pascal/ptkn.c @@ -178,7 +178,7 @@ char getNextCharacter(bool skipWhiteSpace) /* If it is a space and we have been told to skip spaces then consume * the input line until a non-space or the EOL is encountered. - */ + */ else if (skipWhiteSpace) { @@ -393,7 +393,7 @@ void getToken(void) DEBUG(lstFile,"[%02x]", token); -} /* End getToken */ +} /* End getToken */ /*************************************************************** * Private Functions @@ -452,7 +452,7 @@ static void identifier(void) } /* end else */ -} /* End identifier */ +} /* End identifier */ /***************************************************************/ /* Process string */ diff --git a/misc/pascal/pascal/punit.c b/misc/pascal/pascal/punit.c index 00b74e18b..a131d9540 100644 --- a/misc/pascal/pascal/punit.c +++ b/misc/pascal/pascal/punit.c @@ -355,7 +355,7 @@ static void interfaceSection(void) /* Process the exported-heading * - * FORM: exported-heading = + * FORM: exported-heading = * procedure-heading ';' [ directive ] | * function-heading ';' [ directive ] */ @@ -458,8 +458,8 @@ static void exportedProcedureHeading(void) if (token != ';') error (eSEMICOLON); else getToken(); - /* If we are compiling a program or unit that "imports" the - * procedure then generate the appropriate symbol table entries + /* If we are compiling a program or unit that "imports" the + * procedure then generate the appropriate symbol table entries * in the output file to support relocation when the external * procedure is called. */ @@ -573,8 +573,8 @@ static void exportedFunctionHeading(void) if (token != ';') error (eSEMICOLON); else getToken(); - /* If we are compiling a program or unit that "imports" the - * function then generate the appropriate symbol table entries + /* If we are compiling a program or unit that "imports" the + * function then generate the appropriate symbol table entries * in the output file to support relocation when the external * function is called. */ diff --git a/misc/pascal/plink/plink.c b/misc/pascal/plink/plink.c index 0e9c15078..e4c2c69e0 100644 --- a/misc/pascal/plink/plink.c +++ b/misc/pascal/plink/plink.c @@ -401,7 +401,7 @@ static uint32_t mergeRoData(poffHandle_t inHandle, poffHandle_t outHandle) return oldRoDataSize; } - + /***********************************************************************/ /* This function merges the program data section of a new file into the * program data section of the output file, relocating simple program diff --git a/misc/pascal/plink/plsym.c b/misc/pascal/plink/plsym.c index 3f27f512b..ed3f54d01 100644 --- a/misc/pascal/plink/plsym.c +++ b/misc/pascal/plink/plsym.c @@ -325,8 +325,8 @@ static symContainer_t *insertSymbol(poffLibSymbol_t *sym) } /* We get here if: - * a. curr == NULL meaning that the symbol goes at the end of the - * list. (special case, prev == NULL as well. This happens when + * a. curr == NULL meaning that the symbol goes at the end of the + * list. (special case, prev == NULL as well. This happens when * the list is empty). * b. curr != NULL mean that the symbol goes between prev and curr * (special cases: (i) compare == 0 meaning that the symbol is @@ -406,7 +406,7 @@ static symContainer_t *insertSymbol(poffLibSymbol_t *sym) newsym = makeSymContainer(sym); newsym->next = curr; newsym->prev = prev; - + if (prev) prev->next = newsym; else diff --git a/misc/pascal/tests/src/006-optconst.pas b/misc/pascal/tests/src/006-optconst.pas index 511d807eb..43f50adb4 100644 --- a/misc/pascal/tests/src/006-optconst.pas +++ b/misc/pascal/tests/src/006-optconst.pas @@ -1,7 +1,7 @@ { A test of constant optimiztion } program constopt; -var +var i1, i2, i3 : integer; b1 : boolean begin @@ -11,7 +11,7 @@ begin 3. *, DIV, AND, SHL, SHR 4. -, NOT } - + i1 := -2; { -2 } i1 := 3 * 2; { 6 } i1 := 3 * (-2); { -6 } diff --git a/misc/pascal/tests/src/202-strcmp.pas b/misc/pascal/tests/src/202-strcmp.pas index cff214403..60c48f5b4 100644 --- a/misc/pascal/tests/src/202-strcmp.pas +++ b/misc/pascal/tests/src/202-strcmp.pas @@ -6,7 +6,7 @@ CONST lexmiddle2 = 'ZZZLexically Middl'; lexsmall = 'AAALexically Small'; lexnothing = '' -VAR +VAR string1, string2 : string; BEGIN IF (lexbig <= lexmiddle) THEN @@ -18,22 +18,22 @@ BEGIN writeln('ERROR: ', lexmiddle, ' > ', lexmiddle1) else writeln('OKAY: ', lexmiddle, ' <= ', lexmiddle1); - + IF (lexmiddle <> lexmiddle) THEN writeln('ERROR: ', lexmiddle, ' <> ', lexmiddle) else writeln('OKAY: ', lexmiddle, ' = ', lexmiddle); - + IF (lexmiddle = lexnothing) THEN writeln('ERROR: ', lexmiddle, ' = ', lexnothing) else writeln('OKAY: ', lexmiddle, ' <> ', lexnothing); - + IF (lexnothing <> lexnothing) THEN writeln('ERROR: ', lexnothing, ' <> ', lexnothing) else writeln('OKAY: ', lexnothing, ' = ', lexnothing); - + IF (lexmiddle < lexmiddle2) THEN writeln('ERROR: ', lexmiddle, ' < ', lexmiddle2) else @@ -43,5 +43,5 @@ BEGIN writeln('ERROR: ', lexsmall, ' >= ', lexmiddle) else writeln('OKAY: ', lexsmall, ' < ', lexmiddle) - + END. diff --git a/misc/pascal/tests/src/501-uses.pas b/misc/pascal/tests/src/501-uses.pas index 49c3cdaac..1b34add48 100644 --- a/misc/pascal/tests/src/501-uses.pas +++ b/misc/pascal/tests/src/501-uses.pas @@ -1,5 +1,5 @@ program MyProgram; - + uses MyCosineUnit in '501-unit-cosine.pas'; MySineUnit in '501-unit-sine.pas'; @@ -7,7 +7,7 @@ uses var x : real; - + begin write('Enter radians : '); read(x); diff --git a/misc/pascal/tests/src/803-redirect.pas b/misc/pascal/tests/src/803-redirect.pas index d53acc1e1..27afb5165 100644 --- a/misc/pascal/tests/src/803-redirect.pas +++ b/misc/pascal/tests/src/803-redirect.pas @@ -71,7 +71,7 @@ var NewLocation := BASE + value end else - ; (* do nothing we have an undefined form element *) + ; (* do nothing we have an undefined form element *) end; begin (* ProcessCGIData *) diff --git a/misc/pascal/tests/src/804-cgiform.pas b/misc/pascal/tests/src/804-cgiform.pas index e3043f548..0c94290ec 100644 --- a/misc/pascal/tests/src/804-cgiform.pas +++ b/misc/pascal/tests/src/804-cgiform.pas @@ -258,7 +258,7 @@ var GenerateBody; GenerateFooter; end; (* GenerateResponse *) - + procedure Shutdown; begin (* Shutdown *) dispose(NameValuePairs); diff --git a/misc/pascal/tests/src/805-cgimail.pas b/misc/pascal/tests/src/805-cgimail.pas index 5b16f8d52..fbb490229 100644 --- a/misc/pascal/tests/src/805-cgimail.pas +++ b/misc/pascal/tests/src/805-cgimail.pas @@ -254,7 +254,7 @@ var writeln(pipe, '.'); close(pipe); end; //SendEmailWithSendMail - + //*************************************************************** //PURPOSE: Sends and email message using the CDONTS components //NOTE: The CDONTS components were created by Microsoft to diff --git a/misc/pascal/tests/src/806-cgicook.pas b/misc/pascal/tests/src/806-cgicook.pas index 7da5ecffd..a7d2fa5fa 100644 --- a/misc/pascal/tests/src/806-cgicook.pas +++ b/misc/pascal/tests/src/806-cgicook.pas @@ -436,7 +436,7 @@ var begin (* GenerateBodyData *) writeln('<tr>'); writeln('<td width="100%">'); - + //Generate the HTML to display the cookies returned by the browser. writeln('<h1>Current Cookies</h1>'); iNumCookies := length(Cookies); //Number of cookies returned by the browser diff --git a/misc/pascal/tests/src/901-pageutils.pas b/misc/pascal/tests/src/901-pageutils.pas index 855620b1c..f78120eef 100644 --- a/misc/pascal/tests/src/901-pageutils.pas +++ b/misc/pascal/tests/src/901-pageutils.pas @@ -5268,7 +5268,7 @@ END; { change_const_line } { ************************* set_line_flags ******************************** } -PROCEDURE set_line_flags +PROCEDURE set_line_flags (page: page_pointer; ind: short; select, attribute: char; get_line_pointer: get_line_pointer_type) ; @@ -5301,7 +5301,7 @@ END; { set_line_flags } { ************************* get_line_flags ******************************** } -PROCEDURE get_line_flags +PROCEDURE get_line_flags (page: page_pointer; ind: short; VAR select, attribute: char; get_line_pointer: get_line_pointer_type) ; @@ -5326,7 +5326,7 @@ END; { get_line_flags } { ************************* is_selected *********************************** } -FUNCTION is_selected +FUNCTION is_selected (list: list_cb_type; page: page_pointer; ind: short; get_line_pointer: get_line_pointer_type): boolean ; @@ -5360,7 +5360,7 @@ END; { is_selected } { ************************* set_list_line_flags *************************** } -PROCEDURE set_list_line_flags +PROCEDURE set_list_line_flags (VAR list: list_cb_type; select, attribute: char; get_line_pointer: get_line_pointer_type ) ; @@ -5384,7 +5384,7 @@ END; { set_list_line_flags } { ************************* get_next_selected_line ************************ } -PROCEDURE get_next_selected_line +PROCEDURE get_next_selected_line (VAR list: list_cb_type; VAR page: page_pointer; VAR ind: short; get_line_pointer: get_line_pointer_type) ; @@ -5408,7 +5408,7 @@ END; { get_next_selected_line } { ************************* get_prev_selected_line ************************ } -PROCEDURE get_prev_selected_line +PROCEDURE get_prev_selected_line (VAR list: list_cb_type; VAR page: page_pointer; VAR ind: short; get_line_pointer: get_line_pointer_type) ; @@ -5432,7 +5432,7 @@ END; { get_prev_selected_line } { ************************* get_first_selected_line_m *********************** } -PROCEDURE get_first_selected_line_m +PROCEDURE get_first_selected_line_m (VAR list: list_cb_type; VAR page: page_pointer; VAR ind: short; get_line_pointer: get_line_pointer_type) ; @@ -5453,7 +5453,7 @@ END; { get_first_selected_line_m } { ************************* get_first_selected_line ************************ } -PROCEDURE get_first_selected_line +PROCEDURE get_first_selected_line (VAR list: list_cb_type; VAR page: page_pointer; VAR ind: short; get_line_pointer: get_line_pointer_type) ; |