Protoize
command: protoize -c '-m32 -DTARGET_CPU=CPU_6502' -g $(ls *.c | grep -v 68)
This commit is contained in:
parent
b9748cbe0e
commit
e10a35e3e1
107
actions_6502.c
107
actions_6502.c
|
@ -45,11 +45,19 @@
|
||||||
and operand.
|
and operand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
actionsDir1(opcode, numberOfOperands, evaluatedOperands)
|
bool isByteAddress (valueType *value);
|
||||||
opcodeTableEntryType *opcode;
|
bool isDefined (valueType *value);
|
||||||
int numberOfOperands;
|
extern void emitByte (byte byteValue);
|
||||||
valueType *evaluatedOperands[];
|
bool wordCheck (int value);
|
||||||
|
extern void putFixupsHere (fixupKindType kindOfFixupsToPut, int whichFixup);
|
||||||
|
extern void emitWord (wordType wordValue);
|
||||||
|
bool byteCheck (int value);
|
||||||
|
bool isByteOffset (int value);
|
||||||
|
extern void error (errorType theError, ...);
|
||||||
|
|
||||||
|
void
|
||||||
|
actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
{
|
{
|
||||||
#define ZERO_PAGE_ADDRESS_BIT 0x00
|
#define ZERO_PAGE_ADDRESS_BIT 0x00
|
||||||
#define NON_ZERO_PAGE_ADDRESS_BIT 0x08
|
#define NON_ZERO_PAGE_ADDRESS_BIT 0x08
|
||||||
|
@ -66,10 +74,7 @@ actionsDir1(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsDir2(opcode, numberOfOperands, evaluatedOperands)
|
actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
if (wordCheck(address)) {
|
if (wordCheck(address)) {
|
||||||
emitByte(binary);
|
emitByte(binary);
|
||||||
|
@ -79,10 +84,7 @@ actionsDir2(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsDirIndir(opcode, numberOfOperands, evaluatedOperands)
|
actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define DIRECT_ADDRESS_BIT 0x00
|
#define DIRECT_ADDRESS_BIT 0x00
|
||||||
#define INDIRECT_ADDRESS_BIT 0x20
|
#define INDIRECT_ADDRESS_BIT 0x20
|
||||||
|
@ -98,10 +100,7 @@ actionsDirIndir(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsDirX1(opcode, numberOfOperands, evaluatedOperands)
|
actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X1 0x04
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X1 0x04
|
||||||
#define A_REGISTER_BITS_X1 0x08
|
#define A_REGISTER_BITS_X1 0x08
|
||||||
|
@ -133,10 +132,7 @@ actionsDirX1(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsDirX2(opcode, numberOfOperands, evaluatedOperands)
|
actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X2 0x00
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_X2 0x00
|
||||||
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_X2 0x08
|
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_X2 0x08
|
||||||
|
@ -165,10 +161,7 @@ actionsDirX2(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsDirX3(opcode, numberOfOperands, evaluatedOperands)
|
actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
if (class == EXPRESSION_OPND) {
|
if (class == EXPRESSION_OPND) {
|
||||||
if (isByteAddress(operand) && isDefined(operand)) {
|
if (isByteAddress(operand) && isDefined(operand)) {
|
||||||
|
@ -189,10 +182,7 @@ actionsDirX3(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsDirY(opcode, numberOfOperands, evaluatedOperands)
|
actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_Y 0x00
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_Y 0x00
|
||||||
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_Y 0x08
|
#define DIRECT_ADDRESS_NON_ZERO_PAGE_BITS_Y 0x08
|
||||||
|
@ -217,10 +207,7 @@ actionsDirY(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsImmDir(opcode, numberOfOperands, evaluatedOperands)
|
actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define IMMEDIATE_DATA_BITS_ID 0x00
|
#define IMMEDIATE_DATA_BITS_ID 0x00
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_ID 0x04
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_ID 0x04
|
||||||
|
@ -245,10 +232,7 @@ actionsImmDir(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsImmDirX(opcode, numberOfOperands, evaluatedOperands)
|
actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define IMMEDIATE_DATA_BITS_IX 0x00
|
#define IMMEDIATE_DATA_BITS_IX 0x00
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IX 0x04
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IX 0x04
|
||||||
|
@ -284,10 +268,7 @@ actionsImmDirX(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsImmDirY(opcode, numberOfOperands, evaluatedOperands)
|
actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define IMMEDIATE_DATA_BITS_IY 0x00
|
#define IMMEDIATE_DATA_BITS_IY 0x00
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IY 0x04
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_IY 0x04
|
||||||
|
@ -323,10 +304,7 @@ actionsImmDirY(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsImmIndex(opcode, numberOfOperands, evaluatedOperands)
|
actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
#define PRE_INDEXED_BITS_A 0x00
|
#define PRE_INDEXED_BITS_A 0x00
|
||||||
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_A 0x04
|
#define DIRECT_ADDRESS_ZERO_PAGE_BITS_A 0x04
|
||||||
|
@ -383,10 +361,7 @@ actionsImmIndex(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsIndex(opcode, numberOfOperands, evaluatedOperands)
|
actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
if (class == EXPRESSION_OPND) {
|
if (class == EXPRESSION_OPND) {
|
||||||
if (isByteAddress(operand) && isDefined(operand)) {
|
if (isByteAddress(operand) && isDefined(operand)) {
|
||||||
|
@ -428,19 +403,13 @@ actionsIndex(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsNone(opcode, numberOfOperands, evaluatedOperands)
|
actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
emitByte(binary);
|
emitByte(binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
actionsRelative(opcode, numberOfOperands, evaluatedOperands)
|
actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
@ -465,43 +434,37 @@ actionsRelative(opcode, numberOfOperands, evaluatedOperands)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isByte(value)
|
isByte(int value)
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
return (-129<value && value<256);
|
return (-129<value && value<256);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isByteOffset(value)
|
isByteOffset(int value)
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
return (-129<value && value<128);
|
return (-129<value && value<128);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isWordOffset(value)
|
isWordOffset(int value)
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
return (-32769<value && value<32768);
|
return (-32769<value && value<32768);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isByteAddress(value)
|
isByteAddress(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
return(value->kindOfValue==ABSOLUTE_VALUE && isByte(value->value));
|
return(value->kindOfValue==ABSOLUTE_VALUE && isByte(value->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isWord(value)
|
isWord(int value)
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
return (-32769<value && value<65536);
|
return (-32769<value && value<65536);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
byteCheck(value)
|
byteCheck(int value)
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
if (isByte(value)) {
|
if (isByte(value)) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
@ -512,8 +475,7 @@ byteCheck(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
wordCheck(value)
|
wordCheck(int value)
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
if (isWord(value)) {
|
if (isWord(value)) {
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
|
@ -525,8 +487,7 @@ wordCheck(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isDefined(value)
|
isDefined(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE);
|
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE);
|
||||||
}
|
}
|
||||||
|
|
164
buildStuff1.c
164
buildStuff1.c
|
@ -33,14 +33,16 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
char *saveString();
|
char *saveString(char *s);
|
||||||
|
|
||||||
/* Generic routine to create statement nodes */
|
/* Generic routine to create statement nodes */
|
||||||
statementType *
|
|
||||||
newStatement(kind, body)
|
extern void botch (char *message, ...);
|
||||||
statementKindType kind;
|
extern void error (errorType theError, ...);
|
||||||
statementBodyType body;
|
|
||||||
|
statementType *
|
||||||
|
newStatement(statementKindType kind, statementBodyType body)
|
||||||
{
|
{
|
||||||
statementType *result;
|
statementType *result;
|
||||||
|
|
||||||
|
@ -62,17 +64,14 @@ newStatement(kind, body)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildAlignStatement(expression)
|
buildAlignStatement(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
return(newStatement(ALIGN_STATEMENT,
|
return(newStatement(ALIGN_STATEMENT,
|
||||||
(statementBodyType) expression));
|
(statementBodyType) expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildAssertStatement(condition, message)
|
buildAssertStatement(expressionType *condition, expressionType *message)
|
||||||
expressionType *condition;
|
|
||||||
expressionType *message;
|
|
||||||
{
|
{
|
||||||
assertStatementBodyType *result;
|
assertStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -84,25 +83,21 @@ buildAssertStatement(condition, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildBlockStatement(expressionList)
|
buildBlockStatement(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(BLOCK_STATEMENT,
|
return(newStatement(BLOCK_STATEMENT,
|
||||||
(statementBodyType) expressionList));
|
(statementBodyType) expressionList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildByteStatement(expressionList)
|
buildByteStatement(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(BYTE_STATEMENT,
|
return(newStatement(BYTE_STATEMENT,
|
||||||
(statementBodyType) expressionList));
|
(statementBodyType) expressionList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildConstrainStatement(expression, block)
|
buildConstrainStatement(expressionType *expression, blockType *block)
|
||||||
expressionType *expression;
|
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
constrainStatementBodyType *result;
|
constrainStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -114,17 +109,14 @@ buildConstrainStatement(expression, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildDbyteStatement(expressionList)
|
buildDbyteStatement(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(DBYTE_STATEMENT,
|
return(newStatement(DBYTE_STATEMENT,
|
||||||
(statementBodyType) expressionList));
|
(statementBodyType) expressionList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildDefineStatement(name, value)
|
buildDefineStatement(stringType *name, expressionType *value)
|
||||||
stringType *name;
|
|
||||||
expressionType *value;
|
|
||||||
{
|
{
|
||||||
defineStatementBodyType *result;
|
defineStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -135,9 +127,7 @@ buildDefineStatement(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildDoUntilStatement(body, condition)
|
buildDoUntilStatement(blockType *body, conditionType condition)
|
||||||
blockType *body;
|
|
||||||
conditionType condition;
|
|
||||||
{
|
{
|
||||||
doUntilStatementBodyType *result;
|
doUntilStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -148,9 +138,7 @@ buildDoUntilStatement(body, condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildDoWhileStatement(body, condition)
|
buildDoWhileStatement(blockType *body, conditionType condition)
|
||||||
blockType *body;
|
|
||||||
conditionType condition;
|
|
||||||
{
|
{
|
||||||
doWhileStatementBodyType *result;
|
doWhileStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -161,9 +149,7 @@ buildDoWhileStatement(body, condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildDoStatement(body, end)
|
buildDoStatement(blockType *body, doEndType *end)
|
||||||
blockType *body;
|
|
||||||
doEndType *end;
|
|
||||||
{
|
{
|
||||||
statementType *result;
|
statementType *result;
|
||||||
|
|
||||||
|
@ -178,26 +164,21 @@ buildDoStatement(body, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildExternStatement(identifierList)
|
buildExternStatement(identifierListType *identifierList)
|
||||||
identifierListType *identifierList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(EXTERN_STATEMENT,
|
return(newStatement(EXTERN_STATEMENT,
|
||||||
(statementBodyType) identifierList));
|
(statementBodyType) identifierList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildFreturnStatement(expression)
|
buildFreturnStatement(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
return(newStatement(FRETURN_STATEMENT,
|
return(newStatement(FRETURN_STATEMENT,
|
||||||
(statementBodyType) expression));
|
(statementBodyType) expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildFunctionStatement(name, arguments, body)
|
buildFunctionStatement(stringType *name, argumentDefinitionListType *arguments, blockType *body)
|
||||||
stringType *name;
|
|
||||||
argumentDefinitionListType *arguments;
|
|
||||||
blockType *body;
|
|
||||||
{
|
{
|
||||||
functionStatementBodyType *result;
|
functionStatementBodyType *result;
|
||||||
symbolTableEntryType *testSymbol;
|
symbolTableEntryType *testSymbol;
|
||||||
|
@ -216,18 +197,14 @@ buildFunctionStatement(name, arguments, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildGroupStatement(block)
|
buildGroupStatement(blockType *block)
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
return(newStatement(GROUP_STATEMENT,
|
return(newStatement(GROUP_STATEMENT,
|
||||||
(statementBodyType) block));
|
(statementBodyType) block));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildIfStatement(head, continuation, continuationKind)
|
buildIfStatement(ifHeadType *head, ifContinuationType continuation, ifContinuationKindType continuationKind)
|
||||||
ifHeadType *head;
|
|
||||||
ifContinuationType continuation;
|
|
||||||
ifContinuationKindType continuationKind;
|
|
||||||
{
|
{
|
||||||
ifStatementBodyType *result;
|
ifStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -255,17 +232,14 @@ buildIfStatement(head, continuation, continuationKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildIncludeStatement(filename)
|
buildIncludeStatement(expressionType *filename)
|
||||||
expressionType *filename;
|
|
||||||
{
|
{
|
||||||
return(newStatement(INCLUDE_STATEMENT,
|
return(newStatement(INCLUDE_STATEMENT,
|
||||||
(statementBodyType) filename));
|
(statementBodyType) filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildInstructionStatement(opcode, operands)
|
buildInstructionStatement(opcodeTableEntryType *opcode, operandListType *operands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
operandListType *operands;
|
|
||||||
{
|
{
|
||||||
instructionStatementBodyType *result;
|
instructionStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -277,18 +251,14 @@ buildInstructionStatement(opcode, operands)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildLongStatement(expressionList)
|
buildLongStatement(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(LONG_STATEMENT,
|
return(newStatement(LONG_STATEMENT,
|
||||||
(statementBodyType) expressionList));
|
(statementBodyType) expressionList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMacroStatement(macro, arguments, body)
|
buildMacroStatement(macroTableEntryType *macro, argumentDefinitionListType *arguments, blockType *body)
|
||||||
macroTableEntryType *macro;
|
|
||||||
argumentDefinitionListType *arguments;
|
|
||||||
blockType *body;
|
|
||||||
{
|
{
|
||||||
macroStatementBodyType *result;
|
macroStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -300,9 +270,7 @@ buildMacroStatement(macro, arguments, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMacroInstructionStatement(macro, operands)
|
buildMacroInstructionStatement(macroTableEntryType *macro, operandListType *operands)
|
||||||
macroTableEntryType *macro;
|
|
||||||
operandListType *operands;
|
|
||||||
{
|
{
|
||||||
instructionStatementBodyType *result;
|
instructionStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -314,9 +282,7 @@ buildMacroInstructionStatement(macro, operands)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMdefineStatement(name, value)
|
buildMdefineStatement(stringType *name, expressionType *value)
|
||||||
stringType *name;
|
|
||||||
expressionType *value;
|
|
||||||
{
|
{
|
||||||
mdefineStatementBodyType *result;
|
mdefineStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -327,9 +293,7 @@ buildMdefineStatement(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMdoUntilStatement(body, condition)
|
buildMdoUntilStatement(blockType *body, struct expressionTermStruct *condition)
|
||||||
blockType *body;
|
|
||||||
ExpressionType *condition;
|
|
||||||
{
|
{
|
||||||
mdoUntilStatementBodyType *result;
|
mdoUntilStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -340,9 +304,7 @@ buildMdoUntilStatement(body, condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMdoWhileStatement(body, condition)
|
buildMdoWhileStatement(blockType *body, expressionType *condition)
|
||||||
blockType *body;
|
|
||||||
expressionType *condition;
|
|
||||||
{
|
{
|
||||||
mdoWhileStatementBodyType *result;
|
mdoWhileStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -353,9 +315,7 @@ buildMdoWhileStatement(body, condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMdoStatement(body, end)
|
buildMdoStatement(blockType *body, mdoEndType *end)
|
||||||
blockType *body;
|
|
||||||
mdoEndType *end;
|
|
||||||
{
|
{
|
||||||
statementType *result;
|
statementType *result;
|
||||||
|
|
||||||
|
@ -370,9 +330,7 @@ buildMdoStatement(body, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMforStatement(forExpressions, body)
|
buildMforStatement(forExpressionsType *forExpressions, blockType *body)
|
||||||
forExpressionsType *forExpressions;
|
|
||||||
blockType *body;
|
|
||||||
{
|
{
|
||||||
mforStatementBodyType *result;
|
mforStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -386,10 +344,7 @@ buildMforStatement(forExpressions, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMifStatement(head, continuation, continuationKind)
|
buildMifStatement(mifHeadType *head, mifContinuationType continuation, ifContinuationKindType continuationKind)
|
||||||
mifHeadType *head;
|
|
||||||
mifContinuationType continuation;
|
|
||||||
ifContinuationKindType continuationKind;
|
|
||||||
{
|
{
|
||||||
mifStatementBodyType *result;
|
mifStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -417,9 +372,7 @@ buildMifStatement(head, continuation, continuationKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMswitchStatement(switchExpression, cases)
|
buildMswitchStatement(expressionType *switchExpression, caseListType *cases)
|
||||||
expressionType *switchExpression;
|
|
||||||
caseListType *cases;
|
|
||||||
{
|
{
|
||||||
mswitchStatementBodyType *result;
|
mswitchStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -430,10 +383,7 @@ buildMswitchStatement(switchExpression, cases)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMvariableStatement(name, value, dimension)
|
buildMvariableStatement(stringType *name, expressionListType *value, expressionType *dimension)
|
||||||
stringType *name;
|
|
||||||
expressionListType *value;
|
|
||||||
expressionType *dimension;
|
|
||||||
{
|
{
|
||||||
mvariableStatementBodyType *result;
|
mvariableStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -445,9 +395,7 @@ buildMvariableStatement(name, value, dimension)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildMwhileStatement(condition, body)
|
buildMwhileStatement(expressionType *condition, blockType *body)
|
||||||
expressionType *condition;
|
|
||||||
blockType *body;
|
|
||||||
{
|
{
|
||||||
mwhileStatementBodyType *result;
|
mwhileStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -458,53 +406,47 @@ buildMwhileStatement(condition, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildNullStatement()
|
buildNullStatement(void)
|
||||||
{
|
{
|
||||||
return(newStatement(NULL_STATEMENT, (statementBodyType){ .ifUnion = NULL }));
|
return(newStatement(NULL_STATEMENT, (statementBodyType){ .ifUnion = NULL }));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildOrgStatement(expression)
|
buildOrgStatement(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
return(newStatement(ORG_STATEMENT,
|
return(newStatement(ORG_STATEMENT,
|
||||||
(statementBodyType) expression));
|
(statementBodyType) expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildPerformStatement(expression)
|
buildPerformStatement(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
return(newStatement(PERFORM_STATEMENT,
|
return(newStatement(PERFORM_STATEMENT,
|
||||||
(statementBodyType) expression));
|
(statementBodyType) expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildRelStatement()
|
buildRelStatement(void)
|
||||||
{
|
{
|
||||||
return(newStatement(REL_STATEMENT, (statementBodyType){ .ifUnion = NULL }));
|
return(newStatement(REL_STATEMENT, (statementBodyType){ .ifUnion = NULL }));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildStartStatement(expression)
|
buildStartStatement(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
return(newStatement(START_STATEMENT,
|
return(newStatement(START_STATEMENT,
|
||||||
(statementBodyType) expression));
|
(statementBodyType) expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildStringStatement(expressionList)
|
buildStringStatement(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(STRING_STATEMENT,
|
return(newStatement(STRING_STATEMENT,
|
||||||
(statementBodyType) expressionList));
|
(statementBodyType) expressionList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildStructStatement(name, body)
|
buildStructStatement(symbolTableEntryType *name, blockType *body)
|
||||||
symbolTableEntryType *name;
|
|
||||||
blockType *body;
|
|
||||||
{
|
{
|
||||||
structStatementBodyType *result;
|
structStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -515,26 +457,21 @@ buildStructStatement(name, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildTargetStatement(expression)
|
buildTargetStatement(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
return(newStatement(TARGET_STATEMENT,
|
return(newStatement(TARGET_STATEMENT,
|
||||||
(statementBodyType) expression));
|
(statementBodyType) expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildUndefineStatement(identifierList)
|
buildUndefineStatement(identifierListType *identifierList)
|
||||||
identifierListType *identifierList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(UNDEFINE_STATEMENT,
|
return(newStatement(UNDEFINE_STATEMENT,
|
||||||
(statementBodyType) identifierList));
|
(statementBodyType) identifierList));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildVariableStatement(name, value, dimension)
|
buildVariableStatement(stringType *name, expressionListType *value, expressionType *dimension)
|
||||||
stringType *name;
|
|
||||||
expressionListType *value;
|
|
||||||
expressionType *dimension;
|
|
||||||
{
|
{
|
||||||
variableStatementBodyType *result;
|
variableStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -546,9 +483,7 @@ buildVariableStatement(name, value, dimension)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildWhileStatement(condition, body)
|
buildWhileStatement(conditionType condition, blockType *body)
|
||||||
conditionType condition;
|
|
||||||
blockType *body;
|
|
||||||
{
|
{
|
||||||
whileStatementBodyType *result;
|
whileStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -559,8 +494,7 @@ buildWhileStatement(condition, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
buildWordStatement(expressionList)
|
buildWordStatement(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
return(newStatement(WORD_STATEMENT,
|
return(newStatement(WORD_STATEMENT,
|
||||||
(statementBodyType) expressionList));
|
(statementBodyType) expressionList));
|
||||||
|
|
|
@ -41,10 +41,11 @@
|
||||||
|
|
||||||
/* Fragments of statement structures */
|
/* Fragments of statement structures */
|
||||||
|
|
||||||
caseType *
|
|
||||||
buildCase(caseTags, caseBody)
|
extern void botch (char *message, ...);
|
||||||
expressionListType *caseTags;
|
|
||||||
blockType *caseBody;
|
caseType *
|
||||||
|
buildCase(expressionListType *caseTags, blockType *caseBody)
|
||||||
{
|
{
|
||||||
caseType *result;
|
caseType *result;
|
||||||
|
|
||||||
|
@ -55,9 +56,7 @@ buildCase(caseTags, caseBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
doEndType *
|
doEndType *
|
||||||
buildDoEnd(condition, kindOfDoEnd)
|
buildDoEnd(conditionType condition, doEndKindType kindOfDoEnd)
|
||||||
conditionType condition;
|
|
||||||
doEndKindType kindOfDoEnd;
|
|
||||||
{
|
{
|
||||||
doEndType *result;
|
doEndType *result;
|
||||||
|
|
||||||
|
@ -68,10 +67,7 @@ buildDoEnd(condition, kindOfDoEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
forExpressionsType *
|
forExpressionsType *
|
||||||
buildForExpressions(initExpression, testExpression, incrExpression)
|
buildForExpressions(expressionType *initExpression, expressionType *testExpression, expressionType *incrExpression)
|
||||||
expressionType *initExpression;
|
|
||||||
expressionType *testExpression;
|
|
||||||
expressionType *incrExpression;
|
|
||||||
{
|
{
|
||||||
forExpressionsType *result;
|
forExpressionsType *result;
|
||||||
|
|
||||||
|
@ -83,9 +79,7 @@ buildForExpressions(initExpression, testExpression, incrExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
ifHeadType *
|
ifHeadType *
|
||||||
buildIfHead(condition, block)
|
buildIfHead(conditionType condition, blockType *block)
|
||||||
conditionType condition;
|
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
ifHeadType *result;
|
ifHeadType *result;
|
||||||
|
|
||||||
|
@ -96,9 +90,7 @@ buildIfHead(condition, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
mdoEndType *
|
mdoEndType *
|
||||||
buildMdoEnd(condition, kindOfMdoEnd)
|
buildMdoEnd(expressionType *condition, doEndKindType kindOfMdoEnd)
|
||||||
expressionType *condition;
|
|
||||||
doEndKindType kindOfMdoEnd;
|
|
||||||
{
|
{
|
||||||
mdoEndType *result;
|
mdoEndType *result;
|
||||||
|
|
||||||
|
@ -110,9 +102,7 @@ buildMdoEnd(condition, kindOfMdoEnd)
|
||||||
|
|
||||||
|
|
||||||
mifHeadType *
|
mifHeadType *
|
||||||
buildMifHead(condition, block)
|
buildMifHead(expressionType *condition, blockType *block)
|
||||||
expressionType *condition;
|
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
mifHeadType *result;
|
mifHeadType *result;
|
||||||
|
|
||||||
|
@ -126,9 +116,7 @@ buildMifHead(condition, block)
|
||||||
/* Fragments of expression structures */
|
/* Fragments of expression structures */
|
||||||
|
|
||||||
arrayTermType *
|
arrayTermType *
|
||||||
buildArrayTerm(array, index)
|
buildArrayTerm(expressionType *array, expressionType *index)
|
||||||
expressionType *array;
|
|
||||||
expressionType *index;
|
|
||||||
{
|
{
|
||||||
arrayTermType *result;
|
arrayTermType *result;
|
||||||
|
|
||||||
|
@ -139,10 +127,7 @@ buildArrayTerm(array, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
binopTermType *
|
binopTermType *
|
||||||
buildBinopTerm(binop, leftArgument, rightArgument)
|
buildBinopTerm(binopKindType binop, expressionType *leftArgument, expressionType *rightArgument)
|
||||||
binopKindType binop;
|
|
||||||
expressionType *leftArgument;
|
|
||||||
expressionType *rightArgument;
|
|
||||||
{
|
{
|
||||||
binopTermType *result;
|
binopTermType *result;
|
||||||
|
|
||||||
|
@ -154,12 +139,10 @@ buildBinopTerm(binop, leftArgument, rightArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
functionCallTermType *
|
functionCallTermType *
|
||||||
buildFunctionCall(functionName, arguments)
|
buildFunctionCall(stringType *functionName, operandListType *arguments)
|
||||||
stringType *functionName;
|
|
||||||
operandListType *arguments;
|
|
||||||
{
|
{
|
||||||
functionCallTermType *result;
|
functionCallTermType *result;
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
|
|
||||||
result = typeAlloc(functionCallTermType);
|
result = typeAlloc(functionCallTermType);
|
||||||
result->functionName = lookupOrEnterSymbol(functionName,
|
result->functionName = lookupOrEnterSymbol(functionName,
|
||||||
|
@ -169,9 +152,7 @@ buildFunctionCall(functionName, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
postOpTermType *
|
postOpTermType *
|
||||||
buildPostOpTerm(postOp, postOpArgument)
|
buildPostOpTerm(postOpKindType postOp, expressionType *postOpArgument)
|
||||||
postOpKindType postOp;
|
|
||||||
expressionType *postOpArgument;
|
|
||||||
{
|
{
|
||||||
postOpTermType *result;
|
postOpTermType *result;
|
||||||
|
|
||||||
|
@ -182,9 +163,7 @@ buildPostOpTerm(postOp, postOpArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
preOpTermType *
|
preOpTermType *
|
||||||
buildPreOpTerm(preOp, preOpArgument)
|
buildPreOpTerm(preOpKindType preOp, expressionType *preOpArgument)
|
||||||
preOpKindType preOp;
|
|
||||||
expressionType *preOpArgument;
|
|
||||||
{
|
{
|
||||||
preOpTermType *result;
|
preOpTermType *result;
|
||||||
|
|
||||||
|
@ -195,9 +174,7 @@ buildPreOpTerm(preOp, preOpArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
unopTermType *
|
unopTermType *
|
||||||
buildUnopTerm(unop, unopArgument)
|
buildUnopTerm(unopKindType unop, expressionType *unopArgument)
|
||||||
unopKindType unop;
|
|
||||||
expressionType *unopArgument;
|
|
||||||
{
|
{
|
||||||
unopTermType *result;
|
unopTermType *result;
|
||||||
|
|
||||||
|
@ -208,15 +185,11 @@ buildUnopTerm(unop, unopArgument)
|
||||||
}
|
}
|
||||||
|
|
||||||
expressionTermType *
|
expressionTermType *
|
||||||
buildExpressionTerm(kindOfExpressionTerm, arg1, arg2, arg3)
|
buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *arg1, anyOldThing *arg2, anyOldThing *arg3)
|
||||||
expressionTermKindType kindOfExpressionTerm;
|
|
||||||
anyOldThing *arg1;
|
|
||||||
anyOldThing *arg2;
|
|
||||||
anyOldThing *arg3;
|
|
||||||
{
|
{
|
||||||
expressionType *result;
|
expressionType *result;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
|
|
||||||
result = typeAlloc(expressionType);
|
result = typeAlloc(expressionType);
|
||||||
result->kindOfTerm = kindOfExpressionTerm;
|
result->kindOfTerm = kindOfExpressionTerm;
|
||||||
|
@ -298,11 +271,10 @@ buildExpressionTerm(kindOfExpressionTerm, arg1, arg2, arg3)
|
||||||
/* Other stuff */
|
/* Other stuff */
|
||||||
|
|
||||||
macroTableEntryType *
|
macroTableEntryType *
|
||||||
buildMacroTableEntry(name)
|
buildMacroTableEntry(stringType *name)
|
||||||
stringType *name;
|
|
||||||
{
|
{
|
||||||
macroTableEntryType *result;
|
macroTableEntryType *result;
|
||||||
char *saveString();
|
char *saveString(char *s);
|
||||||
|
|
||||||
result = typeAlloc(macroTableEntryType);
|
result = typeAlloc(macroTableEntryType);
|
||||||
result->macroName = saveString(name);
|
result->macroName = saveString(name);
|
||||||
|
@ -313,12 +285,10 @@ buildMacroTableEntry(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolTableEntryType *
|
symbolTableEntryType *
|
||||||
buildSymbolTableEntry(name, usage)
|
buildSymbolTableEntry(stringType *name, symbolUsageKindType usage)
|
||||||
stringType *name;
|
|
||||||
symbolUsageKindType usage;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *result;
|
symbolTableEntryType *result;
|
||||||
char *saveString();
|
char *saveString(char *s);
|
||||||
|
|
||||||
result = typeAlloc(symbolTableEntryType);
|
result = typeAlloc(symbolTableEntryType);
|
||||||
result->symbolName = saveString(name);
|
result->symbolName = saveString(name);
|
||||||
|
@ -335,10 +305,7 @@ buildSymbolTableEntry(name, usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
codeBreakType *
|
codeBreakType *
|
||||||
buildCodeBreak(kind, address, data)
|
buildCodeBreak(codeBreakKindType kind, addressType address, int data)
|
||||||
codeBreakKindType kind;
|
|
||||||
addressType address;
|
|
||||||
int data;
|
|
||||||
{
|
{
|
||||||
codeBreakType *result;
|
codeBreakType *result;
|
||||||
|
|
||||||
|
@ -351,10 +318,7 @@ buildCodeBreak(kind, address, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
reservationListType *
|
reservationListType *
|
||||||
buildReservation(startAddress, blockSize, nextReservation)
|
buildReservation(addressType startAddress, int blockSize, reservationListType *nextReservation)
|
||||||
addressType startAddress;
|
|
||||||
int blockSize;
|
|
||||||
reservationListType *nextReservation;
|
|
||||||
{
|
{
|
||||||
reservationListType *result;
|
reservationListType *result;
|
||||||
|
|
||||||
|
@ -366,9 +330,7 @@ buildReservation(startAddress, blockSize, nextReservation)
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleFixupListType *
|
simpleFixupListType *
|
||||||
buildSimpleFixupList(locationToFixup, previousList)
|
buildSimpleFixupList(valueType locationToFixup, simpleFixupListType *previousList)
|
||||||
valueType locationToFixup;
|
|
||||||
simpleFixupListType *previousList;
|
|
||||||
{
|
{
|
||||||
simpleFixupListType *result;
|
simpleFixupListType *result;
|
||||||
|
|
||||||
|
|
|
@ -43,14 +43,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
argumentListHeadType *
|
argumentListHeadType *
|
||||||
buildArgumentList(new, rest, arrayTag)
|
buildArgumentList(stringType *new, argumentListHeadType *rest, bool arrayTag)
|
||||||
stringType *new;
|
|
||||||
argumentListHeadType *rest;
|
|
||||||
bool arrayTag;
|
|
||||||
{
|
{
|
||||||
argumentListHeadType *newListHead;
|
argumentListHeadType *newListHead;
|
||||||
argumentDefinitionListType *newArgument;
|
argumentDefinitionListType *newArgument;
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
|
|
||||||
if (rest == NULL) {
|
if (rest == NULL) {
|
||||||
newListHead = typeAlloc(argumentListHeadType);
|
newListHead = typeAlloc(argumentListHeadType);
|
||||||
|
@ -76,9 +73,7 @@ buildArgumentList(new, rest, arrayTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
caseListHeadType *
|
caseListHeadType *
|
||||||
buildCaseList(new, rest)
|
buildCaseList(caseType *new, caseListHeadType *rest)
|
||||||
caseType *new;
|
|
||||||
caseListHeadType *rest;
|
|
||||||
{
|
{
|
||||||
caseListHeadType *newListHead;
|
caseListHeadType *newListHead;
|
||||||
caseListType *newCase;
|
caseListType *newCase;
|
||||||
|
@ -103,9 +98,7 @@ buildCaseList(new, rest)
|
||||||
}
|
}
|
||||||
|
|
||||||
expressionListHeadType *
|
expressionListHeadType *
|
||||||
buildExpressionList(new, rest)
|
buildExpressionList(expressionType *new, expressionListHeadType *rest)
|
||||||
expressionType *new;
|
|
||||||
expressionListHeadType *rest;
|
|
||||||
{
|
{
|
||||||
expressionListHeadType *newListHead;
|
expressionListHeadType *newListHead;
|
||||||
expressionListType *newListEntry;
|
expressionListType *newListEntry;
|
||||||
|
@ -130,15 +123,12 @@ buildExpressionList(new, rest)
|
||||||
}
|
}
|
||||||
|
|
||||||
identifierListHeadType *
|
identifierListHeadType *
|
||||||
buildIdentifierList(new, rest, usage)
|
buildIdentifierList(stringType *new, identifierListHeadType *rest, symbolUsageKindType usage)
|
||||||
stringType *new;
|
|
||||||
identifierListHeadType *rest;
|
|
||||||
symbolUsageKindType usage;
|
|
||||||
{
|
{
|
||||||
identifierListType *newListEntry;
|
identifierListType *newListEntry;
|
||||||
identifierListHeadType *newListHead;
|
identifierListHeadType *newListHead;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
|
|
||||||
if (rest == NULL) {
|
if (rest == NULL) {
|
||||||
newListHead = typeAlloc(identifierListHeadType);
|
newListHead = typeAlloc(identifierListHeadType);
|
||||||
|
@ -160,9 +150,7 @@ buildIdentifierList(new, rest, usage)
|
||||||
}
|
}
|
||||||
|
|
||||||
labelListHeadType *
|
labelListHeadType *
|
||||||
buildLabelList(new, rest)
|
buildLabelList(symbolTableEntryType *new, labelListHeadType *rest)
|
||||||
symbolTableEntryType *new;
|
|
||||||
labelListHeadType *rest;
|
|
||||||
{
|
{
|
||||||
labelListHeadType *newLabelHead;
|
labelListHeadType *newLabelHead;
|
||||||
labelListType *newLabel;
|
labelListType *newLabel;
|
||||||
|
@ -187,9 +175,7 @@ buildLabelList(new, rest)
|
||||||
}
|
}
|
||||||
|
|
||||||
operandListHeadType *
|
operandListHeadType *
|
||||||
buildOperandList(new, rest)
|
buildOperandList(operandType *new, operandListHeadType *rest)
|
||||||
operandType *new;
|
|
||||||
operandListHeadType *rest;
|
|
||||||
{
|
{
|
||||||
operandListHeadType *newListHead;
|
operandListHeadType *newListHead;
|
||||||
|
|
||||||
|
@ -213,17 +199,13 @@ buildOperandList(new, rest)
|
||||||
}
|
}
|
||||||
|
|
||||||
selectionListHeadType *
|
selectionListHeadType *
|
||||||
buildSelectionList(new, rest)
|
buildSelectionList(selectionListType *new, selectionListHeadType *rest)
|
||||||
selectionListType *new;
|
|
||||||
selectionListHeadType *rest;
|
|
||||||
{
|
{
|
||||||
return((selectionListHeadType *) buildIdentifierList(new, rest, unknownSymbolTag /* random guess */));
|
return((selectionListHeadType *) buildIdentifierList(new, rest, unknownSymbolTag /* random guess */));
|
||||||
}
|
}
|
||||||
|
|
||||||
statementListHeadType *
|
statementListHeadType *
|
||||||
buildStatementList(new, rest)
|
buildStatementList(statementType *new, statementListHeadType *rest)
|
||||||
statementType *new;
|
|
||||||
statementListHeadType *rest;
|
|
||||||
{
|
{
|
||||||
statementListHeadType *newListHead;
|
statementListHeadType *newListHead;
|
||||||
|
|
||||||
|
|
|
@ -42,47 +42,54 @@
|
||||||
environment
|
environment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
valueType *
|
|
||||||
makeBooleanValue(test)
|
extern void error (errorType theError, ...);
|
||||||
int test;
|
extern int hashString (char *s);
|
||||||
|
extern void assembleMacro (macroTableEntryType *macroInstruction, operandListType *operands);
|
||||||
|
extern void saveListingOff (void);
|
||||||
|
extern void saveListingOn (void);
|
||||||
|
extern bool strcmplc (char *s1, char *s2);
|
||||||
|
extern symbolTableEntryType *lookupOrEnterSymbol (stringType *s, symbolUsageKindType kind);
|
||||||
|
extern void assembleDefineStatement (defineStatementBodyType *defineStatement);
|
||||||
|
extern void freeStatement (statementType *statement);
|
||||||
|
|
||||||
|
valueType *
|
||||||
|
makeBooleanValue(int test)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(newValue(ABSOLUTE_VALUE, test!=0, EXPRESSION_OPND));
|
return(newValue(ABSOLUTE_VALUE, test!=0, EXPRESSION_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
makeFailureValue()
|
makeFailureValue(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(newValue(FAIL, 0, EXPRESSION_OPND));
|
return(newValue(FAIL, 0, EXPRESSION_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
makeIntegerValue(integer)
|
makeIntegerValue(int integer)
|
||||||
int integer;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return(newValue(ABSOLUTE_VALUE, integer, EXPRESSION_OPND));
|
return(newValue(ABSOLUTE_VALUE, integer, EXPRESSION_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
makeOperandValue(operand)
|
makeOperandValue(operandType *operand)
|
||||||
operandType *operand;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return(newValue(OPERAND_VALUE, operand, EXPRESSION_OPND));
|
return(newValue(OPERAND_VALUE, operand, EXPRESSION_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
makeStringValue(string)
|
makeStringValue(stringType *string)
|
||||||
stringType *string;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
return(newValue(STRING_VALUE, string, STRING_OPND));
|
return(newValue(STRING_VALUE, string, STRING_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
makeUndefinedValue()
|
makeUndefinedValue(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
return(newValue(UNDEFINED_VALUE, 0, EXPRESSION_OPND));
|
return(newValue(UNDEFINED_VALUE, 0, EXPRESSION_OPND));
|
||||||
|
@ -98,9 +105,7 @@ makeUndefinedValue()
|
||||||
|
|
||||||
/* Return internal address mode of an operand */
|
/* Return internal address mode of an operand */
|
||||||
valueType *
|
valueType *
|
||||||
addressModeBIF(parameterList, kindOfFixup)
|
addressModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -115,15 +120,13 @@ addressModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Call a macro where the macro name is obtained dynamically from a string */
|
/* Call a macro where the macro name is obtained dynamically from a string */
|
||||||
valueType *
|
valueType *
|
||||||
applyBIF(parameterList, kindOfFixup)
|
applyBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *macroToLookup;
|
stringType *macroToLookup;
|
||||||
macroTableEntryType *macroToCall;
|
macroTableEntryType *macroToCall;
|
||||||
|
|
||||||
macroTableEntryType *lookupMacroName();
|
macroTableEntryType *lookupMacroName(char *s, int hashValue);
|
||||||
|
|
||||||
if (parameterList == NULL) {
|
if (parameterList == NULL) {
|
||||||
error(NO_ARGUMENTS_TO_BIF_ERROR, "apply");
|
error(NO_ARGUMENTS_TO_BIF_ERROR, "apply");
|
||||||
|
@ -146,9 +149,7 @@ applyBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* return the length of an array */
|
/* return the length of an array */
|
||||||
valueType *
|
valueType *
|
||||||
arrayLengthBIF(parameterList, kindOfFixup)
|
arrayLengthBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *testObjectValue;
|
valueType *testObjectValue;
|
||||||
|
|
||||||
|
@ -188,9 +189,7 @@ static char atasciiTable[] = { /* 0xFFs will become 0x00s on output */
|
||||||
|
|
||||||
/* Convert a string to ATASCII */
|
/* Convert a string to ATASCII */
|
||||||
valueType *
|
valueType *
|
||||||
atasciiBIF(parameterList, kindOfFixup)
|
atasciiBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
|
@ -215,9 +214,7 @@ atasciiBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Convert a string to ATASCII while setting high-order color bits */
|
/* Convert a string to ATASCII while setting high-order color bits */
|
||||||
valueType *
|
valueType *
|
||||||
atasciiColorBIF(parameterList, kindOfFixup)
|
atasciiColorBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
|
@ -264,18 +261,14 @@ atasciiColorBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Turn debug mode off and on */
|
/* Turn debug mode off and on */
|
||||||
valueType *
|
valueType *
|
||||||
debugModeOffBIF(parameterList, kindOfFixup)
|
debugModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
debug = FALSE;
|
debug = FALSE;
|
||||||
return(makeBooleanValue(FALSE));
|
return(makeBooleanValue(FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
debugModeOnBIF(parameterList, kindOfFixup)
|
debugModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
debug = TRUE;
|
debug = TRUE;
|
||||||
return(makeBooleanValue(TRUE));
|
return(makeBooleanValue(TRUE));
|
||||||
|
@ -283,18 +276,14 @@ debugModeOnBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Turn display of code emission off and on */
|
/* Turn display of code emission off and on */
|
||||||
valueType *
|
valueType *
|
||||||
emitModeOffBIF(parameterList, kindOfFixup)
|
emitModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
emitPrint = FALSE;
|
emitPrint = FALSE;
|
||||||
return(makeBooleanValue(FALSE));
|
return(makeBooleanValue(FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
emitModeOnBIF(parameterList, kindOfFixup)
|
emitModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
emitPrint = TRUE;
|
emitPrint = TRUE;
|
||||||
return(makeBooleanValue(TRUE));
|
return(makeBooleanValue(TRUE));
|
||||||
|
@ -302,9 +291,7 @@ emitModeOnBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is absolute (as opposed to relocatable) */
|
/* Check if an operand is absolute (as opposed to relocatable) */
|
||||||
valueType *
|
valueType *
|
||||||
isAbsoluteValueBIF(parameterList, kindOfFixup)
|
isAbsoluteValueBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -320,9 +307,9 @@ isAbsoluteValueBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if operand is code block */
|
/* Check if operand is code block */
|
||||||
valueType *
|
valueType *
|
||||||
isBlockBIF(parameterList, kindOfFixup) /* questionable */
|
isBlockBIF(operandListType *parameterList, fixupKindType kindOfFixup) /* questionable */
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -338,9 +325,7 @@ isBlockBIF(parameterList, kindOfFixup) /* questionable */
|
||||||
|
|
||||||
/* Check if operand is a BIF */
|
/* Check if operand is a BIF */
|
||||||
valueType *
|
valueType *
|
||||||
isBuiltInFunctionBIF(parameterList, kindOfFixup)
|
isBuiltInFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -356,9 +341,7 @@ isBuiltInFunctionBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if operand is a condition code */
|
/* Check if operand is a condition code */
|
||||||
valueType *
|
valueType *
|
||||||
isConditionCodeBIF(parameterList, kindOfFixup)
|
isConditionCodeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -374,15 +357,13 @@ isConditionCodeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if a symbol is defined */
|
/* Check if a symbol is defined */
|
||||||
valueType *
|
valueType *
|
||||||
isDefinedBIF(parameterList, kindOfFixup)
|
isDefinedBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
symbolTableEntryType *effectiveSymbol();
|
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
if (parameterList->kindOfOperand == EXPRESSION_OPND &&
|
if (parameterList->kindOfOperand == EXPRESSION_OPND &&
|
||||||
|
@ -409,14 +390,12 @@ isDefinedBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if a symbol is externally visible */
|
/* Check if a symbol is externally visible */
|
||||||
valueType *
|
valueType *
|
||||||
isExternalBIF(parameterList, kindOfFixup)
|
isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
if (parameterList != NULL && parameterList->kindOfOperand ==
|
if (parameterList != NULL && parameterList->kindOfOperand ==
|
||||||
EXPRESSION_OPND) {
|
EXPRESSION_OPND) {
|
||||||
|
@ -432,9 +411,7 @@ isExternalBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is a struct field */
|
/* Check if an operand is a struct field */
|
||||||
valueType *
|
valueType *
|
||||||
isFieldBIF(parameterList, kindOfFixup)
|
isFieldBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -450,9 +427,7 @@ isFieldBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is a user-defined function */
|
/* Check if an operand is a user-defined function */
|
||||||
valueType *
|
valueType *
|
||||||
isFunctionBIF(parameterList, kindOfFixup)
|
isFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -468,9 +443,7 @@ isFunctionBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand value is relocatable */
|
/* Check if an operand value is relocatable */
|
||||||
valueType *
|
valueType *
|
||||||
isRelocatableValueBIF(parameterList, kindOfFixup)
|
isRelocatableValueBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -487,9 +460,7 @@ isRelocatableValueBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is a string */
|
/* Check if an operand is a string */
|
||||||
valueType *
|
valueType *
|
||||||
isStringBIF(parameterList, kindOfFixup)
|
isStringBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -505,9 +476,7 @@ isStringBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is a struct */
|
/* Check if an operand is a struct */
|
||||||
valueType *
|
valueType *
|
||||||
isStructBIF(parameterList, kindOfFixup)
|
isStructBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
@ -523,9 +492,7 @@ isStructBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is a symbol */
|
/* Check if an operand is a symbol */
|
||||||
valueType *
|
valueType *
|
||||||
isSymbolBIF(parameterList, kindOfFixup)
|
isSymbolBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
|
|
||||||
|
@ -541,9 +508,7 @@ isSymbolBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Turn listing off and on */
|
/* Turn listing off and on */
|
||||||
valueType *
|
valueType *
|
||||||
listingOffBIF(parameterList, kindOfFixup)
|
listingOffBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
if (listingOn) {
|
if (listingOn) {
|
||||||
if (!listingControlCounter)
|
if (!listingControlCounter)
|
||||||
|
@ -554,9 +519,7 @@ listingOffBIF(parameterList, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
listingOnBIF(parameterList, kindOfFixup)
|
listingOnBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
if (listingOn) {
|
if (listingOn) {
|
||||||
if (--listingControlCounter < 0) {
|
if (--listingControlCounter < 0) {
|
||||||
|
@ -575,9 +538,7 @@ listingOnBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Generate an array on the fly */
|
/* Generate an array on the fly */
|
||||||
valueType *
|
valueType *
|
||||||
makeArrayBIF(parameterList, kindOfFixup)
|
makeArrayBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *lengthValue;
|
valueType *lengthValue;
|
||||||
int length;
|
int length;
|
||||||
|
@ -619,9 +580,7 @@ makeArrayBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Return the Nth character of a string (as an integer) */
|
/* Return the Nth character of a string (as an integer) */
|
||||||
valueType *
|
valueType *
|
||||||
nthCharBIF(parameterList, kindOfFixup)
|
nthCharBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *positionValue;
|
valueType *positionValue;
|
||||||
int position;
|
int position;
|
||||||
|
@ -658,9 +617,7 @@ nthCharBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Pass stuff through to stdio's 'printf' function */
|
/* Pass stuff through to stdio's 'printf' function */
|
||||||
valueType *
|
valueType *
|
||||||
printfBIF(parameterList, kindOfFixup)
|
printfBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
stringType *formatString;
|
stringType *formatString;
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
|
@ -697,9 +654,7 @@ printfBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Concatenate two strings */
|
/* Concatenate two strings */
|
||||||
valueType *
|
valueType *
|
||||||
strcatBIF(parameterList, kindOfFixup)
|
strcatBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *string1;
|
stringType *string1;
|
||||||
|
@ -731,9 +686,7 @@ strcatBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Compare two strings */
|
/* Compare two strings */
|
||||||
valueType *
|
valueType *
|
||||||
strcmpBIF(parameterList, kindOfFixup)
|
strcmpBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *string1;
|
stringType *string1;
|
||||||
|
@ -764,9 +717,7 @@ strcmpBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Compare two strings in a case-independent fashion */
|
/* Compare two strings in a case-independent fashion */
|
||||||
valueType *
|
valueType *
|
||||||
strcmplcBIF(parameterList, kindOfFixup)
|
strcmplcBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *string1;
|
stringType *string1;
|
||||||
|
@ -797,9 +748,7 @@ strcmplcBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Return the length of a string */
|
/* Return the length of a string */
|
||||||
valueType *
|
valueType *
|
||||||
strlenBIF(parameterList, kindOfFixup)
|
strlenBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
|
|
||||||
|
@ -815,9 +764,7 @@ strlenBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Return a substring of a string */
|
/* Return a substring of a string */
|
||||||
valueType *
|
valueType *
|
||||||
substrBIF(parameterList, kindOfFixup)
|
substrBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *string;
|
stringType *string;
|
||||||
|
@ -895,16 +842,14 @@ substrBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Turn a string into a symbol */
|
/* Turn a string into a symbol */
|
||||||
valueType *
|
valueType *
|
||||||
symbolLookupBIF(parameterList, kindOfFixup)
|
symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *identifierToLookup;
|
stringType *identifierToLookup;
|
||||||
|
|
||||||
expressionTermType *buildExpressionTerm();
|
expressionTermType *buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *arg1, anyOldThing *arg2, anyOldThing *arg3);
|
||||||
operandType *buildOperand();
|
operandType *buildOperand(operandKindType kindOfOperand, anyOldThing *arg);
|
||||||
valueType *evaluateIdentifier();
|
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
||||||
|
|
||||||
if (parameterList == NULL) {
|
if (parameterList == NULL) {
|
||||||
error(NO_ARGUMENTS_TO_BIF_ERROR, "symbolLookup");
|
error(NO_ARGUMENTS_TO_BIF_ERROR, "symbolLookup");
|
||||||
|
@ -922,13 +867,11 @@ symbolLookupBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Define a string as a symbol */
|
/* Define a string as a symbol */
|
||||||
valueType *
|
valueType *
|
||||||
symbolDefineBIF(parameterList, kindOfFixup)
|
symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
statementType *syntheticDefineStatement;
|
statementType *syntheticDefineStatement;
|
||||||
statementType *buildDefineStatement();
|
statementType *buildDefineStatement(stringType *name, expressionType *value);
|
||||||
|
|
||||||
if (parameterList == NULL) {
|
if (parameterList == NULL) {
|
||||||
error(NO_ARGUMENTS_TO_BIF_ERROR, "symbolDefine");
|
error(NO_ARGUMENTS_TO_BIF_ERROR, "symbolDefine");
|
||||||
|
@ -957,15 +900,13 @@ symbolDefineBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Turn a symbol into a string */
|
/* Turn a symbol into a string */
|
||||||
valueType *
|
valueType *
|
||||||
symbolNameBIF(parameterList, kindOfFixup)
|
symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
saveEnvironment = currentEnvironment;
|
saveEnvironment = currentEnvironment;
|
||||||
while (parameterList != NULL && parameterList->kindOfOperand ==
|
while (parameterList != NULL && parameterList->kindOfOperand ==
|
||||||
|
@ -996,14 +937,12 @@ symbolNameBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Return internal form of what sort of symbol a symbol is */
|
/* Return internal form of what sort of symbol a symbol is */
|
||||||
valueType *
|
valueType *
|
||||||
symbolUsageBIF(parameterList, kindOfFixup)
|
symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
if (parameterList != NULL && parameterList->kindOfOperand ==
|
if (parameterList != NULL && parameterList->kindOfOperand ==
|
||||||
EXPRESSION_OPND) {
|
EXPRESSION_OPND) {
|
||||||
|
@ -1018,9 +957,7 @@ symbolUsageBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Return internal form of what sort of value a value is */
|
/* Return internal form of what sort of value a value is */
|
||||||
valueType *
|
valueType *
|
||||||
valueTypeBIF(parameterList, kindOfFixup)
|
valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
|
|
@ -34,23 +34,21 @@
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
|
||||||
/* Helper functions, defined in builtInFunctions.c */
|
/* Helper functions, defined in builtInFunctions.c */
|
||||||
valueType *makeBooleanValue();
|
valueType *makeBooleanValue(int test);
|
||||||
valueType *makeFailureValue();
|
valueType *makeFailureValue(void);
|
||||||
valueType *makeIntegerValue();
|
valueType *makeIntegerValue(int integer);
|
||||||
valueType *makeOperandValue();
|
valueType *makeOperandValue(operandType *operand);
|
||||||
valueType *makeStringValue();
|
valueType *makeStringValue(stringType *string);
|
||||||
valueType *makeUndefinedValue();
|
valueType *makeUndefinedValue(void);
|
||||||
|
|
||||||
|
|
||||||
/* Check if operand is the accumulator */
|
/* Check if operand is the accumulator */
|
||||||
valueType *
|
valueType *
|
||||||
isARegisterBIF(parameterList, kindOfFixup)
|
isARegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -63,13 +61,11 @@ isARegisterBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is DIRECT */
|
/* Check if an operand's address mode is DIRECT */
|
||||||
valueType *
|
valueType *
|
||||||
isDirectModeBIF(parameterList, kindOfFixup)
|
isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -82,13 +78,11 @@ isDirectModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is IMMEDIATE */
|
/* Check if an operand's address mode is IMMEDIATE */
|
||||||
valueType *
|
valueType *
|
||||||
isImmediateModeBIF(parameterList, kindOfFixup)
|
isImmediateModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -101,13 +95,11 @@ isImmediateModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is INDEXED (either X or Y) */
|
/* Check if an operand's address mode is INDEXED (either X or Y) */
|
||||||
valueType *
|
valueType *
|
||||||
isIndexedModeBIF(parameterList, kindOfFixup)
|
isIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -123,13 +115,11 @@ isIndexedModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is INDIRECT */
|
/* Check if an operand's address mode is INDIRECT */
|
||||||
valueType *
|
valueType *
|
||||||
isIndirectModeBIF(parameterList, kindOfFixup)
|
isIndirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -142,13 +132,11 @@ isIndirectModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is POST-INDEXED */
|
/* Check if an operand's address mode is POST-INDEXED */
|
||||||
valueType *
|
valueType *
|
||||||
isPostIndexedModeBIF(parameterList, kindOfFixup)
|
isPostIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -161,13 +149,11 @@ isPostIndexedModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is PRE-INDEXED */
|
/* Check if an operand's address mode is PRE-INDEXED */
|
||||||
valueType *
|
valueType *
|
||||||
isPreIndexedModeBIF(parameterList, kindOfFixup)
|
isPreIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -181,13 +167,11 @@ isPreIndexedModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is X-INDEXED */
|
/* Check if an operand's address mode is X-INDEXED */
|
||||||
valueType *
|
valueType *
|
||||||
isXIndexedModeBIF(parameterList, kindOfFixup)
|
isXIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -201,13 +185,11 @@ isXIndexedModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is the X index register */
|
/* Check if an operand is the X index register */
|
||||||
valueType *
|
valueType *
|
||||||
isXRegisterBIF(parameterList, kindOfFixup)
|
isXRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -220,13 +202,11 @@ isXRegisterBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand's address mode is Y-INDEXED */
|
/* Check if an operand's address mode is Y-INDEXED */
|
||||||
valueType *
|
valueType *
|
||||||
isYIndexedModeBIF(parameterList, kindOfFixup)
|
isYIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
@ -240,13 +220,11 @@ isYIndexedModeBIF(parameterList, kindOfFixup)
|
||||||
|
|
||||||
/* Check if an operand is the Y index register */
|
/* Check if an operand is the Y index register */
|
||||||
valueType *
|
valueType *
|
||||||
isYRegisterBIF(parameterList, kindOfFixup)
|
isYRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
operandListType *parameterList;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
|
|
232
debugPrint.c
232
debugPrint.c
|
@ -44,8 +44,14 @@ int tablevel = 0;
|
||||||
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
|
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
|
||||||
|
|
||||||
/* For keeping nested structures looking pretty */
|
/* For keeping nested structures looking pretty */
|
||||||
void
|
|
||||||
tab()
|
extern void printOperandKind (operandKindType kind);
|
||||||
|
extern void printToken (int token);
|
||||||
|
extern void printCondition (conditionType condition);
|
||||||
|
extern void printOperand (operandType *operand);
|
||||||
|
|
||||||
|
void
|
||||||
|
tab(void)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
@ -62,8 +68,7 @@ tab()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
printAssignmentKind(assignmentKind)
|
printAssignmentKind(assignmentKindType assignmentKind)
|
||||||
assignmentKindType assignmentKind;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'assignmentKindType'. */
|
enumerated type 'assignmentKindType'. */
|
||||||
|
@ -86,8 +91,7 @@ printAssignmentKind(assignmentKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printExpressionKind(kind)
|
printExpressionKind(expressionTermKindType kind)
|
||||||
expressionTermKindType kind;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'expressionTermKindType'. */
|
enumerated type 'expressionTermKindType'. */
|
||||||
|
@ -112,8 +116,7 @@ printExpressionKind(kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
stringType *
|
stringType *
|
||||||
statementKindString(kind)
|
statementKindString(statementKindType kind)
|
||||||
statementKindType kind;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of
|
/* This table MUST be maintained congruently with the definition of
|
||||||
the enumerated type 'statementKindType'. */
|
the enumerated type 'statementKindType'. */
|
||||||
|
@ -161,8 +164,7 @@ static char *statementKindTable[] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printStatementKind(kind)
|
printStatementKind(statementKindType kind)
|
||||||
statementKindType kind;
|
|
||||||
{
|
{
|
||||||
printf("%s", statementKindString(kind));
|
printf("%s", statementKindString(kind));
|
||||||
}
|
}
|
||||||
|
@ -173,8 +175,7 @@ printStatementKind(kind)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
printValue(value)
|
printValue(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'valueKindType'. */
|
enumerated type 'valueKindType'. */
|
||||||
|
@ -207,8 +208,7 @@ printValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printSymbol(symbol)
|
printSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruent with the definition of the
|
/* This table MUST be maintained congruent with the definition of the
|
||||||
enumerated type 'symbolUsageKindType'. */
|
enumerated type 'symbolUsageKindType'. */
|
||||||
|
@ -243,8 +243,7 @@ printSymbol(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printArgumentDefinitionList(list)
|
printArgumentDefinitionList(argumentDefinitionListType *list)
|
||||||
argumentDefinitionListType *list;
|
|
||||||
{
|
{
|
||||||
nullPrint(list);
|
nullPrint(list);
|
||||||
tab(); printf("(arguments:\n");
|
tab(); printf("(arguments:\n");
|
||||||
|
@ -258,10 +257,9 @@ printArgumentDefinitionList(list)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printBlock(block)
|
printBlock(blockType *block)
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
void printStatement();
|
void printStatement(statementType *statement);
|
||||||
|
|
||||||
nullPrint(block);
|
nullPrint(block);
|
||||||
tab(); printf("(block:\n");
|
tab(); printf("(block:\n");
|
||||||
|
@ -272,10 +270,9 @@ printBlock(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printArrayTerm(arrayTerm)
|
printArrayTerm(arrayTermType *arrayTerm)
|
||||||
arrayTermType *arrayTerm;
|
|
||||||
{
|
{
|
||||||
void printIdentifier();
|
void printIdentifier(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
nullPrint(arrayTerm);
|
nullPrint(arrayTerm);
|
||||||
tab(); printf("(array\n");
|
tab(); printf("(array\n");
|
||||||
|
@ -287,8 +284,7 @@ printArrayTerm(arrayTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printAssignmentTerm(assignmentTerm)
|
printAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
binopTermType *assignmentTerm;
|
|
||||||
{
|
{
|
||||||
|
|
||||||
nullPrint(assignmentTerm);
|
nullPrint(assignmentTerm);
|
||||||
|
@ -303,10 +299,9 @@ printAssignmentTerm(assignmentTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printBinopTerm(binopTerm)
|
printBinopTerm(binopTermType *binopTerm)
|
||||||
binopTermType *binopTerm;
|
|
||||||
{
|
{
|
||||||
void printIdentifier();
|
void printIdentifier(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
nullPrint(binopTerm);
|
nullPrint(binopTerm);
|
||||||
tab(); printf("(binop [");
|
tab(); printf("(binop [");
|
||||||
|
@ -323,10 +318,9 @@ printBinopTerm(binopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printFunctionCall(functionCall)
|
printFunctionCall(functionCallTermType *functionCall)
|
||||||
functionCallTermType *functionCall;
|
|
||||||
{
|
{
|
||||||
void printOperandList();
|
void printOperandList(operandListType *operandList);
|
||||||
|
|
||||||
nullPrint(functionCall);
|
nullPrint(functionCall);
|
||||||
tab(); printf("(function call %s\n", functionCall->functionName->
|
tab(); printf("(function call %s\n", functionCall->functionName->
|
||||||
|
@ -338,29 +332,26 @@ printFunctionCall(functionCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printHere()
|
printHere(void)
|
||||||
{
|
{
|
||||||
tab(); printf("(here)\n");
|
tab(); printf("(here)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printIdentifier(identifier)
|
printIdentifier(symbolTableEntryType *identifier)
|
||||||
symbolTableEntryType *identifier;
|
|
||||||
{
|
{
|
||||||
nullPrint(identifier);
|
nullPrint(identifier);
|
||||||
printSymbol(identifier);
|
printSymbol(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printNumber(number)
|
printNumber(numberTermType number)
|
||||||
numberTermType number;
|
|
||||||
{
|
{
|
||||||
tab(); printf("(number: %d)\n", number);
|
tab(); printf("(number: %d)\n", number);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printPostopTerm(postopTerm)
|
printPostopTerm(postOpTermType *postopTerm)
|
||||||
postOpTermType *postopTerm;
|
|
||||||
{
|
{
|
||||||
nullPrint(postopTerm);
|
nullPrint(postopTerm);
|
||||||
tab(); printf("(postop [");
|
tab(); printf("(postop [");
|
||||||
|
@ -373,8 +364,7 @@ printPostopTerm(postopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printPreopTerm(preopTerm)
|
printPreopTerm(preOpTermType *preopTerm)
|
||||||
preOpTermType *preopTerm;
|
|
||||||
{
|
{
|
||||||
nullPrint(preopTerm);
|
nullPrint(preopTerm);
|
||||||
tab(); printf("(preop [");
|
tab(); printf("(preop [");
|
||||||
|
@ -387,8 +377,7 @@ printPreopTerm(preopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printUnopTerm(unopTerm)
|
printUnopTerm(unopTermType *unopTerm)
|
||||||
unopTermType *unopTerm;
|
|
||||||
{
|
{
|
||||||
nullPrint(unopTerm);
|
nullPrint(unopTerm);
|
||||||
tab(); printf("(unop [");
|
tab(); printf("(unop [");
|
||||||
|
@ -401,8 +390,7 @@ printUnopTerm(unopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printExpression(expression)
|
printExpression(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
nullPrint(expression);
|
nullPrint(expression);
|
||||||
tab(); printf("(expression: [");
|
tab(); printf("(expression: [");
|
||||||
|
@ -477,8 +465,7 @@ printExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printExpressionList(expressionList)
|
printExpressionList(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
while (expressionList != NULL) {
|
while (expressionList != NULL) {
|
||||||
printExpression(expressionList->theExpression);
|
printExpression(expressionList->theExpression);
|
||||||
|
@ -487,8 +474,7 @@ printExpressionList(expressionList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printIdentifierList(identifierList)
|
printIdentifierList(identifierListType *identifierList)
|
||||||
identifierListType *identifierList;
|
|
||||||
{
|
{
|
||||||
nullPrint(identifierList);
|
nullPrint(identifierList);
|
||||||
printSymbol(identifierList->theSymbol);
|
printSymbol(identifierList->theSymbol);
|
||||||
|
@ -502,8 +488,7 @@ printIdentifierList(identifierList)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
printCase(aCase)
|
printCase(caseType *aCase)
|
||||||
caseType *aCase;
|
|
||||||
{
|
{
|
||||||
tab(); printf("(case:\n"); tablevel++;
|
tab(); printf("(case:\n"); tablevel++;
|
||||||
if (aCase->caseTags == NULL) {
|
if (aCase->caseTags == NULL) {
|
||||||
|
@ -520,8 +505,7 @@ printCase(aCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printCaseList(caseList)
|
printCaseList(caseListType *caseList)
|
||||||
caseListType *caseList;
|
|
||||||
{
|
{
|
||||||
tab(); printf("(cases:\n");
|
tab(); printf("(cases:\n");
|
||||||
tablevel++;
|
tablevel++;
|
||||||
|
@ -534,24 +518,21 @@ printCaseList(caseList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMacro(macroInstruction)
|
printMacro(macroTableEntryType *macroInstruction)
|
||||||
macroTableEntryType *macroInstruction;
|
|
||||||
{
|
{
|
||||||
nullPrint(macroInstruction);
|
nullPrint(macroInstruction);
|
||||||
tab(); printf("(macro: %s)\n", macroInstruction->macroName);
|
tab(); printf("(macro: %s)\n", macroInstruction->macroName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printOpcode(opcode)
|
printOpcode(opcodeTableEntryType *opcode)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
{
|
{
|
||||||
nullPrint(opcode);
|
nullPrint(opcode);
|
||||||
tab(); printf("(opcode: %s)\n", opcode->mnemonic);
|
tab(); printf("(opcode: %s)\n", opcode->mnemonic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printOperandList(operandList)
|
printOperandList(operandListType *operandList)
|
||||||
operandListType *operandList;
|
|
||||||
{
|
{
|
||||||
nullPrint(operandList);
|
nullPrint(operandList);
|
||||||
printOperand(operandList);
|
printOperand(operandList);
|
||||||
|
@ -560,16 +541,14 @@ printOperandList(operandList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printAlignStatement(alignStatement)
|
printAlignStatement(alignStatementBodyType *alignStatement)
|
||||||
alignStatementBodyType *alignStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(alignStatement);
|
nullPrint(alignStatement);
|
||||||
printExpression(alignStatement);
|
printExpression(alignStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printAssertStatement(assertStatement)
|
printAssertStatement(assertStatementBodyType *assertStatement)
|
||||||
assertStatementBodyType *assertStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(assertStatement);
|
nullPrint(assertStatement);
|
||||||
printExpression(assertStatement->condition);
|
printExpression(assertStatement->condition);
|
||||||
|
@ -577,24 +556,21 @@ printAssertStatement(assertStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printBlockStatement(blockStatement)
|
printBlockStatement(blockStatementBodyType *blockStatement)
|
||||||
blockStatementBodyType *blockStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(blockStatement);
|
nullPrint(blockStatement);
|
||||||
printExpressionList(blockStatement);
|
printExpressionList(blockStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printByteStatement(byteStatement)
|
printByteStatement(byteStatementBodyType *byteStatement)
|
||||||
byteStatementBodyType *byteStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(byteStatement);
|
nullPrint(byteStatement);
|
||||||
printExpressionList(byteStatement);
|
printExpressionList(byteStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printConstrainStatement(constrainStatement)
|
printConstrainStatement(constrainStatementBodyType *constrainStatement)
|
||||||
constrainStatementBodyType *constrainStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(constrainStatement);
|
nullPrint(constrainStatement);
|
||||||
printExpression(constrainStatement->constraint);
|
printExpression(constrainStatement->constraint);
|
||||||
|
@ -602,16 +578,14 @@ printConstrainStatement(constrainStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printDbyteStatement(dbyteStatement)
|
printDbyteStatement(dbyteStatementBodyType *dbyteStatement)
|
||||||
dbyteStatementBodyType *dbyteStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(dbyteStatement);
|
nullPrint(dbyteStatement);
|
||||||
printExpressionList(dbyteStatement);
|
printExpressionList(dbyteStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printDefineStatement(defineStatement)
|
printDefineStatement(defineStatementBodyType *defineStatement)
|
||||||
defineStatementBodyType *defineStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(defineStatement);
|
nullPrint(defineStatement);
|
||||||
printSymbol(defineStatement->theSymbol);
|
printSymbol(defineStatement->theSymbol);
|
||||||
|
@ -619,8 +593,7 @@ printDefineStatement(defineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printDoUntilStatement(doUntilStatement)
|
printDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
|
||||||
doUntilStatementBodyType *doUntilStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(doUntilStatement);
|
nullPrint(doUntilStatement);
|
||||||
printBlock(doUntilStatement->doUntilLoop);
|
printBlock(doUntilStatement->doUntilLoop);
|
||||||
|
@ -630,8 +603,7 @@ printDoUntilStatement(doUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printDoWhileStatement(doWhileStatement)
|
printDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
|
||||||
doWhileStatementBodyType *doWhileStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(doWhileStatement);
|
nullPrint(doWhileStatement);
|
||||||
printBlock(doWhileStatement->doWhileLoop);
|
printBlock(doWhileStatement->doWhileLoop);
|
||||||
|
@ -641,24 +613,21 @@ printDoWhileStatement(doWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printExternStatement(externStatement)
|
printExternStatement(externStatementBodyType *externStatement)
|
||||||
externStatementBodyType *externStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(externStatement);
|
nullPrint(externStatement);
|
||||||
printIdentifierList(externStatement);
|
printIdentifierList(externStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printFreturnStatement(freturnStatement)
|
printFreturnStatement(freturnStatementBodyType *freturnStatement)
|
||||||
freturnStatementBodyType *freturnStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(freturnStatement);
|
nullPrint(freturnStatement);
|
||||||
printExpression(freturnStatement);
|
printExpression(freturnStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printFunctionStatement(functionStatement)
|
printFunctionStatement(functionStatementBodyType *functionStatement)
|
||||||
functionStatementBodyType *functionStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(functionStatement);
|
nullPrint(functionStatement);
|
||||||
tab();printf("(function name: %s)\n",functionStatement->functionName);
|
tab();printf("(function name: %s)\n",functionStatement->functionName);
|
||||||
|
@ -667,8 +636,7 @@ printFunctionStatement(functionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printIfStatement(ifStatement)
|
printIfStatement(ifStatementBodyType *ifStatement)
|
||||||
ifStatementBodyType *ifStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(ifStatement);
|
nullPrint(ifStatement);
|
||||||
tab(); printf("(condition: ");
|
tab(); printf("(condition: ");
|
||||||
|
@ -683,16 +651,14 @@ printIfStatement(ifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printIncludeStatement(includeStatement)
|
printIncludeStatement(includeStatementBodyType *includeStatement)
|
||||||
includeStatementBodyType *includeStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(includeStatement);
|
nullPrint(includeStatement);
|
||||||
printExpression(includeStatement);
|
printExpression(includeStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printInstructionStatement(instructionStatement)
|
printInstructionStatement(instructionStatementBodyType *instructionStatement)
|
||||||
instructionStatementBodyType *instructionStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(instructionStatement);
|
nullPrint(instructionStatement);
|
||||||
switch(instructionStatement->kindOfInstruction) {
|
switch(instructionStatement->kindOfInstruction) {
|
||||||
|
@ -713,16 +679,14 @@ printInstructionStatement(instructionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printLongStatement(longStatement)
|
printLongStatement(longStatementBodyType *longStatement)
|
||||||
longStatementBodyType *longStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(longStatement);
|
nullPrint(longStatement);
|
||||||
printExpressionList(longStatement);
|
printExpressionList(longStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMacroStatement(macroStatement)
|
printMacroStatement(macroStatementBodyType *macroStatement)
|
||||||
macroStatementBodyType *macroStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(macroStatement);
|
nullPrint(macroStatement);
|
||||||
tab(); printf("(macro name: %s)\n", macroStatement->theMacro);
|
tab(); printf("(macro name: %s)\n", macroStatement->theMacro);
|
||||||
|
@ -731,8 +695,7 @@ printMacroStatement(macroStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMdefineStatement(mdefineStatement)
|
printMdefineStatement(defineStatementBodyType *mdefineStatement)
|
||||||
defineStatementBodyType *mdefineStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mdefineStatement);
|
nullPrint(mdefineStatement);
|
||||||
printSymbol(mdefineStatement->theSymbol);
|
printSymbol(mdefineStatement->theSymbol);
|
||||||
|
@ -740,8 +703,7 @@ printMdefineStatement(mdefineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMdoUntilStatement(mdoUntilStatement)
|
printMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
|
||||||
mdoUntilStatementBodyType *mdoUntilStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mdoUntilStatement);
|
nullPrint(mdoUntilStatement);
|
||||||
printBlock(mdoUntilStatement->mdoUntilLoop);
|
printBlock(mdoUntilStatement->mdoUntilLoop);
|
||||||
|
@ -749,8 +711,7 @@ printMdoUntilStatement(mdoUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMdoWhileStatement(mdoWhileStatement)
|
printMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
|
||||||
mdoWhileStatementBodyType *mdoWhileStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mdoWhileStatement);
|
nullPrint(mdoWhileStatement);
|
||||||
printBlock(mdoWhileStatement->mdoWhileLoop);
|
printBlock(mdoWhileStatement->mdoWhileLoop);
|
||||||
|
@ -758,8 +719,7 @@ printMdoWhileStatement(mdoWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMforStatement(mforStatement)
|
printMforStatement(mforStatementBodyType *mforStatement)
|
||||||
mforStatementBodyType *mforStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mforStatement);
|
nullPrint(mforStatement);
|
||||||
printExpression(mforStatement->initExpression);
|
printExpression(mforStatement->initExpression);
|
||||||
|
@ -769,8 +729,7 @@ printMforStatement(mforStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMifStatement(mifStatement)
|
printMifStatement(mifStatementBodyType *mifStatement)
|
||||||
mifStatementBodyType *mifStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mifStatement);
|
nullPrint(mifStatement);
|
||||||
printExpression(mifStatement->mifCondition);
|
printExpression(mifStatement->mifCondition);
|
||||||
|
@ -783,8 +742,7 @@ printMifStatement(mifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMswitchStatement(mswitchStatement)
|
printMswitchStatement(mswitchStatementBodyType *mswitchStatement)
|
||||||
mswitchStatementBodyType *mswitchStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mswitchStatement);
|
nullPrint(mswitchStatement);
|
||||||
printExpression(mswitchStatement->switchExpression);
|
printExpression(mswitchStatement->switchExpression);
|
||||||
|
@ -792,8 +750,7 @@ printMswitchStatement(mswitchStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMvariableStatement(mvariableStatement)
|
printMvariableStatement(mvariableStatementBodyType *mvariableStatement)
|
||||||
mvariableStatementBodyType *mvariableStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mvariableStatement);
|
nullPrint(mvariableStatement);
|
||||||
printSymbol(mvariableStatement->theSymbol);
|
printSymbol(mvariableStatement->theSymbol);
|
||||||
|
@ -801,8 +758,7 @@ printMvariableStatement(mvariableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printMwhileStatement(mwhileStatement)
|
printMwhileStatement(mwhileStatementBodyType *mwhileStatement)
|
||||||
mwhileStatementBodyType *mwhileStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(mwhileStatement);
|
nullPrint(mwhileStatement);
|
||||||
printExpression(mwhileStatement->mwhileCondition);
|
printExpression(mwhileStatement->mwhileCondition);
|
||||||
|
@ -810,47 +766,41 @@ printMwhileStatement(mwhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printOrgStatement(orgStatement)
|
printOrgStatement(orgStatementBodyType *orgStatement)
|
||||||
orgStatementBodyType *orgStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(orgStatement);
|
nullPrint(orgStatement);
|
||||||
printExpression(orgStatement);
|
printExpression(orgStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printPerformStatement(performStatement)
|
printPerformStatement(performStatementBodyType *performStatement)
|
||||||
performStatementBodyType *performStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(performStatement);
|
nullPrint(performStatement);
|
||||||
printExpression(performStatement);
|
printExpression(performStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printRelStatement(relStatement)
|
printRelStatement(relStatementBodyType *relStatement)
|
||||||
relStatementBodyType *relStatement;
|
|
||||||
{
|
{
|
||||||
/* there's nothing here... */
|
/* there's nothing here... */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printStartStatement(startStatement)
|
printStartStatement(startStatementBodyType *startStatement)
|
||||||
startStatementBodyType *startStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(startStatement);
|
nullPrint(startStatement);
|
||||||
printExpression(startStatement);
|
printExpression(startStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printStringStatement(stringStatement)
|
printStringStatement(stringStatementBodyType *stringStatement)
|
||||||
stringStatementBodyType *stringStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(stringStatement);
|
nullPrint(stringStatement);
|
||||||
printExpressionList(stringStatement);
|
printExpressionList(stringStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printStructStatement(structStatement)
|
printStructStatement(structStatementBodyType *structStatement)
|
||||||
structStatementBodyType *structStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(structStatement);
|
nullPrint(structStatement);
|
||||||
printSymbol(structStatement->structName);
|
printSymbol(structStatement->structName);
|
||||||
|
@ -858,24 +808,21 @@ printStructStatement(structStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printTargetStatement(targetStatement)
|
printTargetStatement(targetStatementBodyType *targetStatement)
|
||||||
targetStatementBodyType *targetStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(targetStatement);
|
nullPrint(targetStatement);
|
||||||
printExpression(targetStatement);
|
printExpression(targetStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printUndefineStatement(undefineStatement)
|
printUndefineStatement(undefineStatementBodyType *undefineStatement)
|
||||||
undefineStatementBodyType *undefineStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(undefineStatement);
|
nullPrint(undefineStatement);
|
||||||
printIdentifierList(undefineStatement);
|
printIdentifierList(undefineStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printVariableStatement(variableStatement)
|
printVariableStatement(variableStatementBodyType *variableStatement)
|
||||||
variableStatementBodyType *variableStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(variableStatement);
|
nullPrint(variableStatement);
|
||||||
printSymbol(variableStatement->theSymbol);
|
printSymbol(variableStatement->theSymbol);
|
||||||
|
@ -883,8 +830,7 @@ printVariableStatement(variableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printWhileStatement(whileStatement)
|
printWhileStatement(whileStatementBodyType *whileStatement)
|
||||||
whileStatementBodyType *whileStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(whileStatement);
|
nullPrint(whileStatement);
|
||||||
tab(); printf("(condition: ");
|
tab(); printf("(condition: ");
|
||||||
|
@ -894,16 +840,14 @@ printWhileStatement(whileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printWordStatement(wordStatement)
|
printWordStatement(wordStatementBodyType *wordStatement)
|
||||||
wordStatementBodyType *wordStatement;
|
|
||||||
{
|
{
|
||||||
nullPrint(wordStatement);
|
nullPrint(wordStatement);
|
||||||
printExpressionList(wordStatement);
|
printExpressionList(wordStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printLabelList(labelList)
|
printLabelList(labelListType *labelList)
|
||||||
labelListType *labelList;
|
|
||||||
{
|
{
|
||||||
nullPrint(labelList);
|
nullPrint(labelList);
|
||||||
tab(); printf("(\n");
|
tab(); printf("(\n");
|
||||||
|
@ -917,9 +861,7 @@ printLabelList(labelList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printStatementBody(kind, body)
|
printStatementBody(statementKindType kind, statementBodyType body)
|
||||||
statementKindType kind;
|
|
||||||
statementBodyType body;
|
|
||||||
{
|
{
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
|
||||||
|
@ -1082,8 +1024,7 @@ printStatementBody(kind, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printStatement(statement)
|
printStatement(statementType *statement)
|
||||||
statementType *statement;
|
|
||||||
{
|
{
|
||||||
nullPrint(statement);
|
nullPrint(statement);
|
||||||
tab(); printf("(statement[");
|
tab(); printf("(statement[");
|
||||||
|
@ -1104,8 +1045,7 @@ printStatement(statement)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
printPendingFixupList(fixupList)
|
printPendingFixupList(fixupListType *fixupList)
|
||||||
fixupListType *fixupList;
|
|
||||||
{
|
{
|
||||||
printf("fixup list: (");
|
printf("fixup list: (");
|
||||||
tablevel++;
|
tablevel++;
|
||||||
|
@ -1118,10 +1058,7 @@ printPendingFixupList(fixupList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printCreateFixup(expression, location, kindOfFixup)
|
printCreateFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup)
|
||||||
expressionType *expression;
|
|
||||||
addressType location;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
static char *fixupStringTable[] = {
|
static char *fixupStringTable[] = {
|
||||||
"BYTE FIXUP",
|
"BYTE FIXUP",
|
||||||
|
@ -1145,7 +1082,7 @@ printCreateFixup(expression, location, kindOfFixup)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
printExpressionBuffer()
|
printExpressionBuffer(void)
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1160,9 +1097,7 @@ printExpressionBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printOneCodeBuffer(codeSegment, bufferNum)
|
printOneCodeBuffer(codeSegmentType *codeSegment, int bufferNum)
|
||||||
codeSegmentType *codeSegment;
|
|
||||||
int bufferNum;
|
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1190,8 +1125,7 @@ printOneCodeBuffer(codeSegment, bufferNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printCodeBufferSection(codeBufferSection)
|
printCodeBufferSection(codeRegionType *codeBufferSection)
|
||||||
codeRegionType *codeBufferSection;
|
|
||||||
{
|
{
|
||||||
bool anyCodeThereFlag;
|
bool anyCodeThereFlag;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1209,7 +1143,7 @@ printCodeBufferSection(codeBufferSection)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printCodeBuffers()
|
printCodeBuffers(void)
|
||||||
{
|
{
|
||||||
printf("absolute code:\n");
|
printf("absolute code:\n");
|
||||||
printCodeBufferSection(&absoluteCodeRegion);
|
printCodeBufferSection(&absoluteCodeRegion);
|
||||||
|
|
|
@ -39,9 +39,14 @@ int tablevel;
|
||||||
/* Fundamental nop print operation */
|
/* Fundamental nop print operation */
|
||||||
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
|
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
|
||||||
|
|
||||||
void
|
|
||||||
printCondition(condition)
|
extern void tab (void);
|
||||||
conditionType condition;
|
extern void printExpression (expressionType *expression);
|
||||||
|
extern void printIdentifierList (identifierListType *identifierList);
|
||||||
|
extern void printBlock (blockType *block);
|
||||||
|
|
||||||
|
void
|
||||||
|
printCondition(conditionType condition)
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'conditionType'. */
|
enumerated type 'conditionType'. */
|
||||||
|
@ -70,8 +75,7 @@ printCondition(condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printOperandKind(kind)
|
printOperandKind(operandKindType kind)
|
||||||
operandKindType kind;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'operandKindType'. */
|
enumerated type 'operandKindType'. */
|
||||||
|
@ -97,8 +101,7 @@ printOperandKind(kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printToken(token)
|
printToken(int token)
|
||||||
int token;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the set of '#define's in
|
/* This table MUST be maintained congruently with the set of '#define's in
|
||||||
the file 'y.tab.h' as produced by yacc. */
|
the file 'y.tab.h' as produced by yacc. */
|
||||||
|
@ -193,8 +196,7 @@ printToken(token)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printOperand(operand)
|
printOperand(operandType *operand)
|
||||||
operandType *operand;
|
|
||||||
{
|
{
|
||||||
nullPrint(operand);
|
nullPrint(operand);
|
||||||
tab(); printf("(operand: [");
|
tab(); printf("(operand: [");
|
||||||
|
|
3
driver.c
3
driver.c
|
@ -38,8 +38,7 @@ char *m68000 = "68000";
|
||||||
|
|
||||||
char **mlist;
|
char **mlist;
|
||||||
|
|
||||||
main(argc, argv)
|
main(int argc, char **argv)
|
||||||
char **argv;
|
|
||||||
{
|
{
|
||||||
char *processor = m6502;
|
char *processor = m6502;
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -37,11 +37,16 @@
|
||||||
branching from the current location given a condition to branch upon and a
|
branching from the current location given a condition to branch upon and a
|
||||||
target address. */
|
target address. */
|
||||||
|
|
||||||
void
|
|
||||||
emitRelativeBranch(condition, target, fixupLocation)
|
extern void emitByte (byte byteValue);
|
||||||
conditionType condition;
|
extern void emitRelativeByteOffset (valueType *target);
|
||||||
valueType *target;
|
extern void botch (char *message, ...);
|
||||||
valueType fixupLocation[COMPOUND_BRANCH_MAX];
|
extern void emitWord (wordType wordValue);
|
||||||
|
extern void noteAnonymousReference (void);
|
||||||
|
extern void emitWordValue (valueType *wordValue);
|
||||||
|
|
||||||
|
void
|
||||||
|
emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupLocation)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -139,14 +144,12 @@ emitRelativeBranch(condition, target, fixupLocation)
|
||||||
/* emitJump emits a 6502 jump instruction given the target address */
|
/* emitJump emits a 6502 jump instruction given the target address */
|
||||||
|
|
||||||
simpleFixupListType *
|
simpleFixupListType *
|
||||||
emitJump(target, previousFixups)
|
emitJump(valueType *target, simpleFixupListType *previousFixups)
|
||||||
valueType *target;
|
|
||||||
simpleFixupListType *previousFixups;
|
|
||||||
{
|
{
|
||||||
simpleFixupListType *result;
|
simpleFixupListType *result;
|
||||||
valueType picFixup[COMPOUND_BRANCH_MAX];
|
valueType picFixup[COMPOUND_BRANCH_MAX];
|
||||||
|
|
||||||
simpleFixupListType *buildSimpleFixupList();
|
simpleFixupListType *buildSimpleFixupList(valueType locationToFixup, simpleFixupListType *previousList);
|
||||||
|
|
||||||
#define JUMP_OPCODE 0x4C
|
#define JUMP_OPCODE 0x4C
|
||||||
|
|
||||||
|
|
83
emitStuff.c
83
emitStuff.c
|
@ -62,10 +62,19 @@
|
||||||
|
|
||||||
/* incarnateCodeBuffer causes code buffer space to actually be allocated */
|
/* incarnateCodeBuffer causes code buffer space to actually be allocated */
|
||||||
|
|
||||||
void
|
|
||||||
incarnateCodeBuffer(bufferNum, bufferKind)
|
extern void fatalError (errorType theError, ...);
|
||||||
int bufferNum;
|
extern bool byteCheck (int value);
|
||||||
codeBufferKindType bufferKind;
|
extern void printValue (valueType *value);
|
||||||
|
extern void error (errorType theError, ...);
|
||||||
|
extern char *valueKindString (valueKindType valueKind);
|
||||||
|
extern bool wordCheck (int value);
|
||||||
|
extern bool isByteOffset (int value);
|
||||||
|
extern bool isWordOffset (int value);
|
||||||
|
extern void noteAnonymousReference (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
incarnateCodeBuffer(int bufferNum, codeBufferKindType bufferKind)
|
||||||
{
|
{
|
||||||
codeSegmentType *newCodeSegment;
|
codeSegmentType *newCodeSegment;
|
||||||
codeBufferType *newCodeBuffer;
|
codeBufferType *newCodeBuffer;
|
||||||
|
@ -88,9 +97,7 @@ incarnateCodeBuffer(bufferNum, bufferKind)
|
||||||
care to make sure said buffer actually exists before using it. */
|
care to make sure said buffer actually exists before using it. */
|
||||||
|
|
||||||
void
|
void
|
||||||
putByte(address, byteValue)
|
putByte(addressType address, byte byteValue)
|
||||||
addressType address;
|
|
||||||
byte byteValue;
|
|
||||||
{
|
{
|
||||||
int bufferNum;
|
int bufferNum;
|
||||||
int bufferPos;
|
int bufferPos;
|
||||||
|
@ -131,9 +138,7 @@ putByte(address, byteValue)
|
||||||
buffer */
|
buffer */
|
||||||
|
|
||||||
void
|
void
|
||||||
mapByte(address, byteValue)
|
mapByte(int address, byte byteValue)
|
||||||
int address;
|
|
||||||
byte byteValue;
|
|
||||||
{
|
{
|
||||||
if (address < MAXIMUM_ALLOWED_STRUCT_SIZE)
|
if (address < MAXIMUM_ALLOWED_STRUCT_SIZE)
|
||||||
structScratchBuffer[address] = byteValue;
|
structScratchBuffer[address] = byteValue;
|
||||||
|
@ -144,8 +149,7 @@ mapByte(address, byteValue)
|
||||||
code buffer or the current struct assembly buffer */
|
code buffer or the current struct assembly buffer */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitByte(byteValue)
|
emitByte(byte byteValue)
|
||||||
byte byteValue;
|
|
||||||
{
|
{
|
||||||
if (debug || emitPrint)
|
if (debug || emitPrint)
|
||||||
if (structNestingDepth == 0)
|
if (structNestingDepth == 0)
|
||||||
|
@ -165,8 +169,7 @@ emitByte(byteValue)
|
||||||
/* emitWord similarly emits a word */
|
/* emitWord similarly emits a word */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitWord(wordValue)
|
emitWord(wordType wordValue)
|
||||||
wordType wordValue;
|
|
||||||
{
|
{
|
||||||
byteToWordType convert;
|
byteToWordType convert;
|
||||||
int loByte, hiByte;
|
int loByte, hiByte;
|
||||||
|
@ -216,8 +219,7 @@ emitWord(wordValue)
|
||||||
/* emitLong similarly emits a long */
|
/* emitLong similarly emits a long */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitLong(longValue)
|
emitLong(longType longValue)
|
||||||
longType longValue;
|
|
||||||
{
|
{
|
||||||
byteToLongType convert;
|
byteToLongType convert;
|
||||||
int loByte, secondByte, thirdByte, hiByte;
|
int loByte, secondByte, thirdByte, hiByte;
|
||||||
|
@ -286,8 +288,7 @@ emitLong(longValue)
|
||||||
/* emitByteValue takes the byte to be emitted out of a 'valueType' */
|
/* emitByteValue takes the byte to be emitted out of a 'valueType' */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitByteValue(byteValue)
|
emitByteValue(valueType *byteValue)
|
||||||
valueType *byteValue;
|
|
||||||
{
|
{
|
||||||
if (byteValue->kindOfValue == ABSOLUTE_VALUE || byteValue->kindOfValue ==
|
if (byteValue->kindOfValue == ABSOLUTE_VALUE || byteValue->kindOfValue ==
|
||||||
RELOCATABLE_VALUE || byteValue->kindOfValue == UNDEFINED_VALUE) {
|
RELOCATABLE_VALUE || byteValue->kindOfValue == UNDEFINED_VALUE) {
|
||||||
|
@ -313,8 +314,7 @@ emitByteValue(byteValue)
|
||||||
/* emitString similarly spits out a string of bytes */
|
/* emitString similarly spits out a string of bytes */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitString(string)
|
emitString(stringType *string)
|
||||||
stringType *string;
|
|
||||||
{
|
{
|
||||||
if (debug || emitPrint)
|
if (debug || emitPrint)
|
||||||
if (structNestingDepth == 0)
|
if (structNestingDepth == 0)
|
||||||
|
@ -342,8 +342,7 @@ emitString(string)
|
||||||
/* emitWordValue emits a word out of a 'valueType' */
|
/* emitWordValue emits a word out of a 'valueType' */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitWordValue(wordValue)
|
emitWordValue(valueType *wordValue)
|
||||||
valueType *wordValue;
|
|
||||||
{
|
{
|
||||||
if (wordValue->kindOfValue == ABSOLUTE_VALUE || wordValue->kindOfValue ==
|
if (wordValue->kindOfValue == ABSOLUTE_VALUE || wordValue->kindOfValue ==
|
||||||
RELOCATABLE_VALUE || wordValue->kindOfValue == UNDEFINED_VALUE) {
|
RELOCATABLE_VALUE || wordValue->kindOfValue == UNDEFINED_VALUE) {
|
||||||
|
@ -369,8 +368,7 @@ emitWordValue(wordValue)
|
||||||
/* emitLongValue emits a long out of a 'valueType' */
|
/* emitLongValue emits a long out of a 'valueType' */
|
||||||
|
|
||||||
void
|
void
|
||||||
emitLongValue(longValue)
|
emitLongValue(valueType *longValue)
|
||||||
valueType *longValue;
|
|
||||||
{
|
{
|
||||||
if (longValue->kindOfValue == ABSOLUTE_VALUE || longValue->kindOfValue ==
|
if (longValue->kindOfValue == ABSOLUTE_VALUE || longValue->kindOfValue ==
|
||||||
RELOCATABLE_VALUE || longValue->kindOfValue == UNDEFINED_VALUE) {
|
RELOCATABLE_VALUE || longValue->kindOfValue == UNDEFINED_VALUE) {
|
||||||
|
@ -396,9 +394,7 @@ emitLongValue(longValue)
|
||||||
/* pokeByteValue is like 'emitByte' but it's random access */
|
/* pokeByteValue is like 'emitByte' but it's random access */
|
||||||
|
|
||||||
void
|
void
|
||||||
pokeByteValue(location, value)
|
pokeByteValue(addressType location, valueType *value)
|
||||||
addressType location;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
currentLocationCounter.value = location;
|
currentLocationCounter.value = location;
|
||||||
emitByteValue(value);
|
emitByteValue(value);
|
||||||
|
@ -408,9 +404,7 @@ pokeByteValue(location, value)
|
||||||
/* ditto pokeWordValue */
|
/* ditto pokeWordValue */
|
||||||
|
|
||||||
void
|
void
|
||||||
pokeWordValue(location, value)
|
pokeWordValue(addressType location, valueType *value)
|
||||||
addressType location;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
currentLocationCounter.value = location;
|
currentLocationCounter.value = location;
|
||||||
emitWordValue(value);
|
emitWordValue(value);
|
||||||
|
@ -420,9 +414,7 @@ pokeWordValue(location, value)
|
||||||
/* ditto pokeLongValue */
|
/* ditto pokeLongValue */
|
||||||
|
|
||||||
void
|
void
|
||||||
pokeLongValue(location, value)
|
pokeLongValue(addressType location, valueType *value)
|
||||||
addressType location;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
currentLocationCounter.value = location;
|
currentLocationCounter.value = location;
|
||||||
emitLongValue(value);
|
emitLongValue(value);
|
||||||
|
@ -433,9 +425,7 @@ pokeLongValue(location, value)
|
||||||
relative branches */
|
relative branches */
|
||||||
|
|
||||||
void
|
void
|
||||||
pokeRelativeByteValue(location, value)
|
pokeRelativeByteValue(addressType location, valueType *value)
|
||||||
addressType location;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
@ -456,9 +446,7 @@ pokeRelativeByteValue(location, value)
|
||||||
relative branches */
|
relative branches */
|
||||||
|
|
||||||
void
|
void
|
||||||
pokeRelativeWordValue(location, value)
|
pokeRelativeWordValue(addressType location, valueType *value)
|
||||||
addressType location;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
@ -475,8 +463,7 @@ pokeRelativeWordValue(location, value)
|
||||||
/* getByte fetches a byte back out of the labyrinth of code buffers */
|
/* getByte fetches a byte back out of the labyrinth of code buffers */
|
||||||
|
|
||||||
byte
|
byte
|
||||||
getByte(address)
|
getByte(addressType address)
|
||||||
addressType address;
|
|
||||||
{
|
{
|
||||||
int bufferNum;
|
int bufferNum;
|
||||||
int bufferPos;
|
int bufferPos;
|
||||||
|
@ -494,8 +481,7 @@ getByte(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
emitRelativeByteOffset(target)
|
emitRelativeByteOffset(valueType *target)
|
||||||
valueType *target;
|
|
||||||
{
|
{
|
||||||
int saveTargetOffset;
|
int saveTargetOffset;
|
||||||
|
|
||||||
|
@ -512,8 +498,7 @@ emitRelativeByteOffset(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
emitRelativeWordOffset(target)
|
emitRelativeWordOffset(valueType *target)
|
||||||
valueType *target;
|
|
||||||
{
|
{
|
||||||
int saveTargetOffset;
|
int saveTargetOffset;
|
||||||
|
|
||||||
|
@ -531,9 +516,7 @@ emitRelativeWordOffset(target)
|
||||||
has become known. */
|
has become known. */
|
||||||
|
|
||||||
void
|
void
|
||||||
fixupBranch(location, target)
|
fixupBranch(valueType *location, valueType target)
|
||||||
valueType location[COMPOUND_BRANCH_MAX];
|
|
||||||
valueType target;
|
|
||||||
{
|
{
|
||||||
valueType saveCurrentLocation;
|
valueType saveCurrentLocation;
|
||||||
int saveTargetOffset;
|
int saveTargetOffset;
|
||||||
|
@ -554,9 +537,7 @@ fixupBranch(location, target)
|
||||||
/* fixupJump similarly repairs a jump */
|
/* fixupJump similarly repairs a jump */
|
||||||
|
|
||||||
void
|
void
|
||||||
fixupJump(locations, target)
|
fixupJump(simpleFixupListType *locations, valueType target)
|
||||||
simpleFixupListType *locations;
|
|
||||||
valueType target;
|
|
||||||
{
|
{
|
||||||
valueType saveCurrentLocation;
|
valueType saveCurrentLocation;
|
||||||
simpleFixupListType *oldLocation;
|
simpleFixupListType *oldLocation;
|
||||||
|
|
105
encode.c
105
encode.c
|
@ -39,9 +39,20 @@
|
||||||
|
|
||||||
bool encodingFunction;
|
bool encodingFunction;
|
||||||
|
|
||||||
bool
|
|
||||||
encodeByte(aByte)
|
extern void error (errorType theError, ...);
|
||||||
byte aByte;
|
bool encodeIdentifier (symbolTableEntryType *identifier);
|
||||||
|
bool encodeExpression (expressionType *expression);
|
||||||
|
bool encodeValue (valueType *value);
|
||||||
|
bool encodeOperand (operandType *operand);
|
||||||
|
bool encodeString (stringType *string);
|
||||||
|
extern char *valueKindString (valueKindType valueKind);
|
||||||
|
extern void botch (char *message, ...);
|
||||||
|
bool encodeBlock (blockType *block);
|
||||||
|
extern stringType *statementKindString (statementKindType kind);
|
||||||
|
|
||||||
|
bool
|
||||||
|
encodeByte(byte aByte)
|
||||||
{
|
{
|
||||||
if (expressionBufferSize < EXPRESSION_BUFFER_LIMIT) {
|
if (expressionBufferSize < EXPRESSION_BUFFER_LIMIT) {
|
||||||
expressionBuffer[expressionBufferSize++] = aByte;
|
expressionBuffer[expressionBufferSize++] = aByte;
|
||||||
|
@ -53,8 +64,7 @@ encodeByte(aByte)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeBigword(bigword)
|
encodeBigword(int bigword)
|
||||||
int bigword;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<sizeof(int); ++i) {
|
for (i=0; i<sizeof(int); ++i) {
|
||||||
|
@ -66,8 +76,7 @@ encodeBigword(bigword)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeAssignmentTerm(assignmentTerm)
|
encodeAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
binopTermType *assignmentTerm;
|
|
||||||
{
|
{
|
||||||
nullEncode(assignmentTerm);
|
nullEncode(assignmentTerm);
|
||||||
if ((assignmentKindType)assignmentTerm->binop != ASSIGN_ASSIGN) {
|
if ((assignmentKindType)assignmentTerm->binop != ASSIGN_ASSIGN) {
|
||||||
|
@ -83,10 +92,9 @@ encodeAssignmentTerm(assignmentTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeBinopTerm(binopTerm)
|
encodeBinopTerm(binopTermType *binopTerm)
|
||||||
binopTermType *binopTerm;
|
|
||||||
{
|
{
|
||||||
bool encodeExpression();
|
bool encodeExpression(expressionType *expression);
|
||||||
|
|
||||||
nullEncode(binopTerm);
|
nullEncode(binopTerm);
|
||||||
return (
|
return (
|
||||||
|
@ -98,8 +106,7 @@ encodeBinopTerm(binopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeCondition(condition)
|
encodeCondition(conditionType condition)
|
||||||
conditionType condition;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(CONDITION_CODE_TAG) &&
|
encodeByte(CONDITION_CODE_TAG) &&
|
||||||
|
@ -108,8 +115,7 @@ encodeCondition(condition)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
functionNumber(function)
|
functionNumber(functionDefinitionType *function)
|
||||||
functionDefinitionType *function;
|
|
||||||
{
|
{
|
||||||
if (function->ordinal == -1) {
|
if (function->ordinal == -1) {
|
||||||
function->ordinal = externalFunctionCount++;
|
function->ordinal = externalFunctionCount++;
|
||||||
|
@ -126,8 +132,7 @@ functionNumber(function)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeFunctionCall(functionCall)
|
encodeFunctionCall(functionCallTermType *functionCall)
|
||||||
functionCallTermType *functionCall;
|
|
||||||
{
|
{
|
||||||
functionDefinitionType *theFunction;
|
functionDefinitionType *theFunction;
|
||||||
int functionOrdinal;
|
int functionOrdinal;
|
||||||
|
@ -177,14 +182,13 @@ encodeFunctionCall(functionCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeHere()
|
encodeHere(void)
|
||||||
{
|
{
|
||||||
return(encodeByte(HERE_TAG));
|
return(encodeByte(HERE_TAG));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeIdentifier(identifier)
|
encodeIdentifier(symbolTableEntryType *identifier)
|
||||||
symbolTableEntryType *identifier;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *workingContext;
|
symbolInContextType *workingContext;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
@ -248,8 +252,7 @@ encodeIdentifier(identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeNumber(number)
|
encodeNumber(numberTermType number)
|
||||||
numberTermType number;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(NUMBER_TAG) &&
|
encodeByte(NUMBER_TAG) &&
|
||||||
|
@ -258,8 +261,7 @@ encodeNumber(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeRelocatableNumber(number)
|
encodeRelocatableNumber(numberTermType number)
|
||||||
numberTermType number;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(RELOCATABLE_TAG) &&
|
encodeByte(RELOCATABLE_TAG) &&
|
||||||
|
@ -268,8 +270,7 @@ encodeRelocatableNumber(number)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeOperand(operand)
|
encodeOperand(operandType *operand)
|
||||||
operandType *operand;
|
|
||||||
{
|
{
|
||||||
switch (operand->kindOfOperand) {
|
switch (operand->kindOfOperand) {
|
||||||
case EXPRESSION_OPND:
|
case EXPRESSION_OPND:
|
||||||
|
@ -303,8 +304,7 @@ encodeOperand(operand)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodePostopTerm(postopTerm)
|
encodePostopTerm(postOpTermType *postopTerm)
|
||||||
postOpTermType *postopTerm;
|
|
||||||
{
|
{
|
||||||
nullEncode(postopTerm);
|
nullEncode(postopTerm);
|
||||||
return(
|
return(
|
||||||
|
@ -315,8 +315,7 @@ encodePostopTerm(postopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodePreopTerm(preopTerm)
|
encodePreopTerm(preOpTermType *preopTerm)
|
||||||
preOpTermType *preopTerm;
|
|
||||||
{
|
{
|
||||||
nullEncode(preopTerm);
|
nullEncode(preopTerm);
|
||||||
return(
|
return(
|
||||||
|
@ -327,8 +326,7 @@ encodePreopTerm(preopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeString(string)
|
encodeString(stringType *string)
|
||||||
stringType *string;
|
|
||||||
{
|
{
|
||||||
if (!encodeByte(STRING_TAG))
|
if (!encodeByte(STRING_TAG))
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
@ -340,8 +338,7 @@ encodeString(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeUnopTerm(unopTerm)
|
encodeUnopTerm(unopTermType *unopTerm)
|
||||||
unopTermType *unopTerm;
|
|
||||||
{
|
{
|
||||||
nullEncode(unopTerm);
|
nullEncode(unopTerm);
|
||||||
return(
|
return(
|
||||||
|
@ -352,8 +349,7 @@ encodeUnopTerm(unopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeValue(value)
|
encodeValue(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
switch (value->kindOfValue) {
|
switch (value->kindOfValue) {
|
||||||
case ABSOLUTE_VALUE:
|
case ABSOLUTE_VALUE:
|
||||||
|
@ -389,8 +385,7 @@ encodeValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeExpression(expression)
|
encodeExpression(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
nullEncode(expression);
|
nullEncode(expression);
|
||||||
switch (expression->kindOfTerm) {
|
switch (expression->kindOfTerm) {
|
||||||
|
@ -460,8 +455,7 @@ encodeExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeAssertStatement(assertStatement)
|
encodeAssertStatement(assertStatementBodyType *assertStatement)
|
||||||
assertStatementBodyType *assertStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(ASSERT_TAG) &&
|
encodeByte(ASSERT_TAG) &&
|
||||||
|
@ -471,8 +465,7 @@ encodeAssertStatement(assertStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeFreturnStatement(freturnStatement)
|
encodeFreturnStatement(freturnStatementBodyType *freturnStatement)
|
||||||
freturnStatementBodyType *freturnStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(FRETURN_TAG) &&
|
encodeByte(FRETURN_TAG) &&
|
||||||
|
@ -481,8 +474,7 @@ encodeFreturnStatement(freturnStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMdefineStatement(mdefineStatement)
|
encodeMdefineStatement(defineStatementBodyType *mdefineStatement)
|
||||||
defineStatementBodyType *mdefineStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(MDEFINE_TAG) &&
|
encodeByte(MDEFINE_TAG) &&
|
||||||
|
@ -492,8 +484,7 @@ encodeMdefineStatement(mdefineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMdoUntilStatement(mdoUntilStatement)
|
encodeMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
|
||||||
mdoUntilStatementBodyType *mdoUntilStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(MDOUNTIL_TAG) &&
|
encodeByte(MDOUNTIL_TAG) &&
|
||||||
|
@ -503,8 +494,7 @@ encodeMdoUntilStatement(mdoUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMdoWhileStatement(mdoWhileStatement)
|
encodeMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
|
||||||
mdoWhileStatementBodyType *mdoWhileStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(MDOWHILE_TAG) &&
|
encodeByte(MDOWHILE_TAG) &&
|
||||||
|
@ -514,8 +504,7 @@ encodeMdoWhileStatement(mdoWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMforStatement(mforStatement)
|
encodeMforStatement(mforStatementBodyType *mforStatement)
|
||||||
mforStatementBodyType *mforStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(MFOR_TAG) &&
|
encodeByte(MFOR_TAG) &&
|
||||||
|
@ -527,8 +516,7 @@ encodeMforStatement(mforStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMifStatement(mifStatement)
|
encodeMifStatement(mifStatementBodyType *mifStatement)
|
||||||
mifStatementBodyType *mifStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(MIF_TAG) &&
|
encodeByte(MIF_TAG) &&
|
||||||
|
@ -539,8 +527,7 @@ encodeMifStatement(mifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMswitchStatement(mswitchStatement)
|
encodeMswitchStatement(mswitchStatementBodyType *mswitchStatement)
|
||||||
mswitchStatementBodyType *mswitchStatement;
|
|
||||||
{
|
{
|
||||||
caseListType *caseList;
|
caseListType *caseList;
|
||||||
caseType *theCase;
|
caseType *theCase;
|
||||||
|
@ -564,8 +551,7 @@ encodeMswitchStatement(mswitchStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMvariableStatement(mvariableStatement)
|
encodeMvariableStatement(mvariableStatementBodyType *mvariableStatement)
|
||||||
mvariableStatementBodyType *mvariableStatement;
|
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
|
@ -585,8 +571,7 @@ encodeMvariableStatement(mvariableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeMwhileStatement(mwhileStatement)
|
encodeMwhileStatement(mwhileStatementBodyType *mwhileStatement)
|
||||||
mwhileStatementBodyType *mwhileStatement;
|
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
encodeByte(MWHILE_TAG) &&
|
encodeByte(MWHILE_TAG) &&
|
||||||
|
@ -596,8 +581,7 @@ encodeMwhileStatement(mwhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeStatement(statement)
|
encodeStatement(statementType *statement)
|
||||||
statementType *statement;
|
|
||||||
{
|
{
|
||||||
switch(statement->kindOfStatement) {
|
switch(statement->kindOfStatement) {
|
||||||
|
|
||||||
|
@ -677,8 +661,7 @@ encodeStatement(statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
encodeBlock(block)
|
encodeBlock(blockType *block)
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
if (!encodeByte(BLOCK_TAG))
|
if (!encodeByte(BLOCK_TAG))
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
|
19
errorStuff.c
19
errorStuff.c
|
@ -39,7 +39,12 @@ bool nullStatementFlag;
|
||||||
input up to the end of the line, in a (probably futile) effort to recover
|
input up to the end of the line, in a (probably futile) effort to recover
|
||||||
from the booboo. */
|
from the booboo. */
|
||||||
|
|
||||||
void
|
|
||||||
|
void verror (errorType theError, va_list ap);
|
||||||
|
void fatalError (errorType theError, ...);
|
||||||
|
extern void chokePukeAndDie (void);
|
||||||
|
|
||||||
|
void
|
||||||
puntOnError(errorType theError, ...)
|
puntOnError(errorType theError, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -289,8 +294,7 @@ fatalSystemError(errorType theError, ...)
|
||||||
the error message as a string (this is almost always 'syntax error'). */
|
the error message as a string (this is almost always 'syntax error'). */
|
||||||
|
|
||||||
void
|
void
|
||||||
yyerror(s)
|
yyerror(char *s)
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
printf("\"%s\", line %d: %s\n", currentFileName, currentLineNumber,s);
|
printf("\"%s\", line %d: %s\n", currentFileName, currentLineNumber,s);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
@ -304,8 +308,7 @@ yyerror(s)
|
||||||
in a sentence). */
|
in a sentence). */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
usageString(usageKind)
|
usageString(symbolUsageKindType usageKind)
|
||||||
symbolUsageKindType usageKind;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'symbolUsageKindType'. */
|
enumerated type 'symbolUsageKindType'. */
|
||||||
|
@ -336,8 +339,7 @@ usageString(usageKind)
|
||||||
/* valueKindString similarly deals with the different kinds of values. */
|
/* valueKindString similarly deals with the different kinds of values. */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
valueKindString(valueKind)
|
valueKindString(valueKindType valueKind)
|
||||||
valueKindType valueKind;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'valueKindType'. */
|
enumerated type 'valueKindType'. */
|
||||||
|
@ -366,8 +368,7 @@ valueKindString(valueKind)
|
||||||
/* assignmentString similarly handles assignments */
|
/* assignmentString similarly handles assignments */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
assignmentString(assignment)
|
assignmentString(assignmentKindType assignment)
|
||||||
assignmentKindType assignment;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'assignmentKindType'. */
|
enumerated type 'assignmentKindType'. */
|
||||||
|
|
|
@ -64,10 +64,32 @@ stringType *dbString;
|
||||||
#define moreStuff(f) (generatingFixup ? moreExpression(f) : moreText(f))
|
#define moreStuff(f) (generatingFixup ? moreExpression(f) : moreText(f))
|
||||||
#define moreStuff1(f,x) (generatingFixup? moreExpression(f,x) : moreText(f,x))
|
#define moreStuff1(f,x) (generatingFixup? moreExpression(f,x) : moreText(f,x))
|
||||||
|
|
||||||
anyOldThing *
|
|
||||||
arrayLookup(arrayTerm, kindOfThing)
|
extern void error (errorType theError, ...);
|
||||||
arrayTermType *arrayTerm;
|
extern char *valueKindString (valueKindType valueKind);
|
||||||
valueKindType *kindOfThing;
|
extern void moreExpression (char *format, ...);
|
||||||
|
extern valueType *evaluateOperand (operandType *operand);
|
||||||
|
extern char *tokenString (int token);
|
||||||
|
extern char *assignmentString (assignmentKindType assignment);
|
||||||
|
extern char *usageString (symbolUsageKindType usageKind);
|
||||||
|
extern valueType *makeUndefinedValue (void);
|
||||||
|
extern void botch (char *message, ...);
|
||||||
|
extern char *conditionString (conditionType condition);
|
||||||
|
extern int bindFunctionArguments (argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *functionName);
|
||||||
|
extern void assembleBlock (blockType *block);
|
||||||
|
extern void unbindArguments (argumentDefinitionListType *argumentList, int numberToUnbind);
|
||||||
|
extern void unbindLocalVariables (identifierListType *identifierList);
|
||||||
|
extern void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage);
|
||||||
|
extern bool shouldParenthesize (operandType *operand);
|
||||||
|
extern void moreText (char *format, ...);
|
||||||
|
extern void endLine (void);
|
||||||
|
extern void tabIndent (void);
|
||||||
|
extern void flushExpressionString (void);
|
||||||
|
extern operandType *buildOperand (operandKindType kindOfOperand, anyOldThing *arg);
|
||||||
|
extern expressionType *generateFixupExpression (expressionType *expression);
|
||||||
|
|
||||||
|
anyOldThing *
|
||||||
|
arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing)
|
||||||
{
|
{
|
||||||
valueType *arrayValue;
|
valueType *arrayValue;
|
||||||
valueType *indexValue;
|
valueType *indexValue;
|
||||||
|
@ -124,8 +146,7 @@ arrayLookup(arrayTerm, kindOfThing)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateArrayTerm(arrayTerm)
|
evaluateArrayTerm(arrayTermType *arrayTerm)
|
||||||
arrayTermType *arrayTerm;
|
|
||||||
{
|
{
|
||||||
anyOldThing *resultThing;
|
anyOldThing *resultThing;
|
||||||
valueKindType kindOfResult;
|
valueKindType kindOfResult;
|
||||||
|
@ -169,9 +190,7 @@ evaluateArrayTerm(arrayTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateAssignmentTerm(assignmentTerm, kindOfFixup)
|
evaluateAssignmentTerm(binopTermType *assignmentTerm, fixupKindType kindOfFixup)
|
||||||
binopTermType *assignmentTerm;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *targetSymbol;
|
symbolTableEntryType *targetSymbol;
|
||||||
valueType *target;
|
valueType *target;
|
||||||
|
@ -363,10 +382,7 @@ evaluateAssignmentTerm(assignmentTerm, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateBinopTerm(binopTerm, isTopLevel, kindOfFixup)
|
evaluateBinopTerm(binopTermType *binopTerm, bool isTopLevel, fixupKindType kindOfFixup)
|
||||||
binopTermType *binopTerm;
|
|
||||||
bool isTopLevel;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *leftOperand;
|
valueType *leftOperand;
|
||||||
valueType *rightOperand;
|
valueType *rightOperand;
|
||||||
|
@ -580,18 +596,14 @@ evaluateBinopTerm(binopTerm, isTopLevel, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateCondition(condition)
|
evaluateCondition(conditionType condition)
|
||||||
conditionType condition;
|
|
||||||
{
|
{
|
||||||
expand(moreExpression("%s", conditionString(condition)));
|
expand(moreExpression("%s", conditionString(condition)));
|
||||||
return(newValue(CONDITION_VALUE, condition, EXPRESSION_OPND));
|
return(newValue(CONDITION_VALUE, condition, EXPRESSION_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateBuiltInFunctionCall(workingContext, parameters, kindOfFixup)
|
evaluateBuiltInFunctionCall(symbolInContextType *workingContext, operandListType *parameters, fixupKindType kindOfFixup)
|
||||||
symbolInContextType *workingContext;
|
|
||||||
operandListType *parameters;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
sideEffectFlag = TRUE;
|
sideEffectFlag = TRUE;
|
||||||
return((*builtInFunctionTable[workingContext->value->value].
|
return((*builtInFunctionTable[workingContext->value->value].
|
||||||
|
@ -599,10 +611,7 @@ evaluateBuiltInFunctionCall(workingContext, parameters, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateFunctionCall(functionCall, kindOfFixup, isStandalone)
|
evaluateFunctionCall(functionCallTermType *functionCall, fixupKindType kindOfFixup, bool isStandalone)
|
||||||
functionCallTermType *functionCall;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
bool isStandalone;
|
|
||||||
{
|
{
|
||||||
functionDefinitionType *theFunction;
|
functionDefinitionType *theFunction;
|
||||||
int numberBound;
|
int numberBound;
|
||||||
|
@ -682,7 +691,7 @@ evaluateFunctionCall(functionCall, kindOfFixup, isStandalone)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateHere()
|
evaluateHere(void)
|
||||||
{
|
{
|
||||||
valueType *result;
|
valueType *result;
|
||||||
|
|
||||||
|
@ -694,10 +703,7 @@ evaluateHere()
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateIdentifier(identifier, isTopLevel, kindOfFixup)
|
evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup)
|
||||||
symbolTableEntryType *identifier;
|
|
||||||
bool isTopLevel;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *workingContext;
|
symbolInContextType *workingContext;
|
||||||
valueType *resultValue;
|
valueType *resultValue;
|
||||||
|
@ -821,16 +827,14 @@ evaluateIdentifier(identifier, isTopLevel, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateNumber(number)
|
evaluateNumber(numberTermType number)
|
||||||
numberTermType number;
|
|
||||||
{
|
{
|
||||||
expand(moreExpression("0x%x", number));
|
expand(moreExpression("0x%x", number));
|
||||||
return(newValue(ABSOLUTE_VALUE, number, EXPRESSION_OPND));
|
return(newValue(ABSOLUTE_VALUE, number, EXPRESSION_OPND));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluatePostopTerm(postopTerm)
|
evaluatePostopTerm(postOpTermType *postopTerm)
|
||||||
postOpTermType *postopTerm;
|
|
||||||
{
|
{
|
||||||
valueType *theOperand;
|
valueType *theOperand;
|
||||||
valueType **theOperandPtr;
|
valueType **theOperandPtr;
|
||||||
|
@ -897,8 +901,7 @@ evaluatePostopTerm(postopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluatePreopTerm(preopTerm)
|
evaluatePreopTerm(preOpTermType *preopTerm)
|
||||||
preOpTermType *preopTerm;
|
|
||||||
{
|
{
|
||||||
valueType *theOperand;
|
valueType *theOperand;
|
||||||
valueType *result;
|
valueType *result;
|
||||||
|
@ -965,8 +968,7 @@ evaluatePreopTerm(preopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateString(string)
|
evaluateString(stringType *string)
|
||||||
stringType *string;
|
|
||||||
{
|
{
|
||||||
stringType *newString;
|
stringType *newString;
|
||||||
|
|
||||||
|
@ -977,9 +979,7 @@ evaluateString(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateUnopTerm(unopTerm, kindOfFixup)
|
evaluateUnopTerm(unopTermType *unopTerm, fixupKindType kindOfFixup)
|
||||||
unopTermType *unopTerm;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *theOperand;
|
valueType *theOperand;
|
||||||
valueKindType resultKindOfValue;
|
valueKindType resultKindOfValue;
|
||||||
|
@ -1031,11 +1031,7 @@ evaluateUnopTerm(unopTerm, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateExpressionInternally(expression, isTopLevel, kindOfFixup,isStandalone)
|
evaluateExpressionInternally(expressionType *expression, bool isTopLevel, fixupKindType kindOfFixup, bool isStandalone)
|
||||||
expressionType *expression;
|
|
||||||
bool isTopLevel;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
bool isStandalone;
|
|
||||||
{
|
{
|
||||||
valueType *result;
|
valueType *result;
|
||||||
|
|
||||||
|
@ -1125,9 +1121,7 @@ evaluateExpressionInternally(expression, isTopLevel, kindOfFixup,isStandalone)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateExpression(expression, kindOfFixup)
|
evaluateExpression(expressionType *expression, fixupKindType kindOfFixup)
|
||||||
expressionType *expression;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
{
|
{
|
||||||
valueType *result;
|
valueType *result;
|
||||||
|
|
||||||
|
@ -1148,8 +1142,7 @@ evaluateExpression(expression, kindOfFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evaluateExpressionStandalone(expression)
|
evaluateExpressionStandalone(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
valueType *expressionResult;
|
valueType *expressionResult;
|
||||||
|
@ -1169,8 +1162,7 @@ evaluateExpressionStandalone(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateDefineExpression(expression)
|
evaluateDefineExpression(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
nullEvaluate(expression);
|
nullEvaluate(expression);
|
||||||
return(newValue(OPERAND_VALUE, buildOperand(EXPRESSION_OPND,
|
return(newValue(OPERAND_VALUE, buildOperand(EXPRESSION_OPND,
|
||||||
|
@ -1178,8 +1170,7 @@ evaluateDefineExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateSelectionList(selectionList)
|
evaluateSelectionList(selectionListType *selectionList)
|
||||||
selectionListType *selectionList;
|
|
||||||
{
|
{
|
||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ valueType *evaluateBinopTerm(binopTermType *assignmentTerm, bool isTopLevel, fix
|
||||||
valueType *evaluateCondition(conditionType condition);
|
valueType *evaluateCondition(conditionType condition);
|
||||||
valueType *evaluateBuiltInFunctionCall(symbolInContextType *workingContext, operandListType *parameters, fixupKindType kindOfFixup);
|
valueType *evaluateBuiltInFunctionCall(symbolInContextType *workingContext, operandListType *parameters, fixupKindType kindOfFixup);
|
||||||
valueType *evaluateFunctionCall(functionCallTermType *functionCall, fixupKindType kindOfFixup, bool isStandalone);
|
valueType *evaluateFunctionCall(functionCallTermType *functionCall, fixupKindType kindOfFixup, bool isStandalone);
|
||||||
valueType *evaluateHere();
|
valueType *evaluateHere(void);
|
||||||
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
||||||
valueType *evaluateNumber(numberTermType number);
|
valueType *evaluateNumber(numberTermType number);
|
||||||
valueType *evaluatePostopTerm(postOpTermType *postopTerm);
|
valueType *evaluatePostopTerm(postOpTermType *postopTerm);
|
||||||
|
|
52
fixups.c
52
fixups.c
|
@ -57,12 +57,19 @@ stringType *dbString = "graphics2.m";
|
||||||
The routines below collectively duplicate expressions for later evaluation.
|
The routines below collectively duplicate expressions for later evaluation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
expressionType *
|
|
||||||
generateFixupExpression(expression)
|
extern void moreExpression (char *format, ...);
|
||||||
expressionType *expression;
|
extern bool isUndefined (valueType *value);
|
||||||
|
extern char *tokenString (int token);
|
||||||
|
extern void error (errorType theError, ...);
|
||||||
|
extern char *conditionString (conditionType condition);
|
||||||
|
extern void botch (char *message, ...);
|
||||||
|
|
||||||
|
expressionType *
|
||||||
|
generateFixupExpression(expressionType *expression)
|
||||||
{
|
{
|
||||||
expressionType *result;
|
expressionType *result;
|
||||||
expressionType *duplicateExpressionForFixup();
|
expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand);
|
||||||
|
|
||||||
generatingFixup = TRUE;
|
generatingFixup = TRUE;
|
||||||
result = duplicateExpressionForFixup(expression, TRUE, FALSE);
|
result = duplicateExpressionForFixup(expression, TRUE, FALSE);
|
||||||
|
@ -71,10 +78,7 @@ generateFixupExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
expressionType *
|
expressionType *
|
||||||
duplicateExpressionForFixup(expression, isTopLevel, isSpecialFunctionOperand)
|
duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand)
|
||||||
expressionType *expression;
|
|
||||||
bool isTopLevel;
|
|
||||||
bool isSpecialFunctionOperand;
|
|
||||||
{
|
{
|
||||||
expressionType *result;
|
expressionType *result;
|
||||||
expressionType *originalResult;
|
expressionType *originalResult;
|
||||||
|
@ -85,15 +89,15 @@ duplicateExpressionForFixup(expression, isTopLevel, isSpecialFunctionOperand)
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
|
||||||
operandType *duplicateOperandForFixup();
|
operandType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
functionCallTermType *duplicateFunctionCall();
|
functionCallTermType *duplicateFunctionCall(functionCallTermType *functionCall);
|
||||||
expressionType *duplicateArrayReference();
|
expressionType *duplicateArrayReference(arrayTermType *arrayTerm);
|
||||||
valueType *evaluateIdentifier();
|
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
||||||
valueType *evaluateHere();
|
valueType *evaluateHere(void);
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
symbolTableEntryType *generateLocalLabel();
|
symbolTableEntryType *generateLocalLabel(symbolTableEntryType *symbol);
|
||||||
stringType *saveString();
|
stringType *saveString(char *s);
|
||||||
|
|
||||||
nullDup(expression);
|
nullDup(expression);
|
||||||
result = originalResult = typeAlloc(expressionType);
|
result = originalResult = typeAlloc(expressionType);
|
||||||
|
@ -280,14 +284,13 @@ duplicateExpressionForFixup(expression, isTopLevel, isSpecialFunctionOperand)
|
||||||
}
|
}
|
||||||
|
|
||||||
functionCallTermType *
|
functionCallTermType *
|
||||||
duplicateFunctionCall(functionCall)
|
duplicateFunctionCall(functionCallTermType *functionCall)
|
||||||
functionCallTermType *functionCall;
|
|
||||||
{
|
{
|
||||||
functionCallTermType *result;
|
functionCallTermType *result;
|
||||||
operandListType **argument;
|
operandListType **argument;
|
||||||
operandListType *parameterList;
|
operandListType *parameterList;
|
||||||
|
|
||||||
operandListType *duplicateOperandForFixup();
|
operandListType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
|
||||||
|
|
||||||
result = typeAlloc(functionCallTermType);
|
result = typeAlloc(functionCallTermType);
|
||||||
result->functionName = functionCall->functionName;
|
result->functionName = functionCall->functionName;
|
||||||
|
@ -310,8 +313,7 @@ duplicateFunctionCall(functionCall)
|
||||||
|
|
||||||
|
|
||||||
expressionType *
|
expressionType *
|
||||||
duplicateArrayReference(arrayTerm)
|
duplicateArrayReference(arrayTermType *arrayTerm)
|
||||||
arrayTermType *arrayTerm;
|
|
||||||
{
|
{
|
||||||
anyOldThing *resultThing;
|
anyOldThing *resultThing;
|
||||||
valueKindType kindOfResult;
|
valueKindType kindOfResult;
|
||||||
|
@ -322,9 +324,9 @@ duplicateArrayReference(arrayTerm)
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
operandType *newOperand;
|
operandType *newOperand;
|
||||||
|
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
operandType *duplicateOperandForFixup();
|
operandType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
|
||||||
anyOldThing *arrayLookup();
|
anyOldThing *arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing);
|
||||||
|
|
||||||
expansionOff();
|
expansionOff();
|
||||||
resultThing = arrayLookup(arrayTerm, &kindOfResult);
|
resultThing = arrayLookup(arrayTerm, &kindOfResult);
|
||||||
|
|
199
garbage.c
199
garbage.c
|
@ -33,11 +33,14 @@
|
||||||
|
|
||||||
#define nullFree(thing) if (thing == NULL) return;
|
#define nullFree(thing) if (thing == NULL) return;
|
||||||
|
|
||||||
void
|
|
||||||
freeArrayTerm(arrayTerm)
|
extern void botch (char *message, ...);
|
||||||
arrayTermType *arrayTerm;
|
extern void freeOperand (operandType *operand);
|
||||||
|
|
||||||
|
void
|
||||||
|
freeArrayTerm(arrayTermType *arrayTerm)
|
||||||
{
|
{
|
||||||
void freeExpression();
|
void freeExpression(expressionType *expression);
|
||||||
|
|
||||||
nullFree(arrayTerm);
|
nullFree(arrayTerm);
|
||||||
freeExpression(arrayTerm->arrayName);
|
freeExpression(arrayTerm->arrayName);
|
||||||
|
@ -46,10 +49,9 @@ freeArrayTerm(arrayTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeAssignmentTerm(assignmentTerm)
|
freeAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
binopTermType *assignmentTerm;
|
|
||||||
{
|
{
|
||||||
void freeExpression();
|
void freeExpression(expressionType *expression);
|
||||||
|
|
||||||
nullFree(assignmentTerm);
|
nullFree(assignmentTerm);
|
||||||
freeExpression(assignmentTerm->rightArgument);
|
freeExpression(assignmentTerm->rightArgument);
|
||||||
|
@ -57,10 +59,9 @@ freeAssignmentTerm(assignmentTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeBinopTerm(binopTerm)
|
freeBinopTerm(binopTermType *binopTerm)
|
||||||
binopTermType *binopTerm;
|
|
||||||
{
|
{
|
||||||
void freeExpression();
|
void freeExpression(expressionType *expression);
|
||||||
|
|
||||||
nullFree(binopTerm);
|
nullFree(binopTerm);
|
||||||
freeExpression(binopTerm->leftArgument);
|
freeExpression(binopTerm->leftArgument);
|
||||||
|
@ -70,10 +71,9 @@ freeBinopTerm(binopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeFunctionCall(functionCall)
|
freeFunctionCall(functionCallTermType *functionCall)
|
||||||
functionCallTermType *functionCall;
|
|
||||||
{
|
{
|
||||||
void freeOperandList();
|
void freeOperandList(operandListType *operandList);
|
||||||
|
|
||||||
nullFree(functionCall);
|
nullFree(functionCall);
|
||||||
freeOperandList(functionCall->parameters);
|
freeOperandList(functionCall->parameters);
|
||||||
|
@ -81,34 +81,30 @@ freeFunctionCall(functionCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freePostopTerm(postopTerm)
|
freePostopTerm(postOpTermType *postopTerm)
|
||||||
postOpTermType *postopTerm;
|
|
||||||
{
|
{
|
||||||
nullFree(postopTerm);
|
nullFree(postopTerm);
|
||||||
free(postopTerm);
|
free(postopTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freePreopTerm(preopTerm)
|
freePreopTerm(preOpTermType *preopTerm)
|
||||||
preOpTermType *preopTerm;
|
|
||||||
{
|
{
|
||||||
nullFree(preopTerm);
|
nullFree(preopTerm);
|
||||||
free(preopTerm);
|
free(preopTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeString(string)
|
freeString(stringType *string)
|
||||||
stringType *string;
|
|
||||||
{
|
{
|
||||||
nullFree(string);
|
nullFree(string);
|
||||||
free(string);
|
free(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeUnopTerm(unopTerm)
|
freeUnopTerm(unopTermType *unopTerm)
|
||||||
unopTermType *unopTerm;
|
|
||||||
{
|
{
|
||||||
void freeExpression();
|
void freeExpression(expressionType *expression);
|
||||||
|
|
||||||
nullFree(unopTerm);
|
nullFree(unopTerm);
|
||||||
freeExpression(unopTerm->unopArgument);
|
freeExpression(unopTerm->unopArgument);
|
||||||
|
@ -116,8 +112,7 @@ freeUnopTerm(unopTerm)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeExpression(expression)
|
freeExpression(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
nullFree(expression);
|
nullFree(expression);
|
||||||
switch (expression->kindOfTerm) {
|
switch (expression->kindOfTerm) {
|
||||||
|
@ -171,8 +166,7 @@ freeExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeExpressionList(expressionList)
|
freeExpressionList(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
expressionListType *newExpressionList;
|
expressionListType *newExpressionList;
|
||||||
|
|
||||||
|
@ -185,8 +179,7 @@ freeExpressionList(expressionList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeIdentifierList(identifierList)
|
freeIdentifierList(identifierListType *identifierList)
|
||||||
identifierListType *identifierList;
|
|
||||||
{
|
{
|
||||||
identifierListType *newIdentifierList;
|
identifierListType *newIdentifierList;
|
||||||
|
|
||||||
|
@ -198,25 +191,22 @@ freeIdentifierList(identifierList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeSelectionList(selectionList)
|
freeSelectionList(selectionListType *selectionList)
|
||||||
selectionListType *selectionList;
|
|
||||||
{
|
{
|
||||||
freeIdentifierList(selectionList);
|
freeIdentifierList(selectionList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeBlock(block)
|
freeBlock(blockType *block)
|
||||||
blockType *block;
|
|
||||||
{
|
{
|
||||||
void freeStatement();
|
void freeStatement(statementType *statement);
|
||||||
|
|
||||||
nullFree(block);
|
nullFree(block);
|
||||||
freeStatement(block);
|
freeStatement(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeCase(aCase)
|
freeCase(caseType *aCase)
|
||||||
caseType *aCase;
|
|
||||||
{
|
{
|
||||||
freeExpressionList(aCase->caseTags);
|
freeExpressionList(aCase->caseTags);
|
||||||
freeBlock(aCase->caseBody);
|
freeBlock(aCase->caseBody);
|
||||||
|
@ -224,8 +214,7 @@ freeCase(aCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeCaseList(caseList)
|
freeCaseList(caseListType *caseList)
|
||||||
caseListType *caseList;
|
|
||||||
{
|
{
|
||||||
caseListType *newCaseList;
|
caseListType *newCaseList;
|
||||||
|
|
||||||
|
@ -238,37 +227,32 @@ freeCaseList(caseList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeOperandList(operandList)
|
freeOperandList(operandListType *operandList)
|
||||||
operandListType *operandList;
|
|
||||||
{
|
{
|
||||||
freeOperand(operandList);
|
freeOperand(operandList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMacro(operands)
|
freeMacro(operandListType *operands)
|
||||||
operandListType *operands;
|
|
||||||
{
|
{
|
||||||
freeOperandList(operands);
|
freeOperandList(operands);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMachineInstruction(operands)
|
freeMachineInstruction(operandListType *operands)
|
||||||
operandListType *operands;
|
|
||||||
{
|
{
|
||||||
freeOperandList(operands);
|
freeOperandList(operands);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeAlignStatement(alignStatement)
|
freeAlignStatement(alignStatementBodyType *alignStatement)
|
||||||
alignStatementBodyType *alignStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(alignStatement);
|
nullFree(alignStatement);
|
||||||
freeExpression(alignStatement);
|
freeExpression(alignStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeAssertStatement(assertStatement)
|
freeAssertStatement(assertStatementBodyType *assertStatement)
|
||||||
assertStatementBodyType *assertStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(assertStatement);
|
nullFree(assertStatement);
|
||||||
freeExpression(assertStatement->condition);
|
freeExpression(assertStatement->condition);
|
||||||
|
@ -277,16 +261,14 @@ freeAssertStatement(assertStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeBlockStatement(blockStatement)
|
freeBlockStatement(blockStatementBodyType *blockStatement)
|
||||||
blockStatementBodyType *blockStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(blockStatement);
|
nullFree(blockStatement);
|
||||||
freeExpressionList(blockStatement);
|
freeExpressionList(blockStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeByteStatement(byteStatement)
|
freeByteStatement(byteStatementBodyType *byteStatement)
|
||||||
byteStatementBodyType *byteStatement;
|
|
||||||
{
|
{
|
||||||
byteStatementBodyType *newByteStatement;
|
byteStatementBodyType *newByteStatement;
|
||||||
|
|
||||||
|
@ -300,8 +282,7 @@ freeByteStatement(byteStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeConstrainStatement(constrainStatement)
|
freeConstrainStatement(constrainStatementBodyType *constrainStatement)
|
||||||
constrainStatementBodyType *constrainStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(constrainStatement);
|
nullFree(constrainStatement);
|
||||||
freeExpression(constrainStatement->constraint);
|
freeExpression(constrainStatement->constraint);
|
||||||
|
@ -310,8 +291,7 @@ freeConstrainStatement(constrainStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeDbyteStatement(dbyteStatement)
|
freeDbyteStatement(dbyteStatementBodyType *dbyteStatement)
|
||||||
dbyteStatementBodyType *dbyteStatement;
|
|
||||||
{
|
{
|
||||||
dbyteStatementBodyType *newDbyteStatement;
|
dbyteStatementBodyType *newDbyteStatement;
|
||||||
|
|
||||||
|
@ -325,8 +305,7 @@ freeDbyteStatement(dbyteStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeDefineStatement(defineStatement)
|
freeDefineStatement(defineStatementBodyType *defineStatement)
|
||||||
defineStatementBodyType *defineStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(defineStatement);
|
nullFree(defineStatement);
|
||||||
freeExpression(defineStatement->theValue);
|
freeExpression(defineStatement->theValue);
|
||||||
|
@ -334,8 +313,7 @@ freeDefineStatement(defineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeDoUntilStatement(doUntilStatement)
|
freeDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
|
||||||
doUntilStatementBodyType *doUntilStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(doUntilStatement);
|
nullFree(doUntilStatement);
|
||||||
freeBlock(doUntilStatement->doUntilLoop);
|
freeBlock(doUntilStatement->doUntilLoop);
|
||||||
|
@ -343,8 +321,7 @@ freeDoUntilStatement(doUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeDoWhileStatement(doWhileStatement)
|
freeDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
|
||||||
doWhileStatementBodyType *doWhileStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(doWhileStatement);
|
nullFree(doWhileStatement);
|
||||||
freeBlock(doWhileStatement->doWhileLoop);
|
freeBlock(doWhileStatement->doWhileLoop);
|
||||||
|
@ -352,23 +329,20 @@ freeDoWhileStatement(doWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeExternStatement(externStatement)
|
freeExternStatement(externStatementBodyType *externStatement)
|
||||||
externStatementBodyType *externStatement;
|
|
||||||
{
|
{
|
||||||
freeIdentifierList(externStatement);
|
freeIdentifierList(externStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeFreturnStatement(freturnStatement)
|
freeFreturnStatement(freturnStatementBodyType *freturnStatement)
|
||||||
freturnStatementBodyType *freturnStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(freturnStatement);
|
nullFree(freturnStatement);
|
||||||
freeExpression(freturnStatement);
|
freeExpression(freturnStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeFunctionStatement(functionStatement)
|
freeFunctionStatement(functionStatementBodyType *functionStatement)
|
||||||
functionStatementBodyType *functionStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(functionStatement);
|
nullFree(functionStatement);
|
||||||
free(functionStatement->functionName);
|
free(functionStatement->functionName);
|
||||||
|
@ -376,8 +350,7 @@ freeFunctionStatement(functionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeIfStatement(ifStatement)
|
freeIfStatement(ifStatementBodyType *ifStatement)
|
||||||
ifStatementBodyType *ifStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(ifStatement);
|
nullFree(ifStatement);
|
||||||
if (ifStatement->consequence != NULL)
|
if (ifStatement->consequence != NULL)
|
||||||
|
@ -389,16 +362,14 @@ freeIfStatement(ifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeIncludeStatement(includeStatement)
|
freeIncludeStatement(includeStatementBodyType *includeStatement)
|
||||||
includeStatementBodyType *includeStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(includeStatement);
|
nullFree(includeStatement);
|
||||||
freeExpression(includeStatement);
|
freeExpression(includeStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeInstructionStatement(instructionStatement)
|
freeInstructionStatement(instructionStatementBodyType *instructionStatement)
|
||||||
instructionStatementBodyType *instructionStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(instructionStatement);
|
nullFree(instructionStatement);
|
||||||
switch(instructionStatement->kindOfInstruction) {
|
switch(instructionStatement->kindOfInstruction) {
|
||||||
|
@ -419,8 +390,7 @@ freeInstructionStatement(instructionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeLongStatement(longStatement)
|
freeLongStatement(longStatementBodyType *longStatement)
|
||||||
longStatementBodyType *longStatement;
|
|
||||||
{
|
{
|
||||||
longStatementBodyType *newLongStatement;
|
longStatementBodyType *newLongStatement;
|
||||||
|
|
||||||
|
@ -434,16 +404,15 @@ freeLongStatement(longStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMacroStatement(macroStatement)
|
freeMacroStatement(macroStatementBodyType *macroStatement)
|
||||||
macroStatementBodyType *macroStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(macroStatement);
|
nullFree(macroStatement);
|
||||||
free(macroStatement);
|
free(macroStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMdefineStatement(mdefineStatement)
|
freeMdefineStatement(defineStatementBodyType *mdefineStatement)
|
||||||
defineStatementBodyType *mdefineStatement; /* MIST: shouldn't this be "mdefineStatementBodyType"? */
|
/* MIST: shouldn't this be "mdefineStatementBodyType"? */
|
||||||
{
|
{
|
||||||
valueType *freeDefineExpression();
|
valueType *freeDefineExpression();
|
||||||
|
|
||||||
|
@ -453,8 +422,7 @@ freeMdefineStatement(mdefineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMdoUntilStatement(mdoUntilStatement)
|
freeMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
|
||||||
mdoUntilStatementBodyType *mdoUntilStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(mdoUntilStatement);
|
nullFree(mdoUntilStatement);
|
||||||
freeBlock(mdoUntilStatement->mdoUntilLoop);
|
freeBlock(mdoUntilStatement->mdoUntilLoop);
|
||||||
|
@ -462,8 +430,7 @@ freeMdoUntilStatement(mdoUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMdoWhileStatement(mdoWhileStatement)
|
freeMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
|
||||||
mdoWhileStatementBodyType *mdoWhileStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(mdoWhileStatement);
|
nullFree(mdoWhileStatement);
|
||||||
freeBlock(mdoWhileStatement->mdoWhileLoop);
|
freeBlock(mdoWhileStatement->mdoWhileLoop);
|
||||||
|
@ -472,8 +439,7 @@ freeMdoWhileStatement(mdoWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMifStatement(mifStatement)
|
freeMifStatement(mifStatementBodyType *mifStatement)
|
||||||
mifStatementBodyType *mifStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(mifStatement);
|
nullFree(mifStatement);
|
||||||
freeExpression(mifStatement->mifCondition);
|
freeExpression(mifStatement->mifCondition);
|
||||||
|
@ -484,8 +450,7 @@ freeMifStatement(mifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMswitchStatement(mswitchStatement)
|
freeMswitchStatement(mswitchStatementBodyType *mswitchStatement)
|
||||||
mswitchStatementBodyType *mswitchStatement;
|
|
||||||
{
|
{
|
||||||
freeExpression(mswitchStatement->switchExpression);
|
freeExpression(mswitchStatement->switchExpression);
|
||||||
freeCaseList(mswitchStatement->cases);
|
freeCaseList(mswitchStatement->cases);
|
||||||
|
@ -493,8 +458,7 @@ freeMswitchStatement(mswitchStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMforStatement(mforStatement)
|
freeMforStatement(mforStatementBodyType *mforStatement)
|
||||||
mforStatementBodyType *mforStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(mforStatement);
|
nullFree(mforStatement);
|
||||||
freeExpression(mforStatement->initExpression);
|
freeExpression(mforStatement->initExpression);
|
||||||
|
@ -505,8 +469,7 @@ freeMforStatement(mforStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMvariableStatement(mvariableStatement)
|
freeMvariableStatement(mvariableStatementBodyType *mvariableStatement)
|
||||||
mvariableStatementBodyType *mvariableStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(mvariableStatement);
|
nullFree(mvariableStatement);
|
||||||
if ((int)mvariableStatement->theDimension != -1)
|
if ((int)mvariableStatement->theDimension != -1)
|
||||||
|
@ -516,8 +479,7 @@ freeMvariableStatement(mvariableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeMwhileStatement(mwhileStatement)
|
freeMwhileStatement(mwhileStatementBodyType *mwhileStatement)
|
||||||
mwhileStatementBodyType *mwhileStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(mwhileStatement);
|
nullFree(mwhileStatement);
|
||||||
freeExpression(mwhileStatement->mwhileCondition);
|
freeExpression(mwhileStatement->mwhileCondition);
|
||||||
|
@ -526,38 +488,33 @@ freeMwhileStatement(mwhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeOrgStatement(orgStatement)
|
freeOrgStatement(orgStatementBodyType *orgStatement)
|
||||||
orgStatementBodyType *orgStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(orgStatement);
|
nullFree(orgStatement);
|
||||||
freeExpression(orgStatement);
|
freeExpression(orgStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freePerformStatement(performStatement)
|
freePerformStatement(performStatementBodyType *performStatement)
|
||||||
performStatementBodyType *performStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(performStatement);
|
nullFree(performStatement);
|
||||||
freeExpression(performStatement);
|
freeExpression(performStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeRelStatement(relStatement)
|
freeRelStatement(relStatementBodyType *relStatement)
|
||||||
relStatementBodyType *relStatement;
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeStartStatement(startStatement)
|
freeStartStatement(startStatementBodyType *startStatement)
|
||||||
startStatementBodyType *startStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(startStatement);
|
nullFree(startStatement);
|
||||||
freeExpression(startStatement);
|
freeExpression(startStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeStringStatement(stringStatement)
|
freeStringStatement(stringStatementBodyType *stringStatement)
|
||||||
stringStatementBodyType *stringStatement;
|
|
||||||
{
|
{
|
||||||
stringStatementBodyType *newStringStatement;
|
stringStatementBodyType *newStringStatement;
|
||||||
|
|
||||||
|
@ -571,8 +528,7 @@ freeStringStatement(stringStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeStructStatement(structStatement)
|
freeStructStatement(structStatementBodyType *structStatement)
|
||||||
structStatementBodyType *structStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(structStatement);
|
nullFree(structStatement);
|
||||||
freeBlock(structStatement->structBody);
|
freeBlock(structStatement->structBody);
|
||||||
|
@ -580,23 +536,20 @@ freeStructStatement(structStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeTargetStatement(targetStatement)
|
freeTargetStatement(targetStatementBodyType *targetStatement)
|
||||||
targetStatementBodyType *targetStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(targetStatement);
|
nullFree(targetStatement);
|
||||||
freeExpression(targetStatement);
|
freeExpression(targetStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeUndefineStatement(undefineStatement)
|
freeUndefineStatement(undefineStatementBodyType *undefineStatement)
|
||||||
undefineStatementBodyType *undefineStatement;
|
|
||||||
{
|
{
|
||||||
freeIdentifierList(undefineStatement);
|
freeIdentifierList(undefineStatement);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeVariableStatement(variableStatement)
|
freeVariableStatement(variableStatementBodyType *variableStatement)
|
||||||
variableStatementBodyType *variableStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(variableStatement);
|
nullFree(variableStatement);
|
||||||
if ((int)variableStatement->theDimension != -1)
|
if ((int)variableStatement->theDimension != -1)
|
||||||
|
@ -606,8 +559,7 @@ freeVariableStatement(variableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeWhileStatement(whileStatement)
|
freeWhileStatement(whileStatementBodyType *whileStatement)
|
||||||
whileStatementBodyType *whileStatement;
|
|
||||||
{
|
{
|
||||||
nullFree(whileStatement);
|
nullFree(whileStatement);
|
||||||
freeBlock(whileStatement->whileLoop);
|
freeBlock(whileStatement->whileLoop);
|
||||||
|
@ -615,8 +567,7 @@ freeWhileStatement(whileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeWordStatement(wordStatement)
|
freeWordStatement(wordStatementBodyType *wordStatement)
|
||||||
wordStatementBodyType *wordStatement;
|
|
||||||
{
|
{
|
||||||
wordStatementBodyType *newWordStatement;
|
wordStatementBodyType *newWordStatement;
|
||||||
|
|
||||||
|
@ -630,9 +581,7 @@ freeWordStatement(wordStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeStatementBody(kind, body)
|
freeStatementBody(statementKindType kind, statementBodyType body)
|
||||||
statementKindType kind;
|
|
||||||
statementBodyType body;
|
|
||||||
{
|
{
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
|
||||||
|
@ -795,8 +744,7 @@ freeStatementBody(kind, body)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeLabelList(labelList)
|
freeLabelList(labelListType *labelList)
|
||||||
labelListType *labelList;
|
|
||||||
{
|
{
|
||||||
labelListType *nextLabel;
|
labelListType *nextLabel;
|
||||||
|
|
||||||
|
@ -808,8 +756,7 @@ freeLabelList(labelList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeStatement(statement)
|
freeStatement(statementType *statement)
|
||||||
statementType *statement;
|
|
||||||
{
|
{
|
||||||
statementType *newStatement;
|
statementType *newStatement;
|
||||||
|
|
||||||
|
@ -824,11 +771,10 @@ freeStatement(statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeArray(array)
|
freeArray(arrayType *array)
|
||||||
arrayType *array;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
void freeValue();
|
void freeValue(valueType *value);
|
||||||
|
|
||||||
if (array->arraySize > 0) {
|
if (array->arraySize > 0) {
|
||||||
for (i=0; i<array->arraySize; i++)
|
for (i=0; i<array->arraySize; i++)
|
||||||
|
@ -839,8 +785,7 @@ freeArray(array)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
freeValue(value)
|
freeValue(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
if (value->kindOfValue == STRING_VALUE)
|
if (value->kindOfValue == STRING_VALUE)
|
||||||
freeString(value->value);
|
freeString(value->value);
|
||||||
|
|
72
initialize.c
72
initialize.c
|
@ -39,17 +39,27 @@ extern int yydebug;
|
||||||
static fileNameListType *bottomOfInputFileStack;
|
static fileNameListType *bottomOfInputFileStack;
|
||||||
static char *outputFileName;
|
static char *outputFileName;
|
||||||
|
|
||||||
void
|
|
||||||
chokePukeAndDie()
|
extern int unlink (const char *);
|
||||||
|
bool isDotMName (stringType *fileName);
|
||||||
|
extern void fatalError (errorType theError, ...);
|
||||||
|
extern void printVersion (void);
|
||||||
|
extern void warning (errorType theError, ...);
|
||||||
|
extern void fatalSystemError (errorType theError, ...);
|
||||||
|
extern void initializeLexDispatchTable (void);
|
||||||
|
extern genericTableEntryType *hashStringEnter (genericTableEntryType *entry, genericTableEntryType **table);
|
||||||
|
extern int fancyAtoI (char *buffer, int base);
|
||||||
|
extern void error (errorType theError, ...);
|
||||||
|
|
||||||
|
void
|
||||||
|
chokePukeAndDie(void)
|
||||||
{
|
{
|
||||||
unlink(outputFileName);
|
unlink(outputFileName);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initializeStuff(argc, argv)
|
initializeStuff(int argc, char **argv)
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
|
@ -62,13 +72,13 @@ initializeStuff(argc, argv)
|
||||||
char *symbolDumpFileName;
|
char *symbolDumpFileName;
|
||||||
bool dontUnlinkTempFiles;
|
bool dontUnlinkTempFiles;
|
||||||
|
|
||||||
void createHashTables();
|
void createHashTables(void);
|
||||||
void installBuiltInFunctions();
|
void installBuiltInFunctions(void);
|
||||||
void installPredefinedSymbols();
|
void installPredefinedSymbols(void);
|
||||||
void installCommandLineDefineSymbols();
|
void installCommandLineDefineSymbols(void);
|
||||||
void openFirstInputFile();
|
void openFirstInputFile(void);
|
||||||
void queueInputFile();
|
void queueInputFile(char *name);
|
||||||
void noteCommandLineDefine();
|
void noteCommandLineDefine(char *arg);
|
||||||
|
|
||||||
for (i=0; i<128; i++) {
|
for (i=0; i<128; i++) {
|
||||||
lowerCaseCharacterTable[i] = i;
|
lowerCaseCharacterTable[i] = i;
|
||||||
|
@ -381,13 +391,13 @@ initializeStuff(argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
installBuiltInFunctions()
|
installBuiltInFunctions(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *newFunction;
|
symbolTableEntryType *newFunction;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
for (i=0; builtInFunctionTable[i].functionName!=NULL; i++) {
|
for (i=0; builtInFunctionTable[i].functionName!=NULL; i++) {
|
||||||
newFunction = lookupOrEnterSymbol(builtInFunctionTable[i].
|
newFunction = lookupOrEnterSymbol(builtInFunctionTable[i].
|
||||||
|
@ -401,13 +411,13 @@ installBuiltInFunctions()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
installPredefinedSymbols()
|
installPredefinedSymbols(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *newSymbol;
|
symbolTableEntryType *newSymbol;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
for (i=0; predefinedSymbolTable[i].symbolName!=NULL; i++) {
|
for (i=0; predefinedSymbolTable[i].symbolName!=NULL; i++) {
|
||||||
newSymbol = lookupOrEnterSymbol(predefinedSymbolTable[i].
|
newSymbol = lookupOrEnterSymbol(predefinedSymbolTable[i].
|
||||||
|
@ -420,13 +430,13 @@ installPredefinedSymbols()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
installCommandLineDefineSymbols()
|
installCommandLineDefineSymbols(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *newSymbol;
|
symbolTableEntryType *newSymbol;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
while (commandLineDefines != NULL) {
|
while (commandLineDefines != NULL) {
|
||||||
newSymbol = lookupOrEnterSymbol(commandLineDefines->name,
|
newSymbol = lookupOrEnterSymbol(commandLineDefines->name,
|
||||||
|
@ -439,7 +449,7 @@ installCommandLineDefineSymbols()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
createHashTables()
|
createHashTables(void)
|
||||||
{
|
{
|
||||||
opcodeTableEntryType *newOpcodeEntry;
|
opcodeTableEntryType *newOpcodeEntry;
|
||||||
keywordTableEntryType *newKeywordEntry;
|
keywordTableEntryType *newKeywordEntry;
|
||||||
|
@ -459,8 +469,7 @@ createHashTables()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
queueInputFile(name)
|
queueInputFile(char *name)
|
||||||
char *name;
|
|
||||||
{
|
{
|
||||||
fileNameListType *newFileName;
|
fileNameListType *newFileName;
|
||||||
|
|
||||||
|
@ -479,7 +488,7 @@ queueInputFile(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
openFirstInputFile()
|
openFirstInputFile(void)
|
||||||
{
|
{
|
||||||
if (inputFileStack == NULL) {
|
if (inputFileStack == NULL) {
|
||||||
inputFileStack = typeAlloc(fileNameListType);
|
inputFileStack = typeAlloc(fileNameListType);
|
||||||
|
@ -504,8 +513,7 @@ openFirstInputFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isDotMName(fileName)
|
isDotMName(stringType *fileName)
|
||||||
stringType *fileName;
|
|
||||||
{
|
{
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
|
@ -515,10 +523,7 @@ isDotMName(fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
parseCommandLineDefine(arg, name, value)
|
parseCommandLineDefine(char *arg, char **name, int *value)
|
||||||
char *arg;
|
|
||||||
char **name;
|
|
||||||
int *value;
|
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
char c;
|
char c;
|
||||||
|
@ -561,14 +566,13 @@ parseCommandLineDefine(arg, name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
noteCommandLineDefine(arg)
|
noteCommandLineDefine(char *arg)
|
||||||
char *arg;
|
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
int value;
|
int value;
|
||||||
commandLineDefineType *newCommandLineDefine;
|
commandLineDefineType *newCommandLineDefine;
|
||||||
|
|
||||||
bool parseCommandLineDefine();
|
bool parseCommandLineDefine(char *arg, char **name, int *value);
|
||||||
|
|
||||||
if (parseCommandLineDefine(arg, &name, &value)) {
|
if (parseCommandLineDefine(arg, &name, &value)) {
|
||||||
newCommandLineDefine = typeAlloc(commandLineDefineType);
|
newCommandLineDefine = typeAlloc(commandLineDefineType);
|
||||||
|
|
112
lexer.c
112
lexer.c
|
@ -52,8 +52,26 @@ static int lineBufferPtr = 0;
|
||||||
#define isNumeric(c) (numericCharacterTable[c])
|
#define isNumeric(c) (numericCharacterTable[c])
|
||||||
#define isAlphaNumeric(c) (alphaNumericCharacterTable[c])
|
#define isAlphaNumeric(c) (alphaNumericCharacterTable[c])
|
||||||
|
|
||||||
int
|
|
||||||
yylex()
|
int lexer (void);
|
||||||
|
extern void printToken (int token);
|
||||||
|
int lexLiteral (char c);
|
||||||
|
bool isMacrossLiteralCharacter (char c);
|
||||||
|
int readAnotherLine (void);
|
||||||
|
extern int hashString (char *s);
|
||||||
|
extern opcodeTableEntryType *lookupOpcode (char *s, int hashValue);
|
||||||
|
extern int lookupKeyword (char *s, int hashValue);
|
||||||
|
extern conditionType lookupConditionCode (char *s, int hashValue);
|
||||||
|
extern macroTableEntryType *lookupMacroName (char *s, int hashValue);
|
||||||
|
int fancyAtoI (char *buffer, int base);
|
||||||
|
int digitValue (char c);
|
||||||
|
extern void error (errorType theError, ...);
|
||||||
|
int getStringCharacter (FILE *input);
|
||||||
|
extern void fatalSystemError (errorType theError, ...);
|
||||||
|
extern bool notListable (statementKindType statementKind);
|
||||||
|
|
||||||
|
int
|
||||||
|
yylex(void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -67,11 +85,11 @@ yylex()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lexer()
|
lexer(void)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
char skipWhitespaceAndComments();
|
char skipWhitespaceAndComments(void);
|
||||||
|
|
||||||
if ((c = skipWhitespaceAndComments()) == EOF)
|
if ((c = skipWhitespaceAndComments()) == EOF)
|
||||||
return(lexLiteral(c));
|
return(lexLiteral(c));
|
||||||
|
@ -80,15 +98,15 @@ lexer()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
initializeLexDispatchTable()
|
initializeLexDispatchTable(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int lexIdentifier();
|
int lexIdentifier(char c);
|
||||||
int lexNumber();
|
int lexNumber(char c);
|
||||||
int lexLiteral();
|
int lexLiteral(char c);
|
||||||
int lexCharacterConstant();
|
int lexCharacterConstant(void);
|
||||||
int lexStringConstant();
|
int lexStringConstant(void);
|
||||||
int lexOperator();
|
int lexOperator(char firstC);
|
||||||
|
|
||||||
for (c = 0; c < LEX_DISPATCH_TABLE_SIZE; c++) {
|
for (c = 0; c < LEX_DISPATCH_TABLE_SIZE; c++) {
|
||||||
if (isAlphabetic(c) || c=='$')
|
if (isAlphabetic(c) || c=='$')
|
||||||
|
@ -107,8 +125,7 @@ initializeLexDispatchTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isMacrossLiteralCharacter(c)
|
isMacrossLiteralCharacter(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
return(c==':' || c==',' || c=='@' || c=='#' ||
|
return(c==':' || c==',' || c=='@' || c=='#' ||
|
||||||
c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' ||
|
c=='(' || c==')' || c=='{' || c=='}' || c=='[' || c==']' ||
|
||||||
|
@ -116,9 +133,7 @@ isMacrossLiteralCharacter(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
snarfAlphanumericString(c, buffer)
|
snarfAlphanumericString(char c, char *buffer)
|
||||||
char c;
|
|
||||||
char *buffer;
|
|
||||||
{
|
{
|
||||||
char *bufferPtr;
|
char *bufferPtr;
|
||||||
|
|
||||||
|
@ -135,10 +150,9 @@ snarfAlphanumericString(c, buffer)
|
||||||
char nameBuffer[MAX_NAME_SIZE+1];
|
char nameBuffer[MAX_NAME_SIZE+1];
|
||||||
|
|
||||||
int
|
int
|
||||||
lexIdentifier(c)
|
lexIdentifier(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
char *saveString();
|
char *saveString(char *s);
|
||||||
int hashValue;
|
int hashValue;
|
||||||
|
|
||||||
snarfAlphanumericString(c, nameBuffer);
|
snarfAlphanumericString(c, nameBuffer);
|
||||||
|
@ -161,8 +175,7 @@ lexIdentifier(c)
|
||||||
char numberBuffer[MAX_NAME_SIZE+1];
|
char numberBuffer[MAX_NAME_SIZE+1];
|
||||||
|
|
||||||
int
|
int
|
||||||
lexNumber(c)
|
lexNumber(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
int base;
|
int base;
|
||||||
int start;
|
int start;
|
||||||
|
@ -189,9 +202,7 @@ lexNumber(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fancyAtoI(buffer, base)
|
fancyAtoI(char *buffer, int base)
|
||||||
char *buffer;
|
|
||||||
int base;
|
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
int digit;
|
int digit;
|
||||||
|
@ -209,8 +220,7 @@ fancyAtoI(buffer, base)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
digitValue(c)
|
digitValue(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
if (isNumeric(c))
|
if (isNumeric(c))
|
||||||
return(c - '0');
|
return(c - '0');
|
||||||
|
@ -219,8 +229,7 @@ digitValue(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lexLiteral(c)
|
lexLiteral(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
static bool passedEnd = FALSE;
|
static bool passedEnd = FALSE;
|
||||||
|
|
||||||
|
@ -240,7 +249,7 @@ lexLiteral(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lexCharacterConstant()
|
lexCharacterConstant(void)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
@ -256,13 +265,12 @@ lexCharacterConstant()
|
||||||
bool escaped; /* true if last string character read was an escape
|
bool escaped; /* true if last string character read was an escape
|
||||||
code. */
|
code. */
|
||||||
int
|
int
|
||||||
getStringCharacter(input)
|
getStringCharacter(FILE *input)
|
||||||
FILE *input;
|
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
char *numberPtr;
|
char *numberPtr;
|
||||||
int result;
|
int result;
|
||||||
char controlCharacter();
|
char controlCharacter(char c);
|
||||||
|
|
||||||
escaped = FALSE;
|
escaped = FALSE;
|
||||||
c = getNextChar();
|
c = getNextChar();
|
||||||
|
@ -292,7 +300,7 @@ getStringCharacter(input)
|
||||||
char stringBuffer[MAX_NAME_SIZE + 1];
|
char stringBuffer[MAX_NAME_SIZE + 1];
|
||||||
|
|
||||||
int
|
int
|
||||||
lexStringConstant()
|
lexStringConstant(void)
|
||||||
{
|
{
|
||||||
char *stringPtr;
|
char *stringPtr;
|
||||||
char c;
|
char c;
|
||||||
|
@ -309,8 +317,7 @@ lexStringConstant()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lexOperator(firstC)
|
lexOperator(char firstC)
|
||||||
char firstC;
|
|
||||||
{
|
{
|
||||||
char secondC;
|
char secondC;
|
||||||
char thirdC;
|
char thirdC;
|
||||||
|
@ -347,8 +354,7 @@ lexOperator(firstC)
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
char
|
||||||
controlCharacter(c)
|
controlCharacter(char c)
|
||||||
char c;
|
|
||||||
{
|
{
|
||||||
#define CONTROL_CHARACTER_MASK (~0100)
|
#define CONTROL_CHARACTER_MASK (~0100)
|
||||||
|
|
||||||
|
@ -356,7 +362,7 @@ controlCharacter(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
char
|
||||||
skipWhitespaceAndComments()
|
skipWhitespaceAndComments(void)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
@ -394,7 +400,7 @@ skipWhitespaceAndComments()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
popInputFileStack()
|
popInputFileStack(void)
|
||||||
{
|
{
|
||||||
fileNameListType *oldFile;
|
fileNameListType *oldFile;
|
||||||
|
|
||||||
|
@ -425,8 +431,7 @@ popInputFileStack()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pushInputFileStack(fileName)
|
pushInputFileStack(stringType *fileName)
|
||||||
stringType *fileName;
|
|
||||||
{
|
{
|
||||||
fileNameListType *newFileName;
|
fileNameListType *newFileName;
|
||||||
|
|
||||||
|
@ -446,7 +451,7 @@ pushInputFileStack(fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
resynchronizeInput()
|
resynchronizeInput(void)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
while ((c = getNextChar())!='\n' && c!=EOF)
|
while ((c = getNextChar())!='\n' && c!=EOF)
|
||||||
|
@ -458,8 +463,7 @@ resynchronizeInput()
|
||||||
static bool previousLongLineFlag = FALSE;
|
static bool previousLongLineFlag = FALSE;
|
||||||
|
|
||||||
void
|
void
|
||||||
saveLineForListing(line)
|
saveLineForListing(stringType *line)
|
||||||
stringType *line;
|
|
||||||
{
|
{
|
||||||
if (!previousLongLineFlag) {
|
if (!previousLongLineFlag) {
|
||||||
putw(currentLocationCounter.value, saveFileForPass2);
|
putw(currentLocationCounter.value, saveFileForPass2);
|
||||||
|
@ -470,7 +474,7 @@ saveLineForListing(line)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
saveEOLForListing()
|
saveEOLForListing(void)
|
||||||
{
|
{
|
||||||
putw(-1, saveFileForPass2);
|
putw(-1, saveFileForPass2);
|
||||||
putw(includeNestingDepth, saveFileForPass2);
|
putw(includeNestingDepth, saveFileForPass2);
|
||||||
|
@ -478,9 +482,7 @@ saveEOLForListing()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
saveIndexForListing(kindOfStatement, cumulativeLineNumber)
|
saveIndexForListing(statementKindType kindOfStatement, int cumulativeLineNumber)
|
||||||
statementKindType kindOfStatement;
|
|
||||||
int cumulativeLineNumber;
|
|
||||||
{
|
{
|
||||||
if (!amExpanding() || !notListable(kindOfStatement)) {
|
if (!amExpanding() || !notListable(kindOfStatement)) {
|
||||||
putw(kindOfStatement, indexFileForPass2);
|
putw(kindOfStatement, indexFileForPass2);
|
||||||
|
@ -493,8 +495,7 @@ saveIndexForListing(kindOfStatement, cumulativeLineNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
saveEndMifForListing(cumulativeLineNumber)
|
saveEndMifForListing(int cumulativeLineNumber)
|
||||||
int cumulativeLineNumber;
|
|
||||||
{
|
{
|
||||||
putw(MIF_STATEMENT, indexFileForPass2);
|
putw(MIF_STATEMENT, indexFileForPass2);
|
||||||
putw(-1, indexFileForPass2);
|
putw(-1, indexFileForPass2);
|
||||||
|
@ -505,13 +506,13 @@ saveEndMifForListing(cumulativeLineNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
saveListingOff()
|
saveListingOff(void)
|
||||||
{
|
{
|
||||||
saveIndexForListing(-1, cumulativeLineNumber);
|
saveIndexForListing(-1, cumulativeLineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
saveListingOn()
|
saveListingOn(void)
|
||||||
{
|
{
|
||||||
if (currentCodeMode == ABSOLUTE_BUFFER)
|
if (currentCodeMode == ABSOLUTE_BUFFER)
|
||||||
saveIndexForListing(-1, cumulativeLineNumber);
|
saveIndexForListing(-1, cumulativeLineNumber);
|
||||||
|
@ -520,10 +521,7 @@ saveListingOn()
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
myfgets(buffer, length, stream)
|
myfgets(char *buffer, int length, FILE *stream)
|
||||||
char *buffer;
|
|
||||||
int length;
|
|
||||||
FILE *stream;
|
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
char c;
|
char c;
|
||||||
|
@ -546,7 +544,7 @@ myfgets(buffer, length, stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
readAnotherLine()
|
readAnotherLine(void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
|
87
listing.c
87
listing.c
|
@ -44,8 +44,16 @@ static int nextMacroAddress;
|
||||||
static int macroDepth;
|
static int macroDepth;
|
||||||
static int nextMacroDepth;
|
static int nextMacroDepth;
|
||||||
|
|
||||||
void
|
|
||||||
outputListing()
|
extern void saveLineForListing (stringType *line);
|
||||||
|
extern void saveIndexForListing (statementKindType kindOfStatement, int cumulativeLineNumber);
|
||||||
|
extern char *myfgets (char *buffer, int length, FILE *stream);
|
||||||
|
bool isBlankStatement (statementKindType statementKind);
|
||||||
|
extern byte getByte (addressType address);
|
||||||
|
extern bool listableStatement (statementKindType kind);
|
||||||
|
|
||||||
|
void
|
||||||
|
outputListing(void)
|
||||||
{
|
{
|
||||||
rewind(saveFileForPass2);
|
rewind(saveFileForPass2);
|
||||||
rewind(indexFileForPass2);
|
rewind(indexFileForPass2);
|
||||||
|
@ -54,7 +62,7 @@ outputListing()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
terminateListingFiles()
|
terminateListingFiles(void)
|
||||||
{
|
{
|
||||||
saveLineForListing("\n");
|
saveLineForListing("\n");
|
||||||
saveIndexForListing(NULL_STATEMENT, cumulativeLineNumber);
|
saveIndexForListing(NULL_STATEMENT, cumulativeLineNumber);
|
||||||
|
@ -96,7 +104,7 @@ terminateListingFiles()
|
||||||
/* This is the most horrible piece of code I have ever written in my entire
|
/* This is the most horrible piece of code I have ever written in my entire
|
||||||
life -- cbm */
|
life -- cbm */
|
||||||
void
|
void
|
||||||
generateListing()
|
generateListing(void)
|
||||||
{
|
{
|
||||||
int sourceAddress;
|
int sourceAddress;
|
||||||
int sourceDepth;
|
int sourceDepth;
|
||||||
|
@ -297,10 +305,7 @@ generateListing()
|
||||||
bool longLineFlag; /* defined in lexer.c */
|
bool longLineFlag; /* defined in lexer.c */
|
||||||
|
|
||||||
int
|
int
|
||||||
printMacroLine(numberOfBytes, byteAddress, kind)
|
printMacroLine(int numberOfBytes, int byteAddress, statementKindType kind)
|
||||||
int numberOfBytes;
|
|
||||||
int byteAddress;
|
|
||||||
statementKindType kind;
|
|
||||||
{
|
{
|
||||||
macroAddress = nextMacroAddress;
|
macroAddress = nextMacroAddress;
|
||||||
macroDepth = nextMacroDepth;
|
macroDepth = nextMacroDepth;
|
||||||
|
@ -312,11 +317,7 @@ printMacroLine(numberOfBytes, byteAddress, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
readSourceFileLine(sourceAddressPtr, sourceDepthPtr, lineBuffer, file)
|
readSourceFileLine(int *sourceAddressPtr, int *sourceDepthPtr, char *lineBuffer, FILE *file)
|
||||||
int *sourceAddressPtr;
|
|
||||||
int *sourceDepthPtr;
|
|
||||||
char lineBuffer[];
|
|
||||||
FILE *file;
|
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
|
@ -331,10 +332,7 @@ readSourceFileLine(sourceAddressPtr, sourceDepthPtr, lineBuffer, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
readIndexFileLine(statementKindPtr, indexAddressPtr, indexLineNumberPtr)
|
readIndexFileLine(statementKindType *statementKindPtr, int *indexAddressPtr, int *indexLineNumberPtr)
|
||||||
statementKindType *statementKindPtr;
|
|
||||||
int *indexAddressPtr;
|
|
||||||
int *indexLineNumberPtr;
|
|
||||||
{
|
{
|
||||||
statementKindType statementKindRead;
|
statementKindType statementKindRead;
|
||||||
int indexAddressRead;
|
int indexAddressRead;
|
||||||
|
@ -353,11 +351,7 @@ readIndexFileLine(statementKindPtr, indexAddressPtr, indexLineNumberPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
printListingLine(numberOfBytes, byteAddress, text, kind)
|
printListingLine(int numberOfBytes, int byteAddress, char *text, statementKindType kind)
|
||||||
int numberOfBytes;
|
|
||||||
int byteAddress;
|
|
||||||
char *text;
|
|
||||||
statementKindType kind;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -408,8 +402,7 @@ printListingLine(numberOfBytes, byteAddress, text, kind)
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isBlockOpener(statementKind)
|
isBlockOpener(statementKindType statementKind)
|
||||||
statementKindType statementKind;
|
|
||||||
{
|
{
|
||||||
return (statementKind==IF_STATEMENT ||
|
return (statementKind==IF_STATEMENT ||
|
||||||
statementKind==WHILE_STATEMENT ||
|
statementKind==WHILE_STATEMENT ||
|
||||||
|
@ -428,8 +421,7 @@ isBlockOpener(statementKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isBlankStatement(statementKind)
|
isBlankStatement(statementKindType statementKind)
|
||||||
statementKindType statementKind;
|
|
||||||
{
|
{
|
||||||
return( statementKind == DEFINE_STATEMENT ||
|
return( statementKind == DEFINE_STATEMENT ||
|
||||||
statementKind == NULL_STATEMENT ||
|
statementKind == NULL_STATEMENT ||
|
||||||
|
@ -455,8 +447,7 @@ isBlankStatement(statementKind)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tabPrint(text)
|
tabPrint(stringType *text)
|
||||||
stringType *text;
|
|
||||||
{
|
{
|
||||||
int column;
|
int column;
|
||||||
int spaces;
|
int spaces;
|
||||||
|
@ -477,16 +468,14 @@ tabPrint(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printNTimes(aChar, times)
|
printNTimes(char aChar, int times)
|
||||||
char aChar;
|
|
||||||
int times;
|
|
||||||
{
|
{
|
||||||
while (times-- > 0)
|
while (times-- > 0)
|
||||||
moreText("%c", aChar, 0, 0);
|
moreText("%c", aChar, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tabIndent()
|
tabIndent(void)
|
||||||
{
|
{
|
||||||
printNTimes('\t', tabCount);
|
printNTimes('\t', tabCount);
|
||||||
}
|
}
|
||||||
|
@ -499,7 +488,7 @@ static char labelString[LINE_BUFFER_SIZE] = { '\0' };
|
||||||
static char *labelStringPtr = labelString;
|
static char *labelStringPtr = labelString;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
labeledLine()
|
labeledLine(void)
|
||||||
{
|
{
|
||||||
return(labelStringPtr != labelString);
|
return(labelStringPtr != labelString);
|
||||||
}
|
}
|
||||||
|
@ -542,9 +531,7 @@ moreText(char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
moreLabel(format, arg1)
|
moreLabel(char *format, int arg1)
|
||||||
char *format;
|
|
||||||
int arg1;
|
|
||||||
{
|
{
|
||||||
sprintf(labelStringPtr, format, arg1);
|
sprintf(labelStringPtr, format, arg1);
|
||||||
labelStringPtr = labelString + strlen(labelString);
|
labelStringPtr = labelString + strlen(labelString);
|
||||||
|
@ -554,7 +541,7 @@ static addressType savedCurrentLocationCounterValue;
|
||||||
static int savedIncludeNestingDepth;
|
static int savedIncludeNestingDepth;
|
||||||
|
|
||||||
void
|
void
|
||||||
startLine()
|
startLine(void)
|
||||||
{
|
{
|
||||||
printNTimes('+', macroCallDepth);
|
printNTimes('+', macroCallDepth);
|
||||||
savedCurrentLocationCounterValue = currentLocationCounter.value;
|
savedCurrentLocationCounterValue = currentLocationCounter.value;
|
||||||
|
@ -562,7 +549,7 @@ startLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
endLine()
|
endLine(void)
|
||||||
{
|
{
|
||||||
if (amListing()) {
|
if (amListing()) {
|
||||||
putw(savedCurrentLocationCounterValue, macroFileForPass2);
|
putw(savedCurrentLocationCounterValue, macroFileForPass2);
|
||||||
|
@ -574,16 +561,14 @@ endLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
flushExpressionString()
|
flushExpressionString(void)
|
||||||
{
|
{
|
||||||
expressionStringPtr = expressionString;
|
expressionStringPtr = expressionString;
|
||||||
*expressionStringPtr = '\0';
|
*expressionStringPtr = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expandExpression(toBuffer, toBufferPtr)
|
expandExpression(char *toBuffer, char **toBufferPtr)
|
||||||
char *toBuffer;
|
|
||||||
char **toBufferPtr;
|
|
||||||
{
|
{
|
||||||
if (toBuffer == NULL)
|
if (toBuffer == NULL)
|
||||||
moreText("%s", expressionString, 0, 0);
|
moreText("%s", expressionString, 0, 0);
|
||||||
|
@ -593,25 +578,20 @@ expandExpression(toBuffer, toBufferPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expandNum(buffer, bufferPtr, n)
|
expandNum(char *buffer, char **bufferPtr, int n)
|
||||||
char *buffer;
|
|
||||||
char **bufferPtr;
|
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
moreTextOptional(buffer, bufferPtr, "%d", n, 0, 0);
|
moreTextOptional(buffer, bufferPtr, "%d", n, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
flushOperand(n)
|
flushOperand(int n)
|
||||||
int n;
|
|
||||||
{
|
{
|
||||||
moreText("%s", operandBuffer[n], 0, 0);
|
moreText("%s", operandBuffer[n], 0, 0);
|
||||||
operandBuffer[n][0] = '\0';
|
operandBuffer[n][0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expandOperands(op)
|
expandOperands(int op)
|
||||||
int op;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -625,7 +605,7 @@ expandOperands(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expandLabel()
|
expandLabel(void)
|
||||||
{
|
{
|
||||||
moreText("%s", labelString, 0, 0);
|
moreText("%s", labelString, 0, 0);
|
||||||
labelStringPtr = labelString;
|
labelStringPtr = labelString;
|
||||||
|
@ -643,7 +623,7 @@ moreExpression(char *format, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
startLineMarked()
|
startLineMarked(void)
|
||||||
{
|
{
|
||||||
startLine();
|
startLine();
|
||||||
if (amListing())
|
if (amListing())
|
||||||
|
@ -651,8 +631,7 @@ startLineMarked()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
notListable(statementKind)
|
notListable(statementKindType statementKind)
|
||||||
statementKindType statementKind;
|
|
||||||
{
|
{
|
||||||
return(!listableStatement(statementKind) &&
|
return(!listableStatement(statementKind) &&
|
||||||
statementKind != INSTRUCTION_STATEMENT &&
|
statementKind != INSTRUCTION_STATEMENT &&
|
||||||
|
|
20
listing.h
20
listing.h
|
@ -6,9 +6,9 @@
|
||||||
* Glorious Future Year 1989 the vprintf function does almost exactly
|
* Glorious Future Year 1989 the vprintf function does almost exactly
|
||||||
* what we want. */
|
* what we want. */
|
||||||
|
|
||||||
void outputListing();
|
void outputListing(void);
|
||||||
void terminateListingFiles();
|
void terminateListingFiles(void);
|
||||||
void generateListing();
|
void generateListing(void);
|
||||||
int printMacroLine(int numberOfBytes, int byteAddress, statementKindType kind);
|
int printMacroLine(int numberOfBytes, int byteAddress, statementKindType kind);
|
||||||
void readSourceFileLine(int *sourceAddressPtr, int *sourceDepthPtr, char lineBuffer[], FILE *file);
|
void readSourceFileLine(int *sourceAddressPtr, int *sourceDepthPtr, char lineBuffer[], FILE *file);
|
||||||
void readIndexFileLine(statementKindType *statementKindPtr, int *indexAddressPtr, int *indexLineNumberPtr);
|
void readIndexFileLine(statementKindType *statementKindPtr, int *indexAddressPtr, int *indexLineNumberPtr);
|
||||||
|
@ -17,22 +17,22 @@ bool isBlockOpener(statementKindType statementKind);
|
||||||
bool isBlankStatment(statementKindType statementKind);
|
bool isBlankStatment(statementKindType statementKind);
|
||||||
void tabPrint(stringType *text);
|
void tabPrint(stringType *text);
|
||||||
void printNTimes (char aChar, int times);
|
void printNTimes (char aChar, int times);
|
||||||
void tabIndent();
|
void tabIndent(void);
|
||||||
bool labeledLine();
|
bool labeledLine(void);
|
||||||
void addText(char *buffer, char **bufferPtr, char *format, ...);
|
void addText(char *buffer, char **bufferPtr, char *format, ...);
|
||||||
void moreTextOptional(char *buffer, char **bufferPtr, char *format, ...);
|
void moreTextOptional(char *buffer, char **bufferPtr, char *format, ...);
|
||||||
void moreText(char *format, ...);
|
void moreText(char *format, ...);
|
||||||
void moreLabel(char *format, int arg1);
|
void moreLabel(char *format, int arg1);
|
||||||
void startLine();
|
void startLine(void);
|
||||||
void endLine();
|
void endLine(void);
|
||||||
void flushExpressionString();
|
void flushExpressionString(void);
|
||||||
void expandExpression(char *toBuffer, char **toBufferPtr);
|
void expandExpression(char *toBuffer, char **toBufferPtr);
|
||||||
void expandNum(char *buffer, char **bufferPtr, int n);
|
void expandNum(char *buffer, char **bufferPtr, int n);
|
||||||
void flushOperand(int n);
|
void flushOperand(int n);
|
||||||
void expandOperands(int op);
|
void expandOperands(int op);
|
||||||
void expandLabel();
|
void expandLabel(void);
|
||||||
void moreExpression(char *format, ...);
|
void moreExpression(char *format, ...);
|
||||||
void startLineMarked();
|
void startLineMarked(void);
|
||||||
bool notListable(statementKindType statementKind);
|
bool notListable(statementKindType statementKind);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
135
lookups.c
135
lookups.c
|
@ -36,14 +36,24 @@
|
||||||
lists that are sorted alphabetically.
|
lists that are sorted alphabetically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
conditionType
|
|
||||||
lookupConditionCode(s, hashValue)
|
extern void botch (char *message, ...);
|
||||||
char *s;
|
extern void freeValue (valueType *value);
|
||||||
int hashValue;
|
extern void error (errorType theError, ...);
|
||||||
|
bool strcmplc (char *s1, char *s2);
|
||||||
|
int hashString (char *s);
|
||||||
|
extern int countParameters (operandListType *parameterList);
|
||||||
|
extern arrayType *allocArray (int size, valueType ***contentsPtr);
|
||||||
|
extern bool isUsable (valueType *value);
|
||||||
|
extern void moreExpression (char *format, ...);
|
||||||
|
extern bool isUndefined (valueType *value);
|
||||||
|
|
||||||
|
conditionType
|
||||||
|
lookupConditionCode(char *s, int hashValue)
|
||||||
{
|
{
|
||||||
conditionTableEntryType *result;
|
conditionTableEntryType *result;
|
||||||
|
|
||||||
genericTableEntryType *prehashedStringLookup();
|
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
||||||
|
|
||||||
result = (conditionTableEntryType *) prehashedStringLookup(s,
|
result = (conditionTableEntryType *) prehashedStringLookup(s,
|
||||||
conditionTable, hashValue);
|
conditionTable, hashValue);
|
||||||
|
@ -54,13 +64,11 @@ lookupConditionCode(s, hashValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lookupKeyword(s, hashValue)
|
lookupKeyword(char *s, int hashValue)
|
||||||
char *s;
|
|
||||||
int hashValue;
|
|
||||||
{
|
{
|
||||||
keywordTableEntryType *result;
|
keywordTableEntryType *result;
|
||||||
|
|
||||||
genericTableEntryType *prehashedStringLookup();
|
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
||||||
|
|
||||||
result = (keywordTableEntryType *) prehashedStringLookup(s,
|
result = (keywordTableEntryType *) prehashedStringLookup(s,
|
||||||
keywordTable, hashValue);
|
keywordTable, hashValue);
|
||||||
|
@ -71,22 +79,18 @@ lookupKeyword(s, hashValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
macroTableEntryType *
|
macroTableEntryType *
|
||||||
lookupMacroName(s, hashValue)
|
lookupMacroName(char *s, int hashValue)
|
||||||
char *s;
|
|
||||||
int hashValue;
|
|
||||||
{
|
{
|
||||||
genericTableEntryType *prehashedStringLookup();
|
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
||||||
|
|
||||||
return((macroTableEntryType *) prehashedStringLookup(s, macroTable,
|
return((macroTableEntryType *) prehashedStringLookup(s, macroTable,
|
||||||
hashValue));
|
hashValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
opcodeTableEntryType *
|
opcodeTableEntryType *
|
||||||
lookupOpcode(s, hashValue)
|
lookupOpcode(char *s, int hashValue)
|
||||||
char *s;
|
|
||||||
int hashValue;
|
|
||||||
{
|
{
|
||||||
genericTableEntryType *prehashedStringLookup();
|
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
||||||
|
|
||||||
return((opcodeTableEntryType *) prehashedStringLookup(s,
|
return((opcodeTableEntryType *) prehashedStringLookup(s,
|
||||||
opcodeTable, hashValue));
|
opcodeTable, hashValue));
|
||||||
|
@ -97,14 +101,12 @@ lookupOpcode(s, hashValue)
|
||||||
the given kind and return *that* */
|
the given kind and return *that* */
|
||||||
|
|
||||||
symbolTableEntryType *
|
symbolTableEntryType *
|
||||||
lookupOrEnterSymbol(s, kind)
|
lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind)
|
||||||
stringType *s;
|
|
||||||
symbolUsageKindType kind;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *result;
|
symbolTableEntryType *result;
|
||||||
genericTableEntryType *hashStringLookup();
|
genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table);
|
||||||
genericTableEntryType *hashStringEnter();
|
genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table);
|
||||||
symbolTableEntryType *buildSymbolTableEntry();
|
symbolTableEntryType *buildSymbolTableEntry(stringType *name, symbolUsageKindType usage);
|
||||||
|
|
||||||
if (result = (symbolTableEntryType *)hashStringLookup(s,symbolTable)){
|
if (result = (symbolTableEntryType *)hashStringLookup(s,symbolTable)){
|
||||||
/* result->referenceCount++;*/
|
/* result->referenceCount++;*/
|
||||||
|
@ -116,8 +118,7 @@ lookupOrEnterSymbol(s, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pushSymbol(symbol)
|
pushSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *newContext;
|
symbolInContextType *newContext;
|
||||||
|
|
||||||
|
@ -127,8 +128,7 @@ pushSymbol(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
popSymbol(symbol)
|
popSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *deadContext;
|
symbolInContextType *deadContext;
|
||||||
|
|
||||||
|
@ -146,16 +146,15 @@ popSymbol(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
macroTableEntryType *
|
macroTableEntryType *
|
||||||
createMacro(macroName)
|
createMacro(stringType *macroName)
|
||||||
stringType *macroName;
|
|
||||||
{
|
{
|
||||||
macroTableEntryType *result;
|
macroTableEntryType *result;
|
||||||
symbolTableEntryType *testSymbol;
|
symbolTableEntryType *testSymbol;
|
||||||
|
|
||||||
genericTableEntryType *hashStringLookup();
|
genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table);
|
||||||
genericTableEntryType *hashStringEnter();
|
genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table);
|
||||||
macroTableEntryType *buildMacroTableEntry();
|
macroTableEntryType *buildMacroTableEntry(stringType *name);
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
|
|
||||||
testSymbol = lookupOrEnterSymbol(macroName, MACRO_SYMBOL);
|
testSymbol = lookupOrEnterSymbol(macroName, MACRO_SYMBOL);
|
||||||
if (testSymbol->context->usage != MACRO_SYMBOL) {
|
if (testSymbol->context->usage != MACRO_SYMBOL) {
|
||||||
|
@ -179,10 +178,7 @@ createMacro(macroName)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
genericTableEntryType *
|
genericTableEntryType *
|
||||||
prehashedStringLookup(s, table, hashValue)
|
prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue)
|
||||||
char *s;
|
|
||||||
genericTableEntryType *table[];
|
|
||||||
int hashValue;
|
|
||||||
{
|
{
|
||||||
genericTableEntryType *result;
|
genericTableEntryType *result;
|
||||||
int test;
|
int test;
|
||||||
|
@ -202,17 +198,13 @@ prehashedStringLookup(s, table, hashValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
genericTableEntryType *
|
genericTableEntryType *
|
||||||
hashStringLookup(s, table)
|
hashStringLookup(char *s, genericTableEntryType **table)
|
||||||
char *s;
|
|
||||||
genericTableEntryType *table[];
|
|
||||||
{
|
{
|
||||||
return(prehashedStringLookup(s, table, hashString(s)));
|
return(prehashedStringLookup(s, table, hashString(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
genericTableEntryType *
|
genericTableEntryType *
|
||||||
hashStringEnter(entry, table)
|
hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table)
|
||||||
genericTableEntryType *entry;
|
|
||||||
genericTableEntryType *table[];
|
|
||||||
{
|
{
|
||||||
genericTableEntryType *result;
|
genericTableEntryType *result;
|
||||||
genericTableEntryType *oldResult;
|
genericTableEntryType *oldResult;
|
||||||
|
@ -252,8 +244,7 @@ hashStringEnter(entry, table)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
hashString(s)
|
hashString(char *s)
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
unsigned result;
|
unsigned result;
|
||||||
|
|
||||||
|
@ -264,9 +255,9 @@ hashString(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
strcmplc(s1, s2) /* string compare in lower case */
|
strcmplc(char *s1, char *s2) /* string compare in lower case */
|
||||||
char *s1; /* heavily optimized version */
|
/* heavily optimized version */
|
||||||
char *s2;
|
|
||||||
{
|
{
|
||||||
char c1;
|
char c1;
|
||||||
int result;
|
int result;
|
||||||
|
@ -284,9 +275,9 @@ strcmplc(s1, s2) /* string compare in lower case */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
strcmplct(s1, s2) /* For tables: s2 is already lower case */
|
strcmplct(char *s1, char *s2) /* For tables: s2 is already lower case */
|
||||||
char *s1; /* heavily optimized version. */
|
/* heavily optimized version. */
|
||||||
char *s2;
|
|
||||||
{
|
{
|
||||||
char c1;
|
char c1;
|
||||||
int result;
|
int result;
|
||||||
|
@ -302,21 +293,18 @@ strcmplct(s1, s2) /* For tables: s2 is already lower case */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
purgeSymbol(symbol)
|
purgeSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
if ((context = getWorkingContext(symbol)) != NULL)
|
if ((context = getWorkingContext(symbol)) != NULL)
|
||||||
context->usage = DEAD_SYMBOL;
|
context->usage = DEAD_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
reincarnateSymbol(context, newUsage)
|
reincarnateSymbol(symbolInContextType *context, symbolUsageKindType newUsage)
|
||||||
symbolInContextType *context;
|
|
||||||
symbolUsageKindType newUsage;
|
|
||||||
{
|
{
|
||||||
context->attributes = 0;
|
context->attributes = 0;
|
||||||
dupValue(context->value, UndefinedValue);
|
dupValue(context->value, UndefinedValue);
|
||||||
|
@ -329,12 +317,9 @@ reincarnateSymbol(context, newUsage)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
pushBinding(symbol, newBinding, newUsage)
|
pushBinding(symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
valueType *newBinding;
|
|
||||||
symbolUsageKindType newUsage;
|
|
||||||
{
|
{
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
pushSymbol(symbol);
|
pushSymbol(symbol);
|
||||||
if (newBinding == NULL)
|
if (newBinding == NULL)
|
||||||
|
@ -347,17 +332,13 @@ pushBinding(symbol, newBinding, newUsage)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
popBinding(symbol)
|
popBinding(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
popSymbol(symbol);
|
popSymbol(symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
int /* returns number of bindings completed, negative this if failure */
|
int /* returns number of bindings completed, negative this if failure */
|
||||||
bindMacroArguments(argumentList, parameterList, macroName)
|
bindMacroArguments(argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *macroName)
|
||||||
argumentDefinitionListType *argumentList;
|
|
||||||
operandListType *parameterList;
|
|
||||||
stringType *macroName;
|
|
||||||
{
|
{
|
||||||
int numberBound;
|
int numberBound;
|
||||||
bool arrayTag;
|
bool arrayTag;
|
||||||
|
@ -365,7 +346,7 @@ bindMacroArguments(argumentList, parameterList, macroName)
|
||||||
valueType **arrayContents;
|
valueType **arrayContents;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
if (argumentList == NULL)
|
if (argumentList == NULL)
|
||||||
arrayTag = FALSE;
|
arrayTag = FALSE;
|
||||||
|
@ -417,10 +398,7 @@ bindMacroArguments(argumentList, parameterList, macroName)
|
||||||
}
|
}
|
||||||
|
|
||||||
int /* returns number of bindings completed, negative this if failure */
|
int /* returns number of bindings completed, negative this if failure */
|
||||||
bindFunctionArguments(argumentList, parameterList, functionName)
|
bindFunctionArguments(argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *functionName)
|
||||||
argumentDefinitionListType *argumentList;
|
|
||||||
operandListType *parameterList;
|
|
||||||
stringType *functionName;
|
|
||||||
{
|
{
|
||||||
valueType *argument;
|
valueType *argument;
|
||||||
bool arrayTag;
|
bool arrayTag;
|
||||||
|
@ -431,8 +409,8 @@ bindFunctionArguments(argumentList, parameterList, functionName)
|
||||||
valueType *firstArgument;
|
valueType *firstArgument;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
|
||||||
valueType *evaluateOperand();
|
valueType *evaluateOperand(operandType *operand);
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
if (argumentList == NULL)
|
if (argumentList == NULL)
|
||||||
arrayTag = FALSE;
|
arrayTag = FALSE;
|
||||||
|
@ -515,9 +493,7 @@ bindFunctionArguments(argumentList, parameterList, functionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unbindArguments(argumentList, numberToUnbind)
|
unbindArguments(argumentDefinitionListType *argumentList, int numberToUnbind)
|
||||||
argumentDefinitionListType *argumentList;
|
|
||||||
int numberToUnbind;
|
|
||||||
{
|
{
|
||||||
while (argumentList != NULL && numberToUnbind-- > 0) {
|
while (argumentList != NULL && numberToUnbind-- > 0) {
|
||||||
popBinding(argumentList->theArgument);
|
popBinding(argumentList->theArgument);
|
||||||
|
@ -528,8 +504,7 @@ unbindArguments(argumentList, numberToUnbind)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unbindLocalVariables(identifierList)
|
unbindLocalVariables(identifierListType *identifierList)
|
||||||
identifierListType *identifierList;
|
|
||||||
{
|
{
|
||||||
identifierListType *deadEntry;
|
identifierListType *deadEntry;
|
||||||
|
|
||||||
|
|
|
@ -205,20 +205,20 @@ int operandClassTable[] = { /* indexed by operandKindType */
|
||||||
BLOCK_OPND_BIT,
|
BLOCK_OPND_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
int actionsRelative();
|
int actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDir1();
|
int actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDir2();
|
int actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDirIndir();
|
int actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDirX1();
|
int actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDirX2();
|
int actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDirX3();
|
int actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsDirY();
|
int actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsImmDir();
|
int actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsImmDirX();
|
int actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsImmDirY();
|
int actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsNone();
|
int actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsIndex();
|
int actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
int actionsImmIndex();
|
int actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
||||||
|
|
||||||
/* indexed by opcodeClass */
|
/* indexed by opcodeClass */
|
||||||
int (*instructionActionTable[])() = {
|
int (*instructionActionTable[])() = {
|
||||||
|
@ -303,53 +303,53 @@ valueType undefinedValueValue = { UNDEFINED_VALUE, 0,
|
||||||
EXPRESSION_OPND };
|
EXPRESSION_OPND };
|
||||||
valueType *UndefinedValue = &undefinedValueValue;
|
valueType *UndefinedValue = &undefinedValueValue;
|
||||||
|
|
||||||
valueType *addressModeBIF();
|
valueType *addressModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *applyBIF();
|
valueType *applyBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *arrayLengthBIF();
|
valueType *arrayLengthBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *atasciiBIF();
|
valueType *atasciiBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *atasciiColorBIF();
|
valueType *atasciiColorBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *debugModeOffBIF();
|
valueType *debugModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *debugModeOnBIF();
|
valueType *debugModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *emitModeOffBIF();
|
valueType *emitModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *emitModeOnBIF();
|
valueType *emitModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isAbsoluteValueBIF();
|
valueType *isAbsoluteValueBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isARegisterBIF();
|
valueType *isARegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isBlockBIF();
|
valueType *isBlockBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isBuiltInFunctionBIF();
|
valueType *isBuiltInFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isConditionCodeBIF();
|
valueType *isConditionCodeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isDefinedBIF();
|
valueType *isDefinedBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isDirectModeBIF();
|
valueType *isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isExternalBIF();
|
valueType *isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isFieldBIF();
|
valueType *isFieldBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isFunctionBIF();
|
valueType *isFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isImmediateModeBIF();
|
valueType *isImmediateModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isIndexedModeBIF();
|
valueType *isIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isIndirectModeBIF();
|
valueType *isIndirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isPostIndexedModeBIF();
|
valueType *isPostIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isPreIndexedModeBIF();
|
valueType *isPreIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isRelocatableValueBIF();
|
valueType *isRelocatableValueBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isStringBIF();
|
valueType *isStringBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isStructBIF();
|
valueType *isStructBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isSymbolBIF();
|
valueType *isSymbolBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isXIndexedModeBIF();
|
valueType *isXIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isXRegisterBIF();
|
valueType *isXRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isYIndexedModeBIF();
|
valueType *isYIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *isYRegisterBIF();
|
valueType *isYRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *listingOffBIF();
|
valueType *listingOffBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *listingOnBIF();
|
valueType *listingOnBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *makeArrayBIF();
|
valueType *makeArrayBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *nthCharBIF();
|
valueType *nthCharBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *printfBIF();
|
valueType *printfBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *strcatBIF();
|
valueType *strcatBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *strcmpBIF();
|
valueType *strcmpBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *strcmplcBIF();
|
valueType *strcmplcBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *strlenBIF();
|
valueType *strlenBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *substrBIF();
|
valueType *substrBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *symbolDefineBIF();
|
valueType *symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *symbolLookupBIF();
|
valueType *symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *symbolNameBIF();
|
valueType *symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *symbolUsageBIF();
|
valueType *symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
valueType *valueTypeBIF();
|
valueType *valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
||||||
|
|
||||||
/* Used to initialize symbols representing built-in functions */
|
/* Used to initialize symbols representing built-in functions */
|
||||||
struct {
|
struct {
|
||||||
|
|
14
main.c
14
main.c
|
@ -30,16 +30,20 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
extern void initializeStuff (int argc, char **argv);
|
||||||
char *argv[];
|
extern int yyparse (void);
|
||||||
|
extern void finishUp (void);
|
||||||
|
extern void chokePukeAndDie (void);
|
||||||
|
|
||||||
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
char end = get_end();
|
char end = get_end();
|
||||||
#else
|
#else
|
||||||
extern char end;
|
extern char end;
|
||||||
#endif
|
#endif
|
||||||
char *sbrk();
|
char *sbrk(int);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
initializeStuff(argc, argv);
|
initializeStuff(argc, argv);
|
||||||
|
@ -55,7 +59,7 @@ main(argc, argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printVersion()
|
printVersion(void)
|
||||||
{
|
{
|
||||||
printf("Macross %s version 4.20.\n", TARGET_CPU_STRING);
|
printf("Macross %s version 4.20.\n", TARGET_CPU_STRING);
|
||||||
}
|
}
|
||||||
|
|
19
malloc.c
19
malloc.c
|
@ -80,7 +80,7 @@ union overhead {
|
||||||
*/
|
*/
|
||||||
#define NBUCKETS 30
|
#define NBUCKETS 30
|
||||||
static union overhead *nextf[NBUCKETS];
|
static union overhead *nextf[NBUCKETS];
|
||||||
extern char *sbrk();
|
extern char *sbrk(int);
|
||||||
|
|
||||||
#ifdef MSTATS
|
#ifdef MSTATS
|
||||||
/*
|
/*
|
||||||
|
@ -109,8 +109,7 @@ static void morecore(int);
|
||||||
static int findbucket(union overhead *, int);
|
static int findbucket(union overhead *, int);
|
||||||
|
|
||||||
char *
|
char *
|
||||||
malloc(nbytes)
|
malloc(register unsigned int nbytes)
|
||||||
register unsigned nbytes;
|
|
||||||
{
|
{
|
||||||
register union overhead *p;
|
register union overhead *p;
|
||||||
register int bucket = 0;
|
register int bucket = 0;
|
||||||
|
@ -160,8 +159,7 @@ malloc(nbytes)
|
||||||
* Allocate more memory to the indicated bucket.
|
* Allocate more memory to the indicated bucket.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
morecore(bucket)
|
morecore(register int bucket)
|
||||||
register bucket;
|
|
||||||
{
|
{
|
||||||
register union overhead *op;
|
register union overhead *op;
|
||||||
register int rnu; /* 2^rnu bytes will be requested */
|
register int rnu; /* 2^rnu bytes will be requested */
|
||||||
|
@ -209,8 +207,7 @@ morecore(bucket)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
free(cp)
|
free(char *cp)
|
||||||
char *cp;
|
|
||||||
{
|
{
|
||||||
register int size;
|
register int size;
|
||||||
register union overhead *op;
|
register union overhead *op;
|
||||||
|
@ -252,9 +249,7 @@ free(cp)
|
||||||
int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
|
int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
realloc(cp, nbytes)
|
realloc(char *cp, unsigned int nbytes)
|
||||||
char *cp;
|
|
||||||
unsigned nbytes;
|
|
||||||
{
|
{
|
||||||
register u_int onb;
|
register u_int onb;
|
||||||
union overhead *op;
|
union overhead *op;
|
||||||
|
@ -304,9 +299,7 @@ realloc(cp, nbytes)
|
||||||
* Return bucket number, or -1 if not found.
|
* Return bucket number, or -1 if not found.
|
||||||
*/
|
*/
|
||||||
static
|
static
|
||||||
findbucket(freep, srchlen)
|
findbucket(union overhead *freep, int srchlen)
|
||||||
union overhead *freep;
|
|
||||||
int srchlen;
|
|
||||||
{
|
{
|
||||||
register union overhead *p;
|
register union overhead *p;
|
||||||
register int i, j;
|
register int i, j;
|
||||||
|
|
134
object.c
134
object.c
|
@ -36,19 +36,28 @@ static int symbolTableSize;
|
||||||
static int symbolTableStringSize;
|
static int symbolTableStringSize;
|
||||||
bool encodingFunction;
|
bool encodingFunction;
|
||||||
|
|
||||||
void
|
|
||||||
outputObjectFile()
|
extern void printCodeBuffers (void);
|
||||||
|
extern bool isExternal (symbolTableEntryType *symbol);
|
||||||
|
extern bool strcmplc (char *s1, char *s2);
|
||||||
|
bool hackableSymbol (symbolTableEntryType *symbol);
|
||||||
|
extern void printExpressionBuffer (void);
|
||||||
|
extern bool encodeRelocatableNumber (numberTermType number);
|
||||||
|
extern void freeExpression (expressionType *expression);
|
||||||
|
|
||||||
|
void
|
||||||
|
outputObjectFile(void)
|
||||||
{
|
{
|
||||||
void outputPartition();
|
void outputPartition(void);
|
||||||
void outputReferenceInfo();
|
void outputReferenceInfo(void);
|
||||||
void outputSymbolTableInfo();
|
void outputSymbolTableInfo(void);
|
||||||
void outputAbsoluteCode();
|
void outputAbsoluteCode(void);
|
||||||
void outputRelocatableCode();
|
void outputRelocatableCode(void);
|
||||||
void outputReservations();
|
void outputReservations(void);
|
||||||
void outputExpressions();
|
void outputExpressions(void);
|
||||||
void outputFunctions();
|
void outputFunctions(void);
|
||||||
void dumpSymbolTable();
|
void dumpSymbolTable(void);
|
||||||
void enumerateAndCountSymbols();
|
void enumerateAndCountSymbols(void);
|
||||||
|
|
||||||
if (debug || emitPrint)
|
if (debug || emitPrint)
|
||||||
printCodeBuffers();
|
printCodeBuffers();
|
||||||
|
@ -72,22 +81,20 @@ outputObjectFile()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputWord(aWord)
|
outputWord(int aWord)
|
||||||
int aWord;
|
|
||||||
{
|
{
|
||||||
putc(aWord & 0xFF, objectFileOutput);
|
putc(aWord & 0xFF, objectFileOutput);
|
||||||
putc((aWord >> 8) & 0xFF, objectFileOutput);
|
putc((aWord >> 8) & 0xFF, objectFileOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputPartition()
|
outputPartition(void)
|
||||||
{
|
{
|
||||||
outputWord(0xFFFF);
|
outputWord(0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputBigword(bigword)
|
outputBigword(long unsigned int bigword)
|
||||||
unsigned long bigword;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -98,15 +105,13 @@ outputBigword(bigword)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputByte(aByte)
|
outputByte(byte aByte)
|
||||||
byte aByte;
|
|
||||||
{
|
{
|
||||||
putc(aByte, objectFileOutput);
|
putc(aByte, objectFileOutput);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputString(string)
|
outputString(stringType *string)
|
||||||
stringType *string;
|
|
||||||
{
|
{
|
||||||
do {
|
do {
|
||||||
putc(*string, objectFileOutput);
|
putc(*string, objectFileOutput);
|
||||||
|
@ -114,8 +119,7 @@ outputString(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputStartAddress(startAddress)
|
outputStartAddress(addressType startAddress)
|
||||||
addressType startAddress;
|
|
||||||
{
|
{
|
||||||
outputWord(startAddress);
|
outputWord(startAddress);
|
||||||
if (produceLinkableObject) {
|
if (produceLinkableObject) {
|
||||||
|
@ -128,14 +132,14 @@ outputStartAddress(startAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputRelocatableCode()
|
outputRelocatableCode(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
addressType codeStartAddress;
|
addressType codeStartAddress;
|
||||||
addressType codeEndAddress;
|
addressType codeEndAddress;
|
||||||
|
|
||||||
void outputPseudoSegment();
|
void outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress);
|
||||||
void outputBreak();
|
void outputBreak(codeBreakType *codeBreak);
|
||||||
|
|
||||||
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
||||||
kindOfValue == RELOCATABLE_VALUE)
|
kindOfValue == RELOCATABLE_VALUE)
|
||||||
|
@ -161,8 +165,7 @@ outputRelocatableCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputBreak(codeBreak)
|
outputBreak(codeBreakType *codeBreak)
|
||||||
codeBreakType *codeBreak;
|
|
||||||
{
|
{
|
||||||
switch (codeBreak->kindOfBreak) {
|
switch (codeBreak->kindOfBreak) {
|
||||||
case BREAK_BREAK:
|
case BREAK_BREAK:
|
||||||
|
@ -185,13 +188,13 @@ outputBreak(codeBreak)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputAbsoluteCode()
|
outputAbsoluteCode(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int startSegment;
|
int startSegment;
|
||||||
int endSegment;
|
int endSegment;
|
||||||
int nextSegment;
|
int nextSegment;
|
||||||
void outputOneCodeBuffer();
|
void outputOneCodeBuffer(codeSegmentType *segment);
|
||||||
|
|
||||||
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
||||||
kindOfValue==ABSOLUTE_VALUE)
|
kindOfValue==ABSOLUTE_VALUE)
|
||||||
|
@ -223,8 +226,7 @@ outputAbsoluteCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputOneCodeBuffer(segment)
|
outputOneCodeBuffer(codeSegmentType *segment)
|
||||||
codeSegmentType *segment;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -238,9 +240,7 @@ outputOneCodeBuffer(segment)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputPseudoSegment(codeStartAddress, codeEndAddress)
|
outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress)
|
||||||
addressType codeStartAddress;
|
|
||||||
addressType codeEndAddress;
|
|
||||||
{
|
{
|
||||||
int startSegment;
|
int startSegment;
|
||||||
int endSegment;
|
int endSegment;
|
||||||
|
@ -252,8 +252,8 @@ outputPseudoSegment(codeStartAddress, codeEndAddress)
|
||||||
int segment;
|
int segment;
|
||||||
codeSegmentType *segmentPtr;
|
codeSegmentType *segmentPtr;
|
||||||
|
|
||||||
void outputWord();
|
void outputWord(int aWord);
|
||||||
void outputByte();
|
void outputByte(byte aByte);
|
||||||
|
|
||||||
outputWord(codeStartAddress);
|
outputWord(codeStartAddress);
|
||||||
outputWord(codeEndAddress);
|
outputWord(codeEndAddress);
|
||||||
|
@ -273,8 +273,7 @@ outputPseudoSegment(codeStartAddress, codeEndAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isObjectSymbol(symbol)
|
isObjectSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
return(symbol != NULL && symbol->context->value != NULL &&
|
return(symbol != NULL && symbol->context->value != NULL &&
|
||||||
symbol->context->value->kindOfValue != FUNCTION_VALUE &&
|
symbol->context->value->kindOfValue != FUNCTION_VALUE &&
|
||||||
|
@ -289,7 +288,7 @@ isObjectSymbol(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
enumerateAndCountSymbols()
|
enumerateAndCountSymbols(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *symb;
|
symbolTableEntryType *symb;
|
||||||
|
@ -305,7 +304,7 @@ enumerateAndCountSymbols()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
enumerateAndCountReferences()
|
enumerateAndCountReferences(void)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
int codeMode;
|
int codeMode;
|
||||||
|
@ -323,8 +322,7 @@ enumerateAndCountReferences()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputReference(reference)
|
outputReference(expressionReferenceType *reference)
|
||||||
expressionReferenceType *reference;
|
|
||||||
{
|
{
|
||||||
byte funnyByte;
|
byte funnyByte;
|
||||||
bigWord funnyWord;
|
bigWord funnyWord;
|
||||||
|
@ -346,7 +344,7 @@ outputReference(reference)
|
||||||
static int referenceCount;
|
static int referenceCount;
|
||||||
|
|
||||||
void
|
void
|
||||||
outputReferenceInfo()
|
outputReferenceInfo(void)
|
||||||
{
|
{
|
||||||
expressionReferenceListType *theReferences;
|
expressionReferenceListType *theReferences;
|
||||||
int codeMode;
|
int codeMode;
|
||||||
|
@ -363,12 +361,11 @@ outputReferenceInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputOneSymbol(symbol)
|
outputOneSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
byte symbolClass;
|
byte symbolClass;
|
||||||
valueType *symbolValue;
|
valueType *symbolValue;
|
||||||
valueType *evaluateIdentifier();
|
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
||||||
|
|
||||||
if (symbol->context->usage == DEFINE_SYMBOL)
|
if (symbol->context->usage == DEFINE_SYMBOL)
|
||||||
symbolValue = evaluateIdentifier(symbol, FALSE, NO_FIXUP_OK);
|
symbolValue = evaluateIdentifier(symbol, FALSE, NO_FIXUP_OK);
|
||||||
|
@ -390,7 +387,7 @@ outputOneSymbol(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputSymbolTableInfo()
|
outputSymbolTableInfo(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *symb;
|
symbolTableEntryType *symb;
|
||||||
|
@ -404,16 +401,13 @@ outputSymbolTableInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
symbolCompare(symbol1, symbol2)
|
symbolCompare(symbolTableEntryType **symbol1, symbolTableEntryType **symbol2)
|
||||||
symbolTableEntryType **symbol1;
|
|
||||||
symbolTableEntryType **symbol2;
|
|
||||||
{
|
{
|
||||||
return(strcmplc((*symbol1)->symbolName, (*symbol2)->symbolName));
|
return(strcmplc((*symbol1)->symbolName, (*symbol2)->symbolName));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
shouldDumpSymbol(symbol)
|
shouldDumpSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
return(symbolTableDumpOn == 2
|
return(symbolTableDumpOn == 2
|
||||||
|| (symbol->context->usage != BUILT_IN_FUNCTION_SYMBOL
|
|| (symbol->context->usage != BUILT_IN_FUNCTION_SYMBOL
|
||||||
|
@ -428,7 +422,7 @@ shouldDumpSymbol(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dumpSymbolTable()
|
dumpSymbolTable(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *symb;
|
symbolTableEntryType *symb;
|
||||||
|
@ -437,8 +431,8 @@ dumpSymbolTable()
|
||||||
int symbolPtr;
|
int symbolPtr;
|
||||||
valueType *value;
|
valueType *value;
|
||||||
|
|
||||||
valueType *evaluateIdentifier();
|
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
||||||
void printValueTersely();
|
void printValueTersely(valueType *value);
|
||||||
|
|
||||||
numberOfSymbols = 0;
|
numberOfSymbols = 0;
|
||||||
for (i=0; i<HASH_TABLE_SIZE; i++)
|
for (i=0; i<HASH_TABLE_SIZE; i++)
|
||||||
|
@ -505,16 +499,14 @@ dumpSymbolTable()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
hackableSymbol(symbol)
|
hackableSymbol(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
return(symbol->context->usage == DEFINE_SYMBOL || symbol->context->
|
return(symbol->context->usage == DEFINE_SYMBOL || symbol->context->
|
||||||
usage == LABEL_SYMBOL);
|
usage == LABEL_SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
printValueTersely(value)
|
printValueTersely(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
static char *valueKindTable[NUM_OF_VALUE_KINDS] = {
|
static char *valueKindTable[NUM_OF_VALUE_KINDS] = {
|
||||||
"ABS",
|
"ABS",
|
||||||
|
@ -542,7 +534,7 @@ printValueTersely(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputReservations()
|
outputReservations(void)
|
||||||
{
|
{
|
||||||
while (reservationList != NULL) {
|
while (reservationList != NULL) {
|
||||||
outputWord(reservationList->startAddress);
|
outputWord(reservationList->startAddress);
|
||||||
|
@ -552,7 +544,7 @@ outputReservations()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputExpressionBuffer()
|
outputExpressionBuffer(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -564,13 +556,12 @@ outputExpressionBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputOneExpression(expression)
|
outputOneExpression(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
expressionType *newExpression;
|
expressionType *newExpression;
|
||||||
|
|
||||||
expressionType *generateFixupExpression();
|
expressionType *generateFixupExpression(expressionType *expression);
|
||||||
bool encodeExpression();
|
bool encodeExpression(expressionType *expression);
|
||||||
|
|
||||||
expressionBufferSize = 0;
|
expressionBufferSize = 0;
|
||||||
if (expression == NULL) {
|
if (expression == NULL) {
|
||||||
|
@ -585,7 +576,7 @@ outputOneExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputExpressions()
|
outputExpressions(void)
|
||||||
{
|
{
|
||||||
int codeMode;
|
int codeMode;
|
||||||
expressionReferenceListType *theReferences;
|
expressionReferenceListType *theReferences;
|
||||||
|
@ -604,12 +595,11 @@ outputExpressions()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputOneFunction(function)
|
outputOneFunction(functionDefinitionType *function)
|
||||||
functionDefinitionType *function;
|
|
||||||
{
|
{
|
||||||
argumentDefinitionListType *argumentList;
|
argumentDefinitionListType *argumentList;
|
||||||
bool encodeBlock();
|
bool encodeBlock(blockType *block);
|
||||||
int countArguments();
|
int countArguments(functionDefinitionType *function);
|
||||||
|
|
||||||
outputByte((byte)countArguments(function));
|
outputByte((byte)countArguments(function));
|
||||||
argumentList = function->arguments;
|
argumentList = function->arguments;
|
||||||
|
@ -623,7 +613,7 @@ outputOneFunction(function)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
outputFunctions()
|
outputFunctions(void)
|
||||||
{
|
{
|
||||||
outputBigword(externalFunctionCount);
|
outputBigword(externalFunctionCount);
|
||||||
encodingFunction = TRUE;
|
encodingFunction = TRUE;
|
||||||
|
|
|
@ -33,10 +33,19 @@
|
||||||
|
|
||||||
/* corresponds to routines in buildStuff2.c */
|
/* corresponds to routines in buildStuff2.c */
|
||||||
|
|
||||||
operandType *
|
|
||||||
buildOperand(kindOfOperand, arg)
|
extern void botch (char *message, ...);
|
||||||
operandKindType kindOfOperand;
|
extern void error (errorType theError, ...);
|
||||||
anyOldThing *arg;
|
extern void freeExpression (expressionType *expression);
|
||||||
|
extern void freeSelectionList (selectionListType *selectionList);
|
||||||
|
extern void freeString (stringType *string);
|
||||||
|
extern void freeBlock (blockType *block);
|
||||||
|
extern void moreText (char *format, ...);
|
||||||
|
extern void expandExpression (char *toBuffer, char **toBufferPtr);
|
||||||
|
extern void assembleBlock (blockType *block);
|
||||||
|
|
||||||
|
operandType *
|
||||||
|
buildOperand(operandKindType kindOfOperand, anyOldThing *arg)
|
||||||
{
|
{
|
||||||
operandType *result;
|
operandType *result;
|
||||||
|
|
||||||
|
@ -129,13 +138,11 @@ buildOperand(kindOfOperand, arg)
|
||||||
/* corresponds to routines in fixups.c */
|
/* corresponds to routines in fixups.c */
|
||||||
|
|
||||||
operandListType *
|
operandListType *
|
||||||
duplicateOperandForFixup(operand, isSpecialFunctionOperand)
|
duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand)
|
||||||
operandListType *operand;
|
|
||||||
bool isSpecialFunctionOperand;
|
|
||||||
{
|
{
|
||||||
operandListType *result;
|
operandListType *result;
|
||||||
|
|
||||||
expressionType *duplicateExpressionForFixup();
|
expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand);
|
||||||
|
|
||||||
result = typeAlloc(operandListType);
|
result = typeAlloc(operandListType);
|
||||||
result->kindOfOperand = operand->kindOfOperand;
|
result->kindOfOperand = operand->kindOfOperand;
|
||||||
|
@ -182,8 +189,7 @@ duplicateOperandForFixup(operand, isSpecialFunctionOperand)
|
||||||
#define nullFree(thing) if (thing == NULL) return;
|
#define nullFree(thing) if (thing == NULL) return;
|
||||||
|
|
||||||
void
|
void
|
||||||
freeOperand(operand)
|
freeOperand(operandType *operand)
|
||||||
operandType *operand;
|
|
||||||
{
|
{
|
||||||
nullFree(operand);
|
nullFree(operand);
|
||||||
switch (operand->kindOfOperand) {
|
switch (operand->kindOfOperand) {
|
||||||
|
@ -229,9 +235,7 @@ freeOperand(operand)
|
||||||
/* corresponds to routines in listing.c */
|
/* corresponds to routines in listing.c */
|
||||||
|
|
||||||
void
|
void
|
||||||
expandOperand(addressMode, buffer)
|
expandOperand(operandKindType addressMode, char *buffer)
|
||||||
operandKindType addressMode;
|
|
||||||
char * buffer;
|
|
||||||
{
|
{
|
||||||
switch (addressMode) {
|
switch (addressMode) {
|
||||||
case IMMEDIATE_OPND: moreText("#"); break;
|
case IMMEDIATE_OPND: moreText("#"); break;
|
||||||
|
@ -279,16 +283,15 @@ expandOperand(addressMode, buffer)
|
||||||
#define expansionOn() expandMacros=saveExpansion;
|
#define expansionOn() expandMacros=saveExpansion;
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
evaluateOperand(operand)
|
evaluateOperand(operandType *operand)
|
||||||
operandType *operand;
|
|
||||||
{
|
{
|
||||||
valueType *result;
|
valueType *result;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
|
|
||||||
valueType *evaluateExpression();
|
valueType *evaluateExpression(expressionType *expression, fixupKindType kindOfFixup);
|
||||||
valueType *evaluateSelectionList();
|
valueType *evaluateSelectionList(selectionListType *selectionList);
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
nullEvaluate(operand);
|
nullEvaluate(operand);
|
||||||
if (operand->kindOfOperand != EXPRESSION_OPND)
|
if (operand->kindOfOperand != EXPRESSION_OPND)
|
||||||
|
@ -358,8 +361,7 @@ evaluateOperand(operand)
|
||||||
/* from parserMisc.c */
|
/* from parserMisc.c */
|
||||||
|
|
||||||
conditionType
|
conditionType
|
||||||
invertConditionCode(conditionCode)
|
invertConditionCode(conditionType conditionCode)
|
||||||
conditionType conditionCode;
|
|
||||||
{
|
{
|
||||||
#define cc (int)conditionCode
|
#define cc (int)conditionCode
|
||||||
|
|
||||||
|
@ -376,8 +378,7 @@ invertConditionCode(conditionCode)
|
||||||
/* from semanticMisc.c */
|
/* from semanticMisc.c */
|
||||||
|
|
||||||
bool
|
bool
|
||||||
shouldParenthesize(operand)
|
shouldParenthesize(operandType *operand)
|
||||||
operandType *operand;
|
|
||||||
{
|
{
|
||||||
expressionTermKindType kind;
|
expressionTermKindType kind;
|
||||||
|
|
||||||
|
|
34
parserMisc.c
34
parserMisc.c
|
@ -37,12 +37,14 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
statementType *
|
|
||||||
addLabelToStatement(labelList, statement)
|
extern void chokePukeAndDie (void);
|
||||||
labelListType *labelList;
|
extern void puntOnError (errorType theError, ...);
|
||||||
statementType *statement;
|
|
||||||
|
statementType *
|
||||||
|
addLabelToStatement(labelListType *labelList, statementType *statement)
|
||||||
{
|
{
|
||||||
statementType *newStatement();
|
statementType *newStatement(statementKindType kind, statementBodyType body);
|
||||||
|
|
||||||
if (statement == NULL)
|
if (statement == NULL)
|
||||||
statement = newStatement(NULL_STATEMENT, (statementBodyType){ NULL });
|
statement = newStatement(NULL_STATEMENT, (statementBodyType){ NULL });
|
||||||
|
@ -66,16 +68,14 @@ botch(char *message, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
checkDefineAssignmentOperator(assignmentOperator)
|
checkDefineAssignmentOperator(assignmentKindType assignmentOperator)
|
||||||
assignmentKindType assignmentOperator;
|
|
||||||
{
|
{
|
||||||
if (assignmentOperator != ASSIGN_ASSIGN)
|
if (assignmentOperator != ASSIGN_ASSIGN)
|
||||||
puntOnError(DEFINE_ASSIGNMENT_WRONG_ERROR);
|
puntOnError(DEFINE_ASSIGNMENT_WRONG_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
convertDefineToMdefine(defineStatement)
|
convertDefineToMdefine(statementType *defineStatement)
|
||||||
statementType *defineStatement;
|
|
||||||
{
|
{
|
||||||
if (defineStatement->kindOfStatement != DEFINE_STATEMENT)
|
if (defineStatement->kindOfStatement != DEFINE_STATEMENT)
|
||||||
botch("convertDefineToMdefine got statement kind: %d\n",
|
botch("convertDefineToMdefine got statement kind: %d\n",
|
||||||
|
@ -85,8 +85,7 @@ convertDefineToMdefine(defineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
ifStatementBodyType *
|
ifStatementBodyType *
|
||||||
extractIfBody(ifStatement)
|
extractIfBody(statementType *ifStatement)
|
||||||
statementType *ifStatement;
|
|
||||||
{
|
{
|
||||||
ifStatementBodyType *result;
|
ifStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -101,8 +100,7 @@ extractIfBody(ifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
mifStatementBodyType *
|
mifStatementBodyType *
|
||||||
extractMifBody(mifStatement)
|
extractMifBody(statementType *mifStatement)
|
||||||
statementType *mifStatement;
|
|
||||||
{
|
{
|
||||||
mifStatementBodyType *result;
|
mifStatementBodyType *result;
|
||||||
|
|
||||||
|
@ -117,8 +115,7 @@ extractMifBody(mifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
stringType *
|
stringType *
|
||||||
extractString(textExpression)
|
extractString(operandType *textExpression)
|
||||||
operandType *textExpression;
|
|
||||||
{
|
{
|
||||||
stringType *result;
|
stringType *result;
|
||||||
|
|
||||||
|
@ -131,22 +128,21 @@ extractString(textExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
popMacroOrFunctionNestingDepth()
|
popMacroOrFunctionNestingDepth(void)
|
||||||
{
|
{
|
||||||
if (--macroOrFunctionNestingDepth == 0)
|
if (--macroOrFunctionNestingDepth == 0)
|
||||||
unknownSymbolTag = UNKNOWN_SYMBOL;
|
unknownSymbolTag = UNKNOWN_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pushMacroOrFunctionNestingDepth()
|
pushMacroOrFunctionNestingDepth(void)
|
||||||
{
|
{
|
||||||
macroOrFunctionNestingDepth++;
|
macroOrFunctionNestingDepth++;
|
||||||
unknownSymbolTag = NESTED_UNKNOWN_SYMBOL;
|
unknownSymbolTag = NESTED_UNKNOWN_SYMBOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
saveString(s)
|
saveString(char *s)
|
||||||
char *s;
|
|
||||||
{
|
{
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ void convertDefineToMDefine(statementType *defineStatement);
|
||||||
ifStatementBodyType *extractIfBody(statementType *ifStatement);
|
ifStatementBodyType *extractIfBody(statementType *ifStatement);
|
||||||
mifStatementBodyType *extractMifBody(statementType *mifStatement);
|
mifStatementBodyType *extractMifBody(statementType *mifStatement);
|
||||||
stringType *extractString(operandType *textExpression);
|
stringType *extractString(operandType *textExpression);
|
||||||
void popMacroOrFunctionNestingDepth();
|
void popMacroOrFunctionNestingDepth(void);
|
||||||
void pushMacroOrFunctionNestingDepth();
|
void pushMacroOrFunctionNestingDepth(void);
|
||||||
char *saveString(char *s);
|
char *saveString(char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
247
semanticMisc.c
247
semanticMisc.c
|
@ -44,21 +44,37 @@
|
||||||
These are miscellaneous routines called by the primary semantics routines.
|
These are miscellaneous routines called by the primary semantics routines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool
|
|
||||||
absoluteValue(address)
|
extern void error (errorType theError, ...);
|
||||||
valueType *address;
|
extern char *valueKindString (valueKindType valueKind);
|
||||||
|
extern void moreLabel (char *format, int arg1);
|
||||||
|
extern void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage);
|
||||||
|
extern void printCreateFixup (expressionType *expression, addressType location, fixupKindType kindOfFixup);
|
||||||
|
extern void flushExpressionString (void);
|
||||||
|
extern void expandOperand (operandKindType addressMode, char *buffer);
|
||||||
|
extern void terminateListingFiles (void);
|
||||||
|
extern void outputObjectFile (void);
|
||||||
|
extern void outputListing (void);
|
||||||
|
extern void botch (char *message, ...);
|
||||||
|
extern void pokeByteValue (addressType location, valueType *value);
|
||||||
|
extern void pokeWordValue (addressType location, valueType *value);
|
||||||
|
extern void pokeLongValue (addressType location, valueType *value);
|
||||||
|
extern void pokeRelativeByteValue (addressType location, valueType *value);
|
||||||
|
extern void pokeRelativeWordValue (addressType location, valueType *value);
|
||||||
|
extern void pushBinding (symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage);
|
||||||
|
|
||||||
|
bool
|
||||||
|
absoluteValue(valueType *address)
|
||||||
{
|
{
|
||||||
return(address->kindOfValue == ABSOLUTE_VALUE);
|
return(address->kindOfValue == ABSOLUTE_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
addAttributeToSymbol(symbol, attribute)
|
addAttributeToSymbol(symbolTableEntryType *symbol, symbolAttributesType attribute)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
symbolAttributesType attribute;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getBaseContext();
|
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
context = getBaseContext(symbol);
|
context = getBaseContext(symbol);
|
||||||
if (context != NULL)
|
if (context != NULL)
|
||||||
|
@ -66,8 +82,7 @@ addAttributeToSymbol(symbol, attribute)
|
||||||
}
|
}
|
||||||
|
|
||||||
addressType
|
addressType
|
||||||
addressValue(value)
|
addressValue(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
if (value->kindOfValue==STRING_VALUE ||
|
if (value->kindOfValue==STRING_VALUE ||
|
||||||
value->kindOfValue==CONDITION_VALUE ||
|
value->kindOfValue==CONDITION_VALUE ||
|
||||||
|
@ -78,9 +93,7 @@ addressValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueKindType
|
valueKindType
|
||||||
addValueKind(leftOperand, rightOperand)
|
addValueKind(valueType *leftOperand, valueType *rightOperand)
|
||||||
valueType *leftOperand;
|
|
||||||
valueType *rightOperand;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'valueKindType'. */
|
enumerated type 'valueKindType'. */
|
||||||
|
@ -211,15 +224,13 @@ addValueKind(leftOperand, rightOperand)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
alreadyDefined(context)
|
alreadyDefined(symbolInContextType *context)
|
||||||
symbolInContextType *context;
|
|
||||||
{
|
{
|
||||||
return((context->attributes & DEFINED_VARIABLE_ATT) != 0);
|
return((context->attributes & DEFINED_VARIABLE_ATT) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
booleanTest(expression)
|
booleanTest(expressionType *expression)
|
||||||
expressionType *expression;
|
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
valueType *expressionResult;
|
valueType *expressionResult;
|
||||||
|
@ -242,8 +253,7 @@ booleanTest(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
countArguments(function)
|
countArguments(functionDefinitionType *function)
|
||||||
functionDefinitionType *function;
|
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
argumentDefinitionListType *arguments;
|
argumentDefinitionListType *arguments;
|
||||||
|
@ -258,8 +268,7 @@ countArguments(function)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
countParameters(parameterList)
|
countParameters(operandListType *parameterList)
|
||||||
operandListType *parameterList;
|
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -272,9 +281,7 @@ countParameters(parameterList)
|
||||||
}
|
}
|
||||||
|
|
||||||
arrayType *
|
arrayType *
|
||||||
allocArray(size, contentsPtr)
|
allocArray(int size, valueType ***contentsPtr)
|
||||||
int size;
|
|
||||||
valueType ***contentsPtr;
|
|
||||||
{
|
{
|
||||||
arrayType *result;
|
arrayType *result;
|
||||||
int i;
|
int i;
|
||||||
|
@ -289,9 +296,7 @@ allocArray(size, contentsPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
createArray(dimension, initializers)
|
createArray(expressionType *dimension, expressionListType *initializers)
|
||||||
expressionType *dimension;
|
|
||||||
expressionListType *initializers;
|
|
||||||
{
|
{
|
||||||
int initCount;
|
int initCount;
|
||||||
valueType *arraySizeValue;
|
valueType *arraySizeValue;
|
||||||
|
@ -300,7 +305,7 @@ createArray(dimension, initializers)
|
||||||
arrayType *result;
|
arrayType *result;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
initCount = expressionListLength(initializers);
|
initCount = expressionListLength(initializers);
|
||||||
if ((int)dimension == -1) {
|
if ((int)dimension == -1) {
|
||||||
|
@ -327,8 +332,7 @@ createArray(dimension, initializers)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
decrementable(value)
|
decrementable(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'valueKindType'. */
|
enumerated type 'valueKindType'. */
|
||||||
|
@ -358,8 +362,7 @@ decrementable(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
expressionListLength(expressionList)
|
expressionListLength(expressionListType *expressionList)
|
||||||
expressionListType *expressionList;
|
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -372,11 +375,10 @@ expressionListLength(expressionList)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
fieldValue(symbol)
|
fieldValue(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
valueType *value;
|
valueType *value;
|
||||||
valueType *evaluateIdentifier();
|
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
||||||
|
|
||||||
value = evaluateIdentifier(symbol, FALSE, NO_FIXUP);
|
value = evaluateIdentifier(symbol, FALSE, NO_FIXUP);
|
||||||
if (value->kindOfValue != FIELD_VALUE) {
|
if (value->kindOfValue != FIELD_VALUE) {
|
||||||
|
@ -388,8 +390,7 @@ fieldValue(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
incrementable(value)
|
incrementable(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'valueKindType'. */
|
enumerated type 'valueKindType'. */
|
||||||
|
@ -419,8 +420,7 @@ incrementable(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
intValue(value)
|
intValue(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
if (value->kindOfValue != ABSOLUTE_VALUE) {
|
if (value->kindOfValue != ABSOLUTE_VALUE) {
|
||||||
error(VALUE_IS_NOT_AN_INT_ERROR);
|
error(VALUE_IS_NOT_AN_INT_ERROR);
|
||||||
|
@ -431,8 +431,7 @@ intValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isAssignable(context)
|
isAssignable(symbolInContextType *context)
|
||||||
symbolInContextType *context;
|
|
||||||
{
|
{
|
||||||
return( context->usage==ARGUMENT_SYMBOL ||
|
return( context->usage==ARGUMENT_SYMBOL ||
|
||||||
context->usage==VARIABLE_SYMBOL ||
|
context->usage==VARIABLE_SYMBOL ||
|
||||||
|
@ -440,15 +439,13 @@ isAssignable(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isBuiltInFunction(context)
|
isBuiltInFunction(symbolInContextType *context)
|
||||||
symbolInContextType *context;
|
|
||||||
{
|
{
|
||||||
return(context!=NULL && context->usage==BUILT_IN_FUNCTION_SYMBOL);
|
return(context!=NULL && context->usage==BUILT_IN_FUNCTION_SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isDefinable(context)
|
isDefinable(symbolInContextType *context)
|
||||||
symbolInContextType *context;
|
|
||||||
{
|
{
|
||||||
return( context->usage==DEFINE_SYMBOL ||
|
return( context->usage==DEFINE_SYMBOL ||
|
||||||
context->usage==DEAD_SYMBOL ||
|
context->usage==DEAD_SYMBOL ||
|
||||||
|
@ -457,12 +454,11 @@ isDefinable(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isExternal(symbol)
|
isExternal(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getBaseContext();
|
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
context = getBaseContext(symbol);
|
context = getBaseContext(symbol);
|
||||||
return (context!=NULL && (context->attributes & GLOBAL_ATT)!=0 &&
|
return (context!=NULL && (context->attributes & GLOBAL_ATT)!=0 &&
|
||||||
|
@ -470,8 +466,7 @@ isExternal(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isFailure(value)
|
isFailure(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
@ -480,15 +475,13 @@ isFailure(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isFunction(context)
|
isFunction(symbolInContextType *context)
|
||||||
symbolInContextType *context;
|
|
||||||
{
|
{
|
||||||
return(context!=NULL && context->usage==FUNCTION_SYMBOL);
|
return(context!=NULL && context->usage==FUNCTION_SYMBOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isLastStatementInBlock(statement)
|
isLastStatementInBlock(statementType *statement)
|
||||||
statementType *statement;
|
|
||||||
{
|
{
|
||||||
statement = statement->nextStatement;
|
statement = statement->nextStatement;
|
||||||
while (statement != NULL) {
|
while (statement != NULL) {
|
||||||
|
@ -521,8 +514,7 @@ isLastStatementInBlock(statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isLogicalOp(op)
|
isLogicalOp(int op)
|
||||||
int op;
|
|
||||||
{
|
{
|
||||||
return (op==EQUAL_TO || op==GREATER_THAN || op==
|
return (op==EQUAL_TO || op==GREATER_THAN || op==
|
||||||
GREATER_THAN_OR_EQUAL_TO || op==LESS_THAN || op==
|
GREATER_THAN_OR_EQUAL_TO || op==LESS_THAN || op==
|
||||||
|
@ -531,8 +523,7 @@ isLogicalOp(op)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isPotentialVariable(context)
|
isPotentialVariable(symbolInContextType *context)
|
||||||
symbolInContextType *context;
|
|
||||||
{
|
{
|
||||||
return( context->usage == VARIABLE_SYMBOL ||
|
return( context->usage == VARIABLE_SYMBOL ||
|
||||||
context->usage == DEAD_SYMBOL ||
|
context->usage == DEAD_SYMBOL ||
|
||||||
|
@ -540,33 +531,26 @@ isPotentialVariable(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isUndefined(value)
|
isUndefined(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
return(value==NULL || value->kindOfValue==UNDEFINED_VALUE);
|
return(value==NULL || value->kindOfValue==UNDEFINED_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isUsable(value)
|
isUsable(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE &&
|
return(value!=NULL && value->kindOfValue!=UNDEFINED_VALUE &&
|
||||||
value->kindOfValue!=FAIL);
|
value->kindOfValue!=FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
logicalXOR(int1, int2)
|
logicalXOR(int int1, int int2)
|
||||||
int int1;
|
|
||||||
int int2;
|
|
||||||
{
|
{
|
||||||
return((int1 && !int2) || (int2 && !int1));
|
return((int1 && !int2) || (int2 && !int1));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
newValue(kindOfValue, value, addressMode)
|
newValue(valueKindType kindOfValue, int value, operandKindType addressMode)
|
||||||
valueKindType kindOfValue;
|
|
||||||
int value;
|
|
||||||
operandKindType addressMode;
|
|
||||||
{
|
{
|
||||||
valueType *result;
|
valueType *result;
|
||||||
|
|
||||||
|
@ -578,9 +562,7 @@ newValue(kindOfValue, value, addressMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueKindType
|
valueKindType
|
||||||
opValueKind(leftOperand, rightOperand)
|
opValueKind(valueType *leftOperand, valueType *rightOperand)
|
||||||
valueType *leftOperand;
|
|
||||||
valueType *rightOperand;
|
|
||||||
{
|
{
|
||||||
if (leftOperand->kindOfValue==ABSOLUTE_VALUE && rightOperand->
|
if (leftOperand->kindOfValue==ABSOLUTE_VALUE && rightOperand->
|
||||||
kindOfValue==ABSOLUTE_VALUE)
|
kindOfValue==ABSOLUTE_VALUE)
|
||||||
|
@ -607,17 +589,14 @@ opValueKind(leftOperand, rightOperand)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
relocatableValue(address)
|
relocatableValue(valueType *address)
|
||||||
valueType *address;
|
|
||||||
{
|
{
|
||||||
return( address->kindOfValue==DATA_VALUE ||
|
return( address->kindOfValue==DATA_VALUE ||
|
||||||
address->kindOfValue==RELOCATABLE_VALUE );
|
address->kindOfValue==RELOCATABLE_VALUE );
|
||||||
}
|
}
|
||||||
|
|
||||||
valueKindType
|
valueKindType
|
||||||
selectValueKind(leftOperand, rightOperand)
|
selectValueKind(valueType *leftOperand, valueType *rightOperand)
|
||||||
valueType *leftOperand;
|
|
||||||
valueType *rightOperand;
|
|
||||||
{
|
{
|
||||||
if (rightOperand->kindOfValue!=FIELD_VALUE ||
|
if (rightOperand->kindOfValue!=FIELD_VALUE ||
|
||||||
(leftOperand->kindOfValue!=ABSOLUTE_VALUE &&
|
(leftOperand->kindOfValue!=ABSOLUTE_VALUE &&
|
||||||
|
@ -629,9 +608,7 @@ selectValueKind(leftOperand, rightOperand)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueKindType
|
valueKindType
|
||||||
subValueKind(leftOperand, rightOperand)
|
subValueKind(valueType *leftOperand, valueType *rightOperand)
|
||||||
valueType *leftOperand;
|
|
||||||
valueType *rightOperand;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'valueKindType'. */
|
enumerated type 'valueKindType'. */
|
||||||
|
@ -762,25 +739,22 @@ subValueKind(leftOperand, rightOperand)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
swab(i)
|
swab(int i)
|
||||||
int i;
|
|
||||||
{
|
{
|
||||||
return(((i & 0xFF) << 8) | ((i & 0xFF00) >> 8));
|
return(((i & 0xFF) << 8) | ((i & 0xFF00) >> 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType *
|
valueType *
|
||||||
swabValue(value)
|
swabValue(valueType *value)
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
valueType *newValue();
|
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
||||||
|
|
||||||
return(newValue(value->kindOfValue, swab(value->value), value->
|
return(newValue(value->kindOfValue, swab(value->value), value->
|
||||||
addressMode));
|
addressMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
valueKindType
|
valueKindType
|
||||||
unopValueKind(operand)
|
unopValueKind(valueType *operand)
|
||||||
valueType *operand;
|
|
||||||
{
|
{
|
||||||
return(operand->kindOfValue==ABSOLUTE_VALUE || operand->kindOfValue==
|
return(operand->kindOfValue==ABSOLUTE_VALUE || operand->kindOfValue==
|
||||||
UNDEFINED_VALUE || operand->kindOfValue==RELOCATABLE_VALUE ?
|
UNDEFINED_VALUE || operand->kindOfValue==RELOCATABLE_VALUE ?
|
||||||
|
@ -788,14 +762,12 @@ unopValueKind(operand)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
valueField(symbol, value)
|
valueField(symbolTableEntryType *symbol, valueType *value)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *workingContext;
|
symbolInContextType *workingContext;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
symbolTableEntryType *effectiveSymbol();
|
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
||||||
|
|
||||||
symbol = effectiveSymbol(symbol, &workingContext);
|
symbol = effectiveSymbol(symbol, &workingContext);
|
||||||
expand(moreLabel("%s:", symbol->symbolName));
|
expand(moreLabel("%s:", symbol->symbolName));
|
||||||
|
@ -815,15 +787,13 @@ valueField(symbol, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
valueLabel(symbol, value)
|
valueLabel(symbolTableEntryType *symbol, valueType *value)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
valueType *value;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *workingContext;
|
symbolInContextType *workingContext;
|
||||||
|
|
||||||
symbolTableEntryType *generateLocalLabel();
|
symbolTableEntryType *generateLocalLabel(symbolTableEntryType *symbol);
|
||||||
symbolInContextType *getBaseContext();
|
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
|
||||||
symbolTableEntryType *effectiveSymbol();
|
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
||||||
|
|
||||||
symbol = effectiveSymbol(symbol, &workingContext);
|
symbol = effectiveSymbol(symbol, &workingContext);
|
||||||
expand(moreLabel("%s:", symbol->symbolName));
|
expand(moreLabel("%s:", symbol->symbolName));
|
||||||
|
@ -864,16 +834,11 @@ valueLabel(symbol, value)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
createFixup(expression, location, kindOfFixup, codeMode, whichFixup)
|
createFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup, codeBufferKindType codeMode, int whichFixup)
|
||||||
expressionType *expression;
|
|
||||||
addressType location;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
codeBufferKindType codeMode;
|
|
||||||
int whichFixup;
|
|
||||||
{
|
{
|
||||||
fixupListType *newFixup;
|
fixupListType *newFixup;
|
||||||
|
|
||||||
expressionType *generateFixupExpression();
|
expressionType *generateFixupExpression(expressionType *expression);
|
||||||
|
|
||||||
if (debug || emitPrint)
|
if (debug || emitPrint)
|
||||||
printCreateFixup(expression, location, kindOfFixup);
|
printCreateFixup(expression, location, kindOfFixup);
|
||||||
|
@ -902,10 +867,10 @@ createFixup(expression, location, kindOfFixup, codeMode, whichFixup)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
finishUp()
|
finishUp(void)
|
||||||
{
|
{
|
||||||
void performFixups();
|
void performFixups(fixupListType *fixups);
|
||||||
void performStartAddressFixup();
|
void performStartAddressFixup(void);
|
||||||
|
|
||||||
if (listingOn)
|
if (listingOn)
|
||||||
terminateListingFiles();
|
terminateListingFiles();
|
||||||
|
@ -936,7 +901,7 @@ isReferenceToRemember(reference)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
noteAnonymousReference()
|
noteAnonymousReference(void)
|
||||||
{
|
{
|
||||||
expressionReferenceListType *newReference;
|
expressionReferenceListType *newReference;
|
||||||
|
|
||||||
|
@ -958,11 +923,7 @@ noteAnonymousReference()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
noteReference(expression, kindOfFixup, location, codeMode)
|
noteReference(expressionType *expression, fixupKindType kindOfFixup, addressType location, codeBufferKindType codeMode)
|
||||||
expressionType *expression;
|
|
||||||
fixupKindType kindOfFixup;
|
|
||||||
addressType location;
|
|
||||||
codeBufferKindType codeMode;
|
|
||||||
{
|
{
|
||||||
expressionReferenceListType *newReference;
|
expressionReferenceListType *newReference;
|
||||||
|
|
||||||
|
@ -1010,8 +971,7 @@ noteReference(expression, kindOfFixup, location, codeMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
performFixups(fixups)
|
performFixups(fixupListType *fixups)
|
||||||
fixupListType *fixups;
|
|
||||||
{
|
{
|
||||||
valueType *valueToPoke;
|
valueType *valueToPoke;
|
||||||
|
|
||||||
|
@ -1072,11 +1032,11 @@ performFixups(fixups)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
performStartAddressFixup()
|
performStartAddressFixup(void)
|
||||||
{
|
{
|
||||||
expressionType *startAddressExpression;
|
expressionType *startAddressExpression;
|
||||||
|
|
||||||
expressionType *generateFixupExpression();
|
expressionType *generateFixupExpression(expressionType *expression);
|
||||||
|
|
||||||
startAddressExpression = (expressionType *)startAddress;
|
startAddressExpression = (expressionType *)startAddress;
|
||||||
startAddress = evaluateExpression(startAddressExpression,NO_FIXUP_OK);
|
startAddress = evaluateExpression(startAddressExpression,NO_FIXUP_OK);
|
||||||
|
@ -1094,9 +1054,7 @@ performStartAddressFixup()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
putFixupsHere(kindOfFixupsToPut, whichFixup)
|
putFixupsHere(fixupKindType kindOfFixupsToPut, int whichFixup)
|
||||||
fixupKindType kindOfFixupsToPut;
|
|
||||||
int whichFixup;
|
|
||||||
{
|
{
|
||||||
int location;
|
int location;
|
||||||
|
|
||||||
|
@ -1187,8 +1145,7 @@ putReferencesHere(kindOfReferencesToPut, whichReference)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
addNewLocalVariable(symbol)
|
addNewLocalVariable(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
identifierListType *newLocalVariable;
|
identifierListType *newLocalVariable;
|
||||||
|
|
||||||
|
@ -1199,16 +1156,14 @@ addNewLocalVariable(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolTableEntryType *
|
symbolTableEntryType *
|
||||||
effectiveSymbol(symbol, assignmentTargetContext)
|
effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
symbolInContextType **assignmentTargetContext;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
operandType *operand;
|
operandType *operand;
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
context = getWorkingContext(symbol);
|
context = getWorkingContext(symbol);
|
||||||
saveEnvironment = currentEnvironment;
|
saveEnvironment = currentEnvironment;
|
||||||
|
@ -1236,18 +1191,16 @@ effectiveSymbol(symbol, assignmentTargetContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolTableEntryType *
|
symbolTableEntryType *
|
||||||
generateLocalLabel(symbol)
|
generateLocalLabel(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
stringType *localLabelString();
|
stringType *localLabelString(symbolTableEntryType *symbol);
|
||||||
symbolTableEntryType *lookupOrEnterSymbol();
|
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
||||||
|
|
||||||
return(lookupOrEnterSymbol(localLabelString(symbol), LABEL_SYMBOL));
|
return(lookupOrEnterSymbol(localLabelString(symbol), LABEL_SYMBOL));
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolInContextType *
|
symbolInContextType *
|
||||||
getBaseContext(identifier)
|
getBaseContext(symbolTableEntryType *identifier)
|
||||||
symbolTableEntryType *identifier;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *result;
|
symbolInContextType *result;
|
||||||
|
|
||||||
|
@ -1259,8 +1212,7 @@ getBaseContext(identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
symbolInContextType *
|
symbolInContextType *
|
||||||
getWorkingContext(identifier)
|
getWorkingContext(symbolTableEntryType *identifier)
|
||||||
symbolTableEntryType *identifier;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *result;
|
symbolInContextType *result;
|
||||||
|
|
||||||
|
@ -1274,13 +1226,12 @@ getWorkingContext(identifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
stringType *
|
stringType *
|
||||||
localLabelString(symbol)
|
localLabelString(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
#define TEMP_SYMBOL_SIZE_LIMIT 200
|
#define TEMP_SYMBOL_SIZE_LIMIT 200
|
||||||
char nameUnderConstruction[TEMP_SYMBOL_SIZE_LIMIT];
|
char nameUnderConstruction[TEMP_SYMBOL_SIZE_LIMIT];
|
||||||
|
|
||||||
stringType *saveString();
|
stringType *saveString(char *s);
|
||||||
|
|
||||||
sprintf(nameUnderConstruction, "_%d_", localLabelTagValue(symbol));
|
sprintf(nameUnderConstruction, "_%d_", localLabelTagValue(symbol));
|
||||||
strncat(nameUnderConstruction, &(symbName(symbol)[1]),
|
strncat(nameUnderConstruction, &(symbName(symbol)[1]),
|
||||||
|
@ -1289,13 +1240,12 @@ localLabelString(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
localLabelTagValue(symbol)
|
localLabelTagValue(symbolTableEntryType *symbol)
|
||||||
symbolTableEntryType *symbol;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
void addNewLocalVariable();
|
void addNewLocalVariable(symbolTableEntryType *symbol);
|
||||||
|
|
||||||
context = getWorkingContext(symbol);
|
context = getWorkingContext(symbol);
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
|
@ -1311,12 +1261,10 @@ localLabelTagValue(symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
addBreak(kind, data)
|
addBreak(codeBreakKindType kind, int data)
|
||||||
codeBreakKindType kind;
|
|
||||||
int data;
|
|
||||||
{
|
{
|
||||||
codeBreakType *newBreak;
|
codeBreakType *newBreak;
|
||||||
codeBreakType *buildCodeBreak();
|
codeBreakType *buildCodeBreak(codeBreakKindType kind, addressType address, int data);
|
||||||
|
|
||||||
newBreak = buildCodeBreak(kind, currentLocationCounter.value, data);
|
newBreak = buildCodeBreak(kind, currentLocationCounter.value, data);
|
||||||
if (codeBreakList == NULL) {
|
if (codeBreakList == NULL) {
|
||||||
|
@ -1328,11 +1276,9 @@ addBreak(kind, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
reserveAbsolute(startAddress, blockSize)
|
reserveAbsolute(addressType startAddress, int blockSize)
|
||||||
addressType startAddress;
|
|
||||||
int blockSize;
|
|
||||||
{
|
{
|
||||||
reservationListType *buildReservation();
|
reservationListType *buildReservation(addressType startAddress, int blockSize, reservationListType *nextReservation);
|
||||||
|
|
||||||
if (reservationList != NULL && reservationList->startAddress +
|
if (reservationList != NULL && reservationList->startAddress +
|
||||||
reservationList->blockSize == startAddress)
|
reservationList->blockSize == startAddress)
|
||||||
|
@ -1343,8 +1289,7 @@ reserveAbsolute(startAddress, blockSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
listableStatement(kind)
|
listableStatement(statementKindType kind)
|
||||||
statementKindType kind;
|
|
||||||
{
|
{
|
||||||
return( kind == ALIGN_STATEMENT || kind == BLOCK_STATEMENT ||
|
return( kind == ALIGN_STATEMENT || kind == BLOCK_STATEMENT ||
|
||||||
kind == BYTE_STATEMENT || kind == CONSTRAIN_STATEMENT ||
|
kind == BYTE_STATEMENT || kind == CONSTRAIN_STATEMENT ||
|
||||||
|
|
|
@ -44,11 +44,11 @@ void valueLabel(symbolTableEntryType *symbol, valueType *value);
|
||||||
|
|
||||||
/* Fixups and references */
|
/* Fixups and references */
|
||||||
void createFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup, codeBufferKindType codeMode, int whichFixup);
|
void createFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup, codeBufferKindType codeMode, int whichFixup);
|
||||||
void finishUp();
|
void finishUp(void);
|
||||||
void noteAnonymousReference();
|
void noteAnonymousReference(void);
|
||||||
void noteReference(expressionType *expression, fixupKindType kindOfFixup, addressType location, codeBufferKindType codeMode);
|
void noteReference(expressionType *expression, fixupKindType kindOfFixup, addressType location, codeBufferKindType codeMode);
|
||||||
void performFixups(fixupListType *fixups);
|
void performFixups(fixupListType *fixups);
|
||||||
void performStartAddressFixup();
|
void performStartAddressFixup(void);
|
||||||
void putFixupsHere(fixupKindType kindOfFixupsToPut, int whichFixup);
|
void putFixupsHere(fixupKindType kindOfFixupsToPut, int whichFixup);
|
||||||
|
|
||||||
/* Contexts and dynamic symbol creation */
|
/* Contexts and dynamic symbol creation */
|
||||||
|
|
|
@ -54,28 +54,63 @@ bool nullStatementFlag = FALSE;
|
||||||
#define expansionOff() {saveExpansion=expandMacros; expandMacros=FALSE;}
|
#define expansionOff() {saveExpansion=expandMacros; expandMacros=FALSE;}
|
||||||
#define expansionOn() expandMacros=saveExpansion;
|
#define expansionOn() expandMacros=saveExpansion;
|
||||||
|
|
||||||
void
|
|
||||||
assembleBlock(block)
|
extern void error (errorType theError, ...);
|
||||||
blockType *block;
|
extern void moreText (char *format, ...);
|
||||||
|
extern void expandOperands (int op);
|
||||||
|
extern void endLine (void);
|
||||||
|
extern int bindMacroArguments (argumentDefinitionListType *argumentList, operandListType *parameterList, stringType *macroName);
|
||||||
|
extern void unbindArguments (argumentDefinitionListType *argumentList, int numberToUnbind);
|
||||||
|
extern void unbindLocalVariables (identifierListType *identifierList);
|
||||||
|
extern void expandExpression (char *toBuffer, char **toBufferPtr);
|
||||||
|
extern void emitByte (byte byteValue);
|
||||||
|
extern void emitString (stringType *string);
|
||||||
|
extern void emitByteValue (valueType *byteValue);
|
||||||
|
extern void startLineMarked (void);
|
||||||
|
extern void tabIndent (void);
|
||||||
|
extern void emitWordValue (valueType *wordValue);
|
||||||
|
extern void reincarnateSymbol (symbolInContextType *context, symbolUsageKindType newUsage);
|
||||||
|
extern char *conditionString (conditionType condition);
|
||||||
|
extern char *usageString (symbolUsageKindType usageKind);
|
||||||
|
extern symbolTableEntryType *lookupOrEnterSymbol (stringType *s, symbolUsageKindType kind);
|
||||||
|
extern bool isDefined (valueType *value);
|
||||||
|
extern void fixupBranch (valueType *location, valueType target);
|
||||||
|
extern void fixupJump (simpleFixupListType *locations, valueType target);
|
||||||
|
extern void pushInputFileStack (stringType *fileName);
|
||||||
|
extern void saveIndexForListing (statementKindType kindOfStatement, int cumulativeLineNumber);
|
||||||
|
extern void startLine (void);
|
||||||
|
extern void expandLabel (void);
|
||||||
|
extern void emitLongValue (valueType *longValue);
|
||||||
|
extern void pushBinding (symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage);
|
||||||
|
extern void saveEndMifForListing (int cumulativeLineNumber);
|
||||||
|
extern char *valueKindString (valueKindType valueKind);
|
||||||
|
extern bool strcmplc (char *s1, char *s2);
|
||||||
|
extern void warning (errorType theError, ...);
|
||||||
|
extern expressionType *generateFixupExpression (expressionType *expression);
|
||||||
|
extern void instantiateStruct (structStatementBodyType *structStatement);
|
||||||
|
extern void assembleStructDefinition (structStatementBodyType *structStatement);
|
||||||
|
extern void purgeSymbol (symbolTableEntryType *symbol);
|
||||||
|
extern bool labeledLine (void);
|
||||||
|
extern void flushExpressionString (void);
|
||||||
|
extern void freeStatement (statementType *statement);
|
||||||
|
extern void printStatement (statementType *statement);
|
||||||
|
|
||||||
|
void
|
||||||
|
assembleBlock(blockType *block)
|
||||||
{
|
{
|
||||||
nullAssemble(block);
|
nullAssemble(block);
|
||||||
assembleStatement(block, FALSE, NULL);
|
assembleStatement(block, FALSE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleFixupListType *
|
simpleFixupListType *
|
||||||
assembleBlockInsideIf(block, ongoingFixupList)
|
assembleBlockInsideIf(blockType *block, simpleFixupListType *ongoingFixupList)
|
||||||
blockType *block;
|
|
||||||
simpleFixupListType *ongoingFixupList;
|
|
||||||
{
|
{
|
||||||
nullAssembleNULL(block);
|
nullAssembleNULL(block);
|
||||||
return(assembleStatement(block, TRUE, ongoingFixupList));
|
return(assembleStatement(block, TRUE, ongoingFixupList));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
operandCheck(opcode, numberOfOperands, evaluatedOperands)
|
operandCheck(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
int numberOfOperands;
|
|
||||||
valueType *evaluatedOperands[];
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -91,9 +126,7 @@ operandCheck(opcode, numberOfOperands, evaluatedOperands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMachineInstruction(opcode, operands)
|
assembleMachineInstruction(opcodeTableEntryType *opcode, operandListType *operands)
|
||||||
opcodeTableEntryType *opcode;
|
|
||||||
operandListType *operands;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int op;
|
int op;
|
||||||
|
@ -140,9 +173,7 @@ assembleMachineInstruction(opcode, operands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMacro(macroInstruction, operands)
|
assembleMacro(macroTableEntryType *macroInstruction, operandListType *operands)
|
||||||
macroTableEntryType *macroInstruction;
|
|
||||||
operandListType *operands;
|
|
||||||
{
|
{
|
||||||
int numberBound;
|
int numberBound;
|
||||||
identifierListType *savedLocalVariableList;
|
identifierListType *savedLocalVariableList;
|
||||||
|
@ -186,8 +217,7 @@ assembleMacro(macroInstruction, operands)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleAlignStatement(alignStatement)
|
assembleAlignStatement(alignStatementBodyType *alignStatement)
|
||||||
alignStatementBodyType *alignStatement;
|
|
||||||
{
|
{
|
||||||
int alignment;
|
int alignment;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
@ -218,8 +248,7 @@ assembleAlignStatement(alignStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleAssertStatement(assertStatement)
|
assembleAssertStatement(assertStatementBodyType *assertStatement)
|
||||||
assertStatementBodyType *assertStatement;
|
|
||||||
{
|
{
|
||||||
valueType *test;
|
valueType *test;
|
||||||
valueType *message;
|
valueType *message;
|
||||||
|
@ -249,8 +278,7 @@ assembleAssertStatement(assertStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleBlockStatement(blockStatement)
|
assembleBlockStatement(blockStatementBodyType *blockStatement)
|
||||||
blockStatementBodyType *blockStatement;
|
|
||||||
{
|
{
|
||||||
valueType *blockIncrement;
|
valueType *blockIncrement;
|
||||||
int blockSize;
|
int blockSize;
|
||||||
|
@ -286,8 +314,7 @@ assembleBlockStatement(blockStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleByteStatement(byteStatement)
|
assembleByteStatement(byteStatementBodyType *byteStatement)
|
||||||
byteStatementBodyType *byteStatement;
|
|
||||||
{
|
{
|
||||||
valueType *byteValue;
|
valueType *byteValue;
|
||||||
|
|
||||||
|
@ -311,8 +338,7 @@ assembleByteStatement(byteStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleConstrainStatement(constrainStatement)
|
assembleConstrainStatement(constrainStatementBodyType *constrainStatement)
|
||||||
constrainStatementBodyType *constrainStatement;
|
|
||||||
{
|
{
|
||||||
valueType *constraintValue;
|
valueType *constraintValue;
|
||||||
int constraint;
|
int constraint;
|
||||||
|
@ -355,8 +381,7 @@ assembleConstrainStatement(constrainStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleDbyteStatement(dbyteStatement)
|
assembleDbyteStatement(dbyteStatementBodyType *dbyteStatement)
|
||||||
dbyteStatementBodyType *dbyteStatement;
|
|
||||||
{
|
{
|
||||||
valueType *wordValue;
|
valueType *wordValue;
|
||||||
|
|
||||||
|
@ -376,8 +401,7 @@ assembleDbyteStatement(dbyteStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleDefineStatement(defineStatement)
|
assembleDefineStatement(defineStatementBodyType *defineStatement)
|
||||||
defineStatementBodyType *defineStatement;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *symbolToDefine;
|
symbolTableEntryType *symbolToDefine;
|
||||||
symbolInContextType *contextToDefine;
|
symbolInContextType *contextToDefine;
|
||||||
|
@ -417,8 +441,7 @@ assembleDefineStatement(defineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleDoUntilStatement(doUntilStatement)
|
assembleDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
|
||||||
doUntilStatementBodyType *doUntilStatement;
|
|
||||||
{
|
{
|
||||||
valueType topOfLoop;
|
valueType topOfLoop;
|
||||||
|
|
||||||
|
@ -442,8 +465,7 @@ assembleDoUntilStatement(doUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleDoWhileStatement(doWhileStatement)
|
assembleDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
|
||||||
doWhileStatementBodyType *doWhileStatement;
|
|
||||||
{
|
{
|
||||||
valueType topOfLoop;
|
valueType topOfLoop;
|
||||||
|
|
||||||
|
@ -467,8 +489,7 @@ assembleDoWhileStatement(doWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleExternStatement(externStatement)
|
assembleExternStatement(externStatementBodyType *externStatement)
|
||||||
externStatementBodyType *externStatement;
|
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
symbolTableEntryType *theSymbol;
|
symbolTableEntryType *theSymbol;
|
||||||
|
@ -496,8 +517,7 @@ assembleExternStatement(externStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleFreturnStatement(freturnStatement)
|
assembleFreturnStatement(freturnStatementBodyType *freturnStatement)
|
||||||
freturnStatementBodyType *freturnStatement;
|
|
||||||
{
|
{
|
||||||
freturnExit = TRUE;
|
freturnExit = TRUE;
|
||||||
resultOfLastFunctionCall = evaluateExpression(freturnStatement,
|
resultOfLastFunctionCall = evaluateExpression(freturnStatement,
|
||||||
|
@ -505,8 +525,7 @@ assembleFreturnStatement(freturnStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleFunctionStatement(functionStatement)
|
assembleFunctionStatement(functionStatementBodyType *functionStatement)
|
||||||
functionStatementBodyType *functionStatement;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *newFunctionSymbol;
|
symbolTableEntryType *newFunctionSymbol;
|
||||||
functionDefinitionType *newFunction;
|
functionDefinitionType *newFunction;
|
||||||
|
@ -545,8 +564,7 @@ assembleFunctionStatement(functionStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleGroupStatement(groupStatement)
|
assembleGroupStatement(blockType *groupStatement)
|
||||||
blockType *groupStatement;
|
|
||||||
{
|
{
|
||||||
expand((startLineMarked(), tabIndent(), moreText("{"), endLine(),
|
expand((startLineMarked(), tabIndent(), moreText("{"), endLine(),
|
||||||
tabCount++));
|
tabCount++));
|
||||||
|
@ -556,10 +574,7 @@ assembleGroupStatement(groupStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleFixupListType *
|
simpleFixupListType *
|
||||||
assembleIfStatement(ifStatement, terminalIf, ongoingFixupList)
|
assembleIfStatement(ifStatementBodyType *ifStatement, bool terminalIf, simpleFixupListType *ongoingFixupList)
|
||||||
ifStatementBodyType *ifStatement;
|
|
||||||
bool terminalIf;
|
|
||||||
simpleFixupListType *ongoingFixupList;
|
|
||||||
{
|
{
|
||||||
valueType fixupLocation1[COMPOUND_BRANCH_MAX];
|
valueType fixupLocation1[COMPOUND_BRANCH_MAX];
|
||||||
simpleFixupListType *fixupLocation2;
|
simpleFixupListType *fixupLocation2;
|
||||||
|
@ -609,8 +624,7 @@ assembleIfStatement(ifStatement, terminalIf, ongoingFixupList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleIfStatementOldStyle(ifStatement)
|
assembleIfStatementOldStyle(ifStatementBodyType *ifStatement)
|
||||||
ifStatementBodyType *ifStatement;
|
|
||||||
{
|
{
|
||||||
valueType fixupLocation1[COMPOUND_BRANCH_MAX];
|
valueType fixupLocation1[COMPOUND_BRANCH_MAX];
|
||||||
simpleFixupListType *fixupLocation2;
|
simpleFixupListType *fixupLocation2;
|
||||||
|
@ -642,8 +656,7 @@ assembleIfStatementOldStyle(ifStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleIncludeStatement(includeStatement)
|
assembleIncludeStatement(includeStatementBodyType *includeStatement)
|
||||||
includeStatementBodyType *includeStatement;
|
|
||||||
{
|
{
|
||||||
stringType *fileName;
|
stringType *fileName;
|
||||||
valueType *possibleFileName;
|
valueType *possibleFileName;
|
||||||
|
@ -663,9 +676,7 @@ assembleIncludeStatement(includeStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleInstructionStatement(instructionStatement, cumulativeLineNumber)
|
assembleInstructionStatement(instructionStatementBodyType *instructionStatement, int cumulativeLineNumber)
|
||||||
instructionStatementBodyType *instructionStatement;
|
|
||||||
int cumulativeLineNumber;
|
|
||||||
{
|
{
|
||||||
nullAssemble(instructionStatement);
|
nullAssemble(instructionStatement);
|
||||||
switch(instructionStatement->kindOfInstruction) {
|
switch(instructionStatement->kindOfInstruction) {
|
||||||
|
@ -695,8 +706,7 @@ assembleInstructionStatement(instructionStatement, cumulativeLineNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleLongStatement(longStatement)
|
assembleLongStatement(longStatementBodyType *longStatement)
|
||||||
longStatementBodyType *longStatement;
|
|
||||||
{
|
{
|
||||||
valueType *longValue;
|
valueType *longValue;
|
||||||
|
|
||||||
|
@ -716,8 +726,7 @@ assembleLongStatement(longStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMacroStatement(macroStatement)
|
assembleMacroStatement(macroStatementBodyType *macroStatement)
|
||||||
macroStatementBodyType *macroStatement;
|
|
||||||
{
|
{
|
||||||
macroTableEntryType *newMacro;
|
macroTableEntryType *newMacro;
|
||||||
|
|
||||||
|
@ -739,8 +748,7 @@ assembleMacroStatement(macroStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMdefineStatement(mdefineStatement)
|
assembleMdefineStatement(defineStatementBodyType *mdefineStatement)
|
||||||
defineStatementBodyType *mdefineStatement;
|
|
||||||
{
|
{
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
|
||||||
|
@ -753,8 +761,7 @@ assembleMdefineStatement(mdefineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMdoUntilStatement(mdoUntilStatement)
|
assembleMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
|
||||||
mdoUntilStatementBodyType *mdoUntilStatement;
|
|
||||||
{
|
{
|
||||||
bool saveListingOn;
|
bool saveListingOn;
|
||||||
|
|
||||||
|
@ -768,8 +775,7 @@ assembleMdoUntilStatement(mdoUntilStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMdoWhileStatement(mdoWhileStatement)
|
assembleMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
|
||||||
mdoWhileStatementBodyType *mdoWhileStatement;
|
|
||||||
{
|
{
|
||||||
bool saveListingOn;
|
bool saveListingOn;
|
||||||
|
|
||||||
|
@ -783,8 +789,7 @@ assembleMdoWhileStatement(mdoWhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMforStatement(mforStatement)
|
assembleMforStatement(mforStatementBodyType *mforStatement)
|
||||||
mforStatementBodyType *mforStatement;
|
|
||||||
{
|
{
|
||||||
bool saveListingOn;
|
bool saveListingOn;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
@ -805,9 +810,7 @@ assembleMforStatement(mforStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMifStatement(mifStatement, cumulativeLineNumber)
|
assembleMifStatement(mifStatementBodyType *mifStatement, int cumulativeLineNumber)
|
||||||
mifStatementBodyType *mifStatement;
|
|
||||||
int cumulativeLineNumber;
|
|
||||||
{
|
{
|
||||||
while (mifStatement != NULL) {
|
while (mifStatement != NULL) {
|
||||||
if (mifStatement->mifCondition == NULL) {
|
if (mifStatement->mifCondition == NULL) {
|
||||||
|
@ -826,8 +829,7 @@ assembleMifStatement(mifStatement, cumulativeLineNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMswitchStatement(mswitchStatement)
|
assembleMswitchStatement(mswitchStatementBodyType *mswitchStatement)
|
||||||
mswitchStatementBodyType *mswitchStatement;
|
|
||||||
{
|
{
|
||||||
valueType *switchValue;
|
valueType *switchValue;
|
||||||
caseListType *caseList;
|
caseListType *caseList;
|
||||||
|
@ -888,8 +890,7 @@ assembleMswitchStatement(mswitchStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMvariableStatement(mvariableStatement)
|
assembleMvariableStatement(mvariableStatementBodyType *mvariableStatement)
|
||||||
mvariableStatementBodyType *mvariableStatement;
|
|
||||||
{
|
{
|
||||||
identifierListType *newLocalVariable;
|
identifierListType *newLocalVariable;
|
||||||
int initCount;
|
int initCount;
|
||||||
|
@ -923,8 +924,7 @@ assembleMvariableStatement(mvariableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleMwhileStatement(mwhileStatement)
|
assembleMwhileStatement(mwhileStatementBodyType *mwhileStatement)
|
||||||
mwhileStatementBodyType *mwhileStatement;
|
|
||||||
{
|
{
|
||||||
bool saveListingOn;
|
bool saveListingOn;
|
||||||
|
|
||||||
|
@ -938,8 +938,7 @@ assembleMwhileStatement(mwhileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleOrgStatement(orgStatement)
|
assembleOrgStatement(orgStatementBodyType *orgStatement)
|
||||||
orgStatementBodyType *orgStatement;
|
|
||||||
{
|
{
|
||||||
valueType *orgAddress;
|
valueType *orgAddress;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
@ -967,8 +966,7 @@ assembleOrgStatement(orgStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assemblePerformStatement(performStatement)
|
assemblePerformStatement(performStatementBodyType *performStatement)
|
||||||
performStatementBodyType *performStatement;
|
|
||||||
{
|
{
|
||||||
nullAssemble(performStatement);
|
nullAssemble(performStatement);
|
||||||
sideEffectFlag = FALSE;
|
sideEffectFlag = FALSE;
|
||||||
|
@ -978,8 +976,7 @@ assemblePerformStatement(performStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleRelStatement(relStatement)
|
assembleRelStatement(relStatementBodyType *relStatement)
|
||||||
relStatementBodyType *relStatement;
|
|
||||||
{
|
{
|
||||||
targetOffset = 0;
|
targetOffset = 0;
|
||||||
if (!relocatableValue(¤tLocationCounter)) {
|
if (!relocatableValue(¤tLocationCounter)) {
|
||||||
|
@ -992,8 +989,7 @@ assembleRelStatement(relStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleStartStatement(startStatement)
|
assembleStartStatement(startStatementBodyType *startStatement)
|
||||||
startStatementBodyType *startStatement;
|
|
||||||
{
|
{
|
||||||
nullAssemble(startStatement);
|
nullAssemble(startStatement);
|
||||||
expand(moreText("start\t"));
|
expand(moreText("start\t"));
|
||||||
|
@ -1020,8 +1016,7 @@ assembleStartStatement(startStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleStringStatement(stringStatement)
|
assembleStringStatement(stringStatementBodyType *stringStatement)
|
||||||
stringStatementBodyType *stringStatement;
|
|
||||||
{
|
{
|
||||||
valueType *byteValue;
|
valueType *byteValue;
|
||||||
|
|
||||||
|
@ -1046,8 +1041,7 @@ assembleStringStatement(stringStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleStructStatement(structStatement)
|
assembleStructStatement(structStatementBodyType *structStatement)
|
||||||
structStatementBodyType *structStatement;
|
|
||||||
{
|
{
|
||||||
nullAssemble(structStatement);
|
nullAssemble(structStatement);
|
||||||
if (structStatement->structBody == NULL)
|
if (structStatement->structBody == NULL)
|
||||||
|
@ -1057,8 +1051,7 @@ assembleStructStatement(structStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleTargetStatement(targetStatement)
|
assembleTargetStatement(targetStatementBodyType *targetStatement)
|
||||||
targetStatementBodyType *targetStatement;
|
|
||||||
{
|
{
|
||||||
valueType *targetAddress;
|
valueType *targetAddress;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
@ -1081,8 +1074,7 @@ assembleTargetStatement(targetStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleUndefineStatement(undefineStatement)
|
assembleUndefineStatement(undefineStatementBodyType *undefineStatement)
|
||||||
undefineStatementBodyType *undefineStatement;
|
|
||||||
{
|
{
|
||||||
expand(moreText("undefine\t"));
|
expand(moreText("undefine\t"));
|
||||||
while (undefineStatement != NULL) {
|
while (undefineStatement != NULL) {
|
||||||
|
@ -1096,8 +1088,7 @@ assembleUndefineStatement(undefineStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleVariableStatement(variableStatement)
|
assembleVariableStatement(variableStatementBodyType *variableStatement)
|
||||||
variableStatementBodyType *variableStatement;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *newVariable;
|
symbolTableEntryType *newVariable;
|
||||||
symbolInContextType *contextForVariable;
|
symbolInContextType *contextForVariable;
|
||||||
|
@ -1143,8 +1134,7 @@ assembleVariableStatement(variableStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleWhileStatement(whileStatement)
|
assembleWhileStatement(whileStatementBodyType *whileStatement)
|
||||||
whileStatementBodyType *whileStatement;
|
|
||||||
{
|
{
|
||||||
valueType topOfLoop;
|
valueType topOfLoop;
|
||||||
valueType fixupLocation[COMPOUND_BRANCH_MAX];
|
valueType fixupLocation[COMPOUND_BRANCH_MAX];
|
||||||
|
@ -1175,8 +1165,7 @@ assembleWhileStatement(whileStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleWordStatement(wordStatement)
|
assembleWordStatement(wordStatementBodyType *wordStatement)
|
||||||
wordStatementBodyType *wordStatement;
|
|
||||||
{
|
{
|
||||||
valueType *word;
|
valueType *word;
|
||||||
|
|
||||||
|
@ -1411,8 +1400,7 @@ assembleStatementBody(kind, body, cumulativeLineNumber, worryAboutIf,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleLabelList(labelList)
|
assembleLabelList(labelListType *labelList)
|
||||||
labelListType *labelList;
|
|
||||||
{
|
{
|
||||||
while (labelList != NULL) {
|
while (labelList != NULL) {
|
||||||
if (structNestingDepth == 0)
|
if (structNestingDepth == 0)
|
||||||
|
@ -1428,10 +1416,7 @@ assembleLabelList(labelList)
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleFixupListType *
|
simpleFixupListType *
|
||||||
assembleStatement(statement, insideIf, ongoingFixupList)
|
assembleStatement(statementType *statement, bool insideIf, simpleFixupListType *ongoingFixupList)
|
||||||
statementType *statement;
|
|
||||||
bool insideIf;
|
|
||||||
simpleFixupListType *ongoingFixupList;
|
|
||||||
{
|
{
|
||||||
char *saveFileName;
|
char *saveFileName;
|
||||||
int saveLineNumber;
|
int saveLineNumber;
|
||||||
|
@ -1477,8 +1462,7 @@ assembleStatement(statement, insideIf, ongoingFixupList)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
eatStatement(statement)
|
eatStatement(statementType *statement)
|
||||||
statementType *statement;
|
|
||||||
{
|
{
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("assembling:\n");
|
printf("assembling:\n");
|
||||||
|
|
|
@ -30,10 +30,22 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
|
||||||
void
|
|
||||||
putStructFixups(base, fixups)
|
extern void botch (char *message, ...);
|
||||||
int base;
|
extern void error (errorType theError, ...);
|
||||||
fixupListType *fixups;
|
extern void moreText (char *format, ...);
|
||||||
|
extern void endLine (void);
|
||||||
|
extern void emitByte (byte byteValue);
|
||||||
|
extern bool listableStatement (statementKindType kind);
|
||||||
|
extern void startLine (void);
|
||||||
|
extern void assembleLabelList (labelListType *labelList);
|
||||||
|
extern void expandLabel (void);
|
||||||
|
extern void tabIndent (void);
|
||||||
|
extern bool assembleStatementBody (statementKindType kind, statementBodyType body, int cumulativeLineNumber, bool worryAboutIf, simpleFixupListType **ifFixupList);
|
||||||
|
extern void startLineMarked (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
putStructFixups(int base, fixupListType *fixups)
|
||||||
{
|
{
|
||||||
fixupListType *newFixup;
|
fixupListType *newFixup;
|
||||||
|
|
||||||
|
@ -54,9 +66,7 @@ putStructFixups(base, fixups)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
putStructReferences(base, references)
|
putStructReferences(int base, expressionReferenceListType *references)
|
||||||
int base;
|
|
||||||
expressionReferenceListType *references;
|
|
||||||
{
|
{
|
||||||
expressionReferenceListType *newReference;
|
expressionReferenceListType *newReference;
|
||||||
int currentMode;
|
int currentMode;
|
||||||
|
@ -80,14 +90,13 @@ putStructReferences(base, references)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
instantiateStruct(structStatement)
|
instantiateStruct(structStatementBodyType *structStatement)
|
||||||
structStatementBodyType *structStatement;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int base;
|
int base;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext();
|
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
||||||
|
|
||||||
#define structInstance ((structInstanceType *) context->value->value)
|
#define structInstance ((structInstanceType *) context->value->value)
|
||||||
|
|
||||||
|
@ -112,8 +121,7 @@ instantiateStruct(structStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
structInstanceType *
|
structInstanceType *
|
||||||
assembleStructDefinitionBody(structBody)
|
assembleStructDefinitionBody(structBodyType *structBody)
|
||||||
structBodyType *structBody;
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
simpleFixupListType *dummy;
|
simpleFixupListType *dummy;
|
||||||
|
@ -144,13 +152,12 @@ assembleStructDefinitionBody(structBody)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
assembleStructDefinition(structStatement)
|
assembleStructDefinition(structStatementBodyType *structStatement)
|
||||||
structStatementBodyType *structStatement;
|
|
||||||
{
|
{
|
||||||
symbolTableEntryType *name;
|
symbolTableEntryType *name;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolTableEntryType *effectiveSymbol();
|
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
||||||
|
|
||||||
name = effectiveSymbol(structStatement->structName, &context);
|
name = effectiveSymbol(structStatement->structName, &context);
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
|
|
|
@ -34,8 +34,7 @@
|
||||||
|
|
||||||
/* conditionString similarly deals with condition codes */
|
/* conditionString similarly deals with condition codes */
|
||||||
char *
|
char *
|
||||||
conditionString(condition)
|
conditionString(conditionType condition)
|
||||||
conditionType condition;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the definition of the
|
/* This table MUST be maintained congruently with the definition of the
|
||||||
enumerated type 'conditionType' */
|
enumerated type 'conditionType' */
|
||||||
|
@ -67,8 +66,7 @@ conditionString(condition)
|
||||||
/* tokenString similarly deals with parser tokens */
|
/* tokenString similarly deals with parser tokens */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
tokenString(token)
|
tokenString(int token)
|
||||||
int token;
|
|
||||||
{
|
{
|
||||||
/* This table MUST be maintained congruently with the token definitions in
|
/* This table MUST be maintained congruently with the token definitions in
|
||||||
the file 'y.tab.h' as output by yacc. */
|
the file 'y.tab.h' as output by yacc. */
|
||||||
|
|
Loading…
Reference in New Issue