Move function declarations out of the .c files and use the generated .h files instead
This commit is contained in:
parent
a98186c8f5
commit
0b99475ead
|
@ -30,6 +30,10 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "emitStuff.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
#define operand (evaluatedOperands[0])
|
#define operand (evaluatedOperands[0])
|
||||||
#define address (evaluatedOperands[0])->value
|
#define address (evaluatedOperands[0])->value
|
||||||
|
@ -45,17 +49,6 @@
|
||||||
and operand.
|
and operand.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
bool isByteAddress (valueType *value);
|
|
||||||
bool isDefined (valueType *value);
|
|
||||||
extern void emitByte (byte byteValue);
|
|
||||||
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
|
void
|
||||||
actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,15 +32,12 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
#include "lookups.h"
|
||||||
char *saveString(char *s);
|
#include "parserMisc.h"
|
||||||
|
|
||||||
/* Generic routine to create statement nodes */
|
/* Generic routine to create statement nodes */
|
||||||
|
|
||||||
extern void botch (char *message, ...);
|
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
|
|
||||||
statementType *
|
statementType *
|
||||||
newStatement(statementKindType kind, statementBodyType body)
|
newStatement(statementKindType kind, statementBodyType body)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These are all the miscellaneous routines for building pieces of parse-tree
|
These are all the miscellaneous routines for building pieces of parse-tree
|
||||||
|
@ -40,11 +42,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* Fragments of statement structures */
|
/* Fragments of statement structures */
|
||||||
|
caseType *
|
||||||
|
|
||||||
extern void botch (char *message, ...);
|
|
||||||
|
|
||||||
caseType *
|
|
||||||
buildCase(expressionListType *caseTags, blockType *caseBody)
|
buildCase(expressionListType *caseTags, blockType *caseBody)
|
||||||
{
|
{
|
||||||
caseType *result;
|
caseType *result;
|
||||||
|
@ -142,7 +140,6 @@ buildBinopTerm(binopKindType binop, expressionType *leftArgument, expressionType
|
||||||
buildFunctionCall(stringType *functionName, operandListType *arguments)
|
buildFunctionCall(stringType *functionName, operandListType *arguments)
|
||||||
{
|
{
|
||||||
functionCallTermType *result;
|
functionCallTermType *result;
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
|
|
||||||
result = typeAlloc(functionCallTermType);
|
result = typeAlloc(functionCallTermType);
|
||||||
result->functionName = lookupOrEnterSymbol(functionName,
|
result->functionName = lookupOrEnterSymbol(functionName,
|
||||||
|
@ -189,8 +186,6 @@ buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *ar
|
||||||
{
|
{
|
||||||
expressionType *result;
|
expressionType *result;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
|
|
||||||
result = typeAlloc(expressionType);
|
result = typeAlloc(expressionType);
|
||||||
result->kindOfTerm = kindOfExpressionTerm;
|
result->kindOfTerm = kindOfExpressionTerm;
|
||||||
switch (kindOfExpressionTerm) {
|
switch (kindOfExpressionTerm) {
|
||||||
|
@ -274,7 +269,6 @@ buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *ar
|
||||||
buildMacroTableEntry(stringType *name)
|
buildMacroTableEntry(stringType *name)
|
||||||
{
|
{
|
||||||
macroTableEntryType *result;
|
macroTableEntryType *result;
|
||||||
char *saveString(char *s);
|
|
||||||
|
|
||||||
result = typeAlloc(macroTableEntryType);
|
result = typeAlloc(macroTableEntryType);
|
||||||
result->macroName = saveString(name);
|
result->macroName = saveString(name);
|
||||||
|
@ -288,7 +282,6 @@ buildMacroTableEntry(stringType *name)
|
||||||
buildSymbolTableEntry(stringType *name, symbolUsageKindType usage)
|
buildSymbolTableEntry(stringType *name, symbolUsageKindType usage)
|
||||||
{
|
{
|
||||||
symbolTableEntryType *result;
|
symbolTableEntryType *result;
|
||||||
char *saveString(char *s);
|
|
||||||
|
|
||||||
result = typeAlloc(symbolTableEntryType);
|
result = typeAlloc(symbolTableEntryType);
|
||||||
result->symbolName = saveString(name);
|
result->symbolName = saveString(name);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These routines all build list-type structures. Since yacc likes to build
|
These routines all build list-type structures. Since yacc likes to build
|
||||||
|
@ -47,7 +48,6 @@ buildArgumentList(stringType *new, argumentListHeadType *rest, bool arrayTag)
|
||||||
{
|
{
|
||||||
argumentListHeadType *newListHead;
|
argumentListHeadType *newListHead;
|
||||||
argumentDefinitionListType *newArgument;
|
argumentDefinitionListType *newArgument;
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
|
|
||||||
if (rest == NULL) {
|
if (rest == NULL) {
|
||||||
newListHead = typeAlloc(argumentListHeadType);
|
newListHead = typeAlloc(argumentListHeadType);
|
||||||
|
@ -128,8 +128,6 @@ buildIdentifierList(stringType *new, identifierListHeadType *rest, symbolUsageKi
|
||||||
identifierListType *newListEntry;
|
identifierListType *newListEntry;
|
||||||
identifierListHeadType *newListHead;
|
identifierListHeadType *newListHead;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
|
|
||||||
if (rest == NULL) {
|
if (rest == NULL) {
|
||||||
newListHead = typeAlloc(identifierListHeadType);
|
newListHead = typeAlloc(identifierListHeadType);
|
||||||
newListHead->theSymbol = lookupOrEnterSymbol(new, usage);
|
newListHead->theSymbol = lookupOrEnterSymbol(new, usage);
|
||||||
|
|
|
@ -30,9 +30,15 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "buildStuff.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
#include "expressionSemantics.h"
|
#include "expressionSemantics.h"
|
||||||
|
#include "garbage.h"
|
||||||
|
#include "lexer.h"
|
||||||
|
#include "lookups.h"
|
||||||
#include "operandStuff.h"
|
#include "operandStuff.h"
|
||||||
#include "semanticMisc.h"
|
#include "semanticMisc.h"
|
||||||
|
#include "statementSemantics.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -42,17 +48,6 @@
|
||||||
environment
|
environment
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
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 *
|
valueType *
|
||||||
makeBooleanValue(int test)
|
makeBooleanValue(int test)
|
||||||
{
|
{
|
||||||
|
@ -126,8 +121,6 @@ applyBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
stringType *macroToLookup;
|
stringType *macroToLookup;
|
||||||
macroTableEntryType *macroToCall;
|
macroTableEntryType *macroToCall;
|
||||||
|
|
||||||
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");
|
||||||
return(makeFailureValue());
|
return(makeFailureValue());
|
||||||
|
@ -362,9 +355,6 @@ isDefinedBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
if (parameterList->kindOfOperand == EXPRESSION_OPND &&
|
if (parameterList->kindOfOperand == EXPRESSION_OPND &&
|
||||||
(expression = parameterList->theOperand.
|
(expression = parameterList->theOperand.
|
||||||
|
@ -395,8 +385,6 @@ isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
if (parameterList != NULL && parameterList->kindOfOperand ==
|
if (parameterList != NULL && parameterList->kindOfOperand ==
|
||||||
EXPRESSION_OPND) {
|
EXPRESSION_OPND) {
|
||||||
expression = parameterList->theOperand.expressionUnion;
|
expression = parameterList->theOperand.expressionUnion;
|
||||||
|
@ -847,10 +835,6 @@ symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
stringType *identifierToLookup;
|
stringType *identifierToLookup;
|
||||||
|
|
||||||
expressionTermType *buildExpressionTerm(expressionTermKindType kindOfExpressionTerm, anyOldThing *arg1, anyOldThing *arg2, anyOldThing *arg3);
|
|
||||||
operandType *buildOperand(operandKindType kindOfOperand, anyOldThing *arg);
|
|
||||||
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");
|
||||||
return(makeFailureValue());
|
return(makeFailureValue());
|
||||||
|
@ -871,7 +855,6 @@ symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *stringValue;
|
valueType *stringValue;
|
||||||
statementType *syntheticDefineStatement;
|
statementType *syntheticDefineStatement;
|
||||||
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");
|
||||||
|
@ -906,8 +889,6 @@ symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
saveEnvironment = currentEnvironment;
|
saveEnvironment = currentEnvironment;
|
||||||
while (parameterList != NULL && parameterList->kindOfOperand ==
|
while (parameterList != NULL && parameterList->kindOfOperand ==
|
||||||
EXPRESSION_OPND) {
|
EXPRESSION_OPND) {
|
||||||
|
@ -942,8 +923,6 @@ symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
if (parameterList != NULL && parameterList->kindOfOperand ==
|
if (parameterList != NULL && parameterList->kindOfOperand ==
|
||||||
EXPRESSION_OPND) {
|
EXPRESSION_OPND) {
|
||||||
expression = parameterList->theOperand.expressionUnion;
|
expression = parameterList->theOperand.expressionUnion;
|
||||||
|
@ -961,7 +940,6 @@ valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeIntegerValue(evaluatedParameter->kindOfValue));
|
return(makeIntegerValue(evaluatedParameter->kindOfValue));
|
||||||
|
|
|
@ -32,15 +32,8 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "builtInFunctions.h"
|
||||||
/* Helper functions, defined in builtInFunctions.c */
|
#include "operandStuff.h"
|
||||||
valueType *makeBooleanValue(int test);
|
|
||||||
valueType *makeFailureValue(void);
|
|
||||||
valueType *makeIntegerValue(int integer);
|
|
||||||
valueType *makeOperandValue(operandType *operand);
|
|
||||||
valueType *makeStringValue(stringType *string);
|
|
||||||
valueType *makeUndefinedValue(void);
|
|
||||||
|
|
||||||
|
|
||||||
/* Check if operand is the accumulator */
|
/* Check if operand is the accumulator */
|
||||||
valueType *
|
valueType *
|
||||||
|
@ -48,8 +41,6 @@ isARegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -65,8 +56,6 @@ isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -82,8 +71,6 @@ isImmediateModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -99,8 +86,6 @@ isIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -119,8 +104,6 @@ isIndirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -136,8 +119,6 @@ isPostIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -153,8 +134,6 @@ isPreIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -171,8 +150,6 @@ isXIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -189,8 +166,6 @@ isXRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -206,8 +181,6 @@ isYIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
@ -224,8 +197,6 @@ isYRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup)
|
||||||
{
|
{
|
||||||
valueType *evaluatedParameter;
|
valueType *evaluatedParameter;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
|
|
||||||
if (parameterList != NULL) {
|
if (parameterList != NULL) {
|
||||||
evaluatedParameter = evaluateOperand(parameterList);
|
evaluatedParameter = evaluateOperand(parameterList);
|
||||||
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
return(makeBooleanValue(evaluatedParameter->addressMode ==
|
||||||
|
|
16
debugPrint.c
16
debugPrint.c
|
@ -30,10 +30,9 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
void printExpression(expressionType *expression);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Print out the parse-tree.
|
Print out the parse-tree.
|
||||||
*/
|
*/
|
||||||
|
@ -44,11 +43,6 @@ 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 */
|
||||||
|
|
||||||
extern void printOperandKind (operandKindType kind);
|
|
||||||
extern void printToken (int token);
|
|
||||||
extern void printCondition (conditionType condition);
|
|
||||||
extern void printOperand (operandType *operand);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
tab(void)
|
tab(void)
|
||||||
|
@ -259,8 +253,6 @@ printArgumentDefinitionList(argumentDefinitionListType *list)
|
||||||
void
|
void
|
||||||
printBlock(blockType *block)
|
printBlock(blockType *block)
|
||||||
{
|
{
|
||||||
void printStatement(statementType *statement);
|
|
||||||
|
|
||||||
nullPrint(block);
|
nullPrint(block);
|
||||||
tab(); printf("(block:\n");
|
tab(); printf("(block:\n");
|
||||||
tablevel++;
|
tablevel++;
|
||||||
|
@ -272,8 +264,6 @@ printBlock(blockType *block)
|
||||||
void
|
void
|
||||||
printArrayTerm(arrayTermType *arrayTerm)
|
printArrayTerm(arrayTermType *arrayTerm)
|
||||||
{
|
{
|
||||||
void printIdentifier(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
nullPrint(arrayTerm);
|
nullPrint(arrayTerm);
|
||||||
tab(); printf("(array\n");
|
tab(); printf("(array\n");
|
||||||
tablevel++;
|
tablevel++;
|
||||||
|
@ -301,8 +291,6 @@ printAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
void
|
void
|
||||||
printBinopTerm(binopTermType *binopTerm)
|
printBinopTerm(binopTermType *binopTerm)
|
||||||
{
|
{
|
||||||
void printIdentifier(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
nullPrint(binopTerm);
|
nullPrint(binopTerm);
|
||||||
tab(); printf("(binop [");
|
tab(); printf("(binop [");
|
||||||
printToken(binopTerm->binop);
|
printToken(binopTerm->binop);
|
||||||
|
@ -320,8 +308,6 @@ printBinopTerm(binopTermType *binopTerm)
|
||||||
void
|
void
|
||||||
printFunctionCall(functionCallTermType *functionCall)
|
printFunctionCall(functionCallTermType *functionCall)
|
||||||
{
|
{
|
||||||
void printOperandList(operandListType *operandList);
|
|
||||||
|
|
||||||
nullPrint(functionCall);
|
nullPrint(functionCall);
|
||||||
tab(); printf("(function call %s\n", functionCall->functionName->
|
tab(); printf("(function call %s\n", functionCall->functionName->
|
||||||
symbolName);
|
symbolName);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,12 +40,6 @@ 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; }
|
||||||
|
|
||||||
|
|
||||||
extern void tab (void);
|
|
||||||
extern void printExpression (expressionType *expression);
|
|
||||||
extern void printIdentifierList (identifierListType *identifierList);
|
|
||||||
extern void printBlock (blockType *block);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
printCondition(conditionType condition)
|
printCondition(conditionType condition)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,19 +32,15 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "buildStuff.h"
|
||||||
|
#include "emitStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
/* emitRelativeBranch emits a relative branch instruction for the 6502,
|
/* emitRelativeBranch emits a relative branch instruction for the 6502,
|
||||||
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. */
|
||||||
|
|
||||||
|
|
||||||
extern void emitByte (byte byteValue);
|
|
||||||
extern void emitRelativeByteOffset (valueType *target);
|
|
||||||
extern void botch (char *message, ...);
|
|
||||||
extern void emitWord (wordType wordValue);
|
|
||||||
extern void noteAnonymousReference (void);
|
|
||||||
extern void emitWordValue (valueType *wordValue);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupLocation)
|
emitRelativeBranch(conditionType condition, valueType *target, valueType *fixupLocation)
|
||||||
{
|
{
|
||||||
|
@ -149,8 +145,6 @@ emitJump(valueType *target, simpleFixupListType *previousFixups)
|
||||||
simpleFixupListType *result;
|
simpleFixupListType *result;
|
||||||
valueType picFixup[COMPOUND_BRANCH_MAX];
|
valueType picFixup[COMPOUND_BRANCH_MAX];
|
||||||
|
|
||||||
simpleFixupListType *buildSimpleFixupList(valueType locationToFixup, simpleFixupListType *previousList);
|
|
||||||
|
|
||||||
#define JUMP_OPCODE 0x4C
|
#define JUMP_OPCODE 0x4C
|
||||||
|
|
||||||
result = previousFixups;
|
result = previousFixups;
|
||||||
|
|
15
emitStuff.c
15
emitStuff.c
|
@ -30,6 +30,10 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Emitted code is stored in places that are allocated dynamically as they
|
Emitted code is stored in places that are allocated dynamically as they
|
||||||
|
@ -62,17 +66,6 @@
|
||||||
|
|
||||||
/* incarnateCodeBuffer causes code buffer space to actually be allocated */
|
/* incarnateCodeBuffer causes code buffer space to actually be allocated */
|
||||||
|
|
||||||
|
|
||||||
extern void fatalError (errorType theError, ...);
|
|
||||||
extern bool byteCheck (int value);
|
|
||||||
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
|
void
|
||||||
incarnateCodeBuffer(int bufferNum, codeBufferKindType bufferKind)
|
incarnateCodeBuffer(int bufferNum, codeBufferKindType bufferKind)
|
||||||
{
|
{
|
||||||
|
|
18
encode.c
18
encode.c
|
@ -31,6 +31,10 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
#include "encode.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
#include "semanticMisc.h"
|
#include "semanticMisc.h"
|
||||||
#include "slinkyExpressions.h"
|
#include "slinkyExpressions.h"
|
||||||
|
|
||||||
|
@ -39,18 +43,6 @@
|
||||||
|
|
||||||
bool encodingFunction;
|
bool encodingFunction;
|
||||||
|
|
||||||
|
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
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
|
bool
|
||||||
encodeByte(byte aByte)
|
encodeByte(byte aByte)
|
||||||
{
|
{
|
||||||
|
@ -94,8 +86,6 @@ encodeAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
bool
|
bool
|
||||||
encodeBinopTerm(binopTermType *binopTerm)
|
encodeBinopTerm(binopTermType *binopTerm)
|
||||||
{
|
{
|
||||||
bool encodeExpression(expressionType *expression);
|
|
||||||
|
|
||||||
nullEncode(binopTerm);
|
nullEncode(binopTerm);
|
||||||
return (
|
return (
|
||||||
encodeByte(BINOP_TAG) &&
|
encodeByte(BINOP_TAG) &&
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "initialize.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
@ -39,12 +41,7 @@ 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;
|
||||||
|
|
|
@ -31,8 +31,17 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
#include "builtInFunctions.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
#include "expressionSemantics.h"
|
#include "expressionSemantics.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
#include "operandStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
#include "semanticMisc.h"
|
#include "semanticMisc.h"
|
||||||
|
#include "statementSemantics.h"
|
||||||
|
#include "tokenStrings.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -64,30 +73,6 @@ 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))
|
||||||
|
|
||||||
|
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
extern char *valueKindString (valueKindType valueKind);
|
|
||||||
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 *
|
anyOldThing *
|
||||||
arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing)
|
arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing)
|
||||||
{
|
{
|
||||||
|
|
33
fixups.c
33
fixups.c
|
@ -30,6 +30,14 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "expressionSemantics.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "operandStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
#include "tokenStrings.h"
|
||||||
|
|
||||||
operandType *dbOperand; /* safe temps for dbx hacking */
|
operandType *dbOperand; /* safe temps for dbx hacking */
|
||||||
expressionType *dbExpression;
|
expressionType *dbExpression;
|
||||||
|
@ -57,19 +65,10 @@ stringType *dbString = "graphics2.m";
|
||||||
The routines below collectively duplicate expressions for later evaluation.
|
The routines below collectively duplicate expressions for later evaluation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
extern void moreExpression (char *format, ...);
|
|
||||||
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 *
|
expressionType *
|
||||||
generateFixupExpression(expressionType *expression)
|
generateFixupExpression(expressionType *expression)
|
||||||
{
|
{
|
||||||
expressionType *result;
|
expressionType *result;
|
||||||
expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand);
|
|
||||||
|
|
||||||
generatingFixup = TRUE;
|
generatingFixup = TRUE;
|
||||||
result = duplicateExpressionForFixup(expression, TRUE, FALSE);
|
result = duplicateExpressionForFixup(expression, TRUE, FALSE);
|
||||||
|
@ -89,16 +88,6 @@ duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool is
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
|
|
||||||
operandType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
functionCallTermType *duplicateFunctionCall(functionCallTermType *functionCall);
|
|
||||||
expressionType *duplicateArrayReference(arrayTermType *arrayTerm);
|
|
||||||
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
|
||||||
valueType *evaluateHere(void);
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
symbolTableEntryType *generateLocalLabel(symbolTableEntryType *symbol);
|
|
||||||
stringType *saveString(char *s);
|
|
||||||
|
|
||||||
nullDup(expression);
|
nullDup(expression);
|
||||||
result = originalResult = typeAlloc(expressionType);
|
result = originalResult = typeAlloc(expressionType);
|
||||||
*result = *expression;
|
*result = *expression;
|
||||||
|
@ -290,8 +279,6 @@ duplicateFunctionCall(functionCallTermType *functionCall)
|
||||||
operandListType **argument;
|
operandListType **argument;
|
||||||
operandListType *parameterList;
|
operandListType *parameterList;
|
||||||
|
|
||||||
operandListType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
|
|
||||||
|
|
||||||
result = typeAlloc(functionCallTermType);
|
result = typeAlloc(functionCallTermType);
|
||||||
result->functionName = functionCall->functionName;
|
result->functionName = functionCall->functionName;
|
||||||
expand(moreExpression("%s(", symbName(functionCall->functionName)));
|
expand(moreExpression("%s(", symbName(functionCall->functionName)));
|
||||||
|
@ -324,10 +311,6 @@ duplicateArrayReference(arrayTermType *arrayTerm)
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
operandType *newOperand;
|
operandType *newOperand;
|
||||||
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
operandType *duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand);
|
|
||||||
anyOldThing *arrayLookup(arrayTermType *arrayTerm, valueKindType *kindOfThing);
|
|
||||||
|
|
||||||
expansionOff();
|
expansionOff();
|
||||||
resultThing = arrayLookup(arrayTerm, &kindOfResult);
|
resultThing = arrayLookup(arrayTerm, &kindOfResult);
|
||||||
expansionOn();
|
expansionOn();
|
||||||
|
|
18
garbage.c
18
garbage.c
|
@ -29,19 +29,16 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "garbage.h"
|
||||||
|
#include "operandStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
#define nullFree(thing) if (thing == NULL) return;
|
#define nullFree(thing) if (thing == NULL) return;
|
||||||
|
|
||||||
|
|
||||||
extern void botch (char *message, ...);
|
|
||||||
extern void freeOperand (operandType *operand);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
freeArrayTerm(arrayTermType *arrayTerm)
|
freeArrayTerm(arrayTermType *arrayTerm)
|
||||||
{
|
{
|
||||||
void freeExpression(expressionType *expression);
|
|
||||||
|
|
||||||
nullFree(arrayTerm);
|
nullFree(arrayTerm);
|
||||||
freeExpression(arrayTerm->arrayName);
|
freeExpression(arrayTerm->arrayName);
|
||||||
freeExpression(arrayTerm->arrayIndex);
|
freeExpression(arrayTerm->arrayIndex);
|
||||||
|
@ -51,8 +48,6 @@ freeArrayTerm(arrayTermType *arrayTerm)
|
||||||
void
|
void
|
||||||
freeAssignmentTerm(binopTermType *assignmentTerm)
|
freeAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
{
|
{
|
||||||
void freeExpression(expressionType *expression);
|
|
||||||
|
|
||||||
nullFree(assignmentTerm);
|
nullFree(assignmentTerm);
|
||||||
freeExpression(assignmentTerm->rightArgument);
|
freeExpression(assignmentTerm->rightArgument);
|
||||||
free(assignmentTerm);
|
free(assignmentTerm);
|
||||||
|
@ -61,8 +56,6 @@ freeAssignmentTerm(binopTermType *assignmentTerm)
|
||||||
void
|
void
|
||||||
freeBinopTerm(binopTermType *binopTerm)
|
freeBinopTerm(binopTermType *binopTerm)
|
||||||
{
|
{
|
||||||
void freeExpression(expressionType *expression);
|
|
||||||
|
|
||||||
nullFree(binopTerm);
|
nullFree(binopTerm);
|
||||||
freeExpression(binopTerm->leftArgument);
|
freeExpression(binopTerm->leftArgument);
|
||||||
if (binopTerm->binop != SELECT)
|
if (binopTerm->binop != SELECT)
|
||||||
|
@ -73,8 +66,6 @@ freeBinopTerm(binopTermType *binopTerm)
|
||||||
void
|
void
|
||||||
freeFunctionCall(functionCallTermType *functionCall)
|
freeFunctionCall(functionCallTermType *functionCall)
|
||||||
{
|
{
|
||||||
void freeOperandList(operandListType *operandList);
|
|
||||||
|
|
||||||
nullFree(functionCall);
|
nullFree(functionCall);
|
||||||
freeOperandList(functionCall->parameters);
|
freeOperandList(functionCall->parameters);
|
||||||
free(functionCall);
|
free(functionCall);
|
||||||
|
@ -104,8 +95,6 @@ freeString(stringType *string)
|
||||||
void
|
void
|
||||||
freeUnopTerm(unopTermType *unopTerm)
|
freeUnopTerm(unopTermType *unopTerm)
|
||||||
{
|
{
|
||||||
void freeExpression(expressionType *expression);
|
|
||||||
|
|
||||||
nullFree(unopTerm);
|
nullFree(unopTerm);
|
||||||
freeExpression(unopTerm->unopArgument);
|
freeExpression(unopTerm->unopArgument);
|
||||||
free(unopTerm);
|
free(unopTerm);
|
||||||
|
@ -774,7 +763,6 @@ freeStatement(statementType *statement)
|
||||||
freeArray(arrayType *array)
|
freeArray(arrayType *array)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
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++)
|
||||||
|
|
39
initialize.c
39
initialize.c
|
@ -29,8 +29,14 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "initialize.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "lexer.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define isAlphaNumeric(c) (alphaNumericCharacterTable[c])
|
#define isAlphaNumeric(c) (alphaNumericCharacterTable[c])
|
||||||
|
|
||||||
|
@ -39,19 +45,7 @@ extern int yydebug;
|
||||||
static fileNameListType *bottomOfInputFileStack;
|
static fileNameListType *bottomOfInputFileStack;
|
||||||
static char *outputFileName;
|
static char *outputFileName;
|
||||||
|
|
||||||
|
void
|
||||||
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)
|
chokePukeAndDie(void)
|
||||||
{
|
{
|
||||||
unlink(outputFileName);
|
unlink(outputFileName);
|
||||||
|
@ -72,14 +66,6 @@ initializeStuff(int argc, char **argv)
|
||||||
char *symbolDumpFileName;
|
char *symbolDumpFileName;
|
||||||
bool dontUnlinkTempFiles;
|
bool dontUnlinkTempFiles;
|
||||||
|
|
||||||
void createHashTables(void);
|
|
||||||
void installBuiltInFunctions(void);
|
|
||||||
void installPredefinedSymbols(void);
|
|
||||||
void installCommandLineDefineSymbols(void);
|
|
||||||
void openFirstInputFile(void);
|
|
||||||
void queueInputFile(char *name);
|
|
||||||
void noteCommandLineDefine(char *arg);
|
|
||||||
|
|
||||||
for (i=0; i<128; i++) {
|
for (i=0; i<128; i++) {
|
||||||
lowerCaseCharacterTable[i] = i;
|
lowerCaseCharacterTable[i] = i;
|
||||||
alphabeticCharacterTable[i] = FALSE;
|
alphabeticCharacterTable[i] = FALSE;
|
||||||
|
@ -396,9 +382,6 @@ installBuiltInFunctions(void)
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *newFunction;
|
symbolTableEntryType *newFunction;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
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].
|
||||||
functionName, BUILT_IN_FUNCTION_SYMBOL);
|
functionName, BUILT_IN_FUNCTION_SYMBOL);
|
||||||
|
@ -416,9 +399,6 @@ installPredefinedSymbols(void)
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *newSymbol;
|
symbolTableEntryType *newSymbol;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
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].
|
||||||
symbolName, DEFINE_SYMBOL);
|
symbolName, DEFINE_SYMBOL);
|
||||||
|
@ -435,9 +415,6 @@ installCommandLineDefineSymbols(void)
|
||||||
int i;
|
int i;
|
||||||
symbolTableEntryType *newSymbol;
|
symbolTableEntryType *newSymbol;
|
||||||
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
|
|
||||||
while (commandLineDefines != NULL) {
|
while (commandLineDefines != NULL) {
|
||||||
newSymbol = lookupOrEnterSymbol(commandLineDefines->name,
|
newSymbol = lookupOrEnterSymbol(commandLineDefines->name,
|
||||||
DEFINE_SYMBOL);
|
DEFINE_SYMBOL);
|
||||||
|
@ -572,8 +549,6 @@ noteCommandLineDefine(char *arg)
|
||||||
int value;
|
int value;
|
||||||
commandLineDefineType *newCommandLineDefine;
|
commandLineDefineType *newCommandLineDefine;
|
||||||
|
|
||||||
bool parseCommandLineDefine(char *arg, char **name, int *value);
|
|
||||||
|
|
||||||
if (parseCommandLineDefine(arg, &name, &value)) {
|
if (parseCommandLineDefine(arg, &name, &value)) {
|
||||||
newCommandLineDefine = typeAlloc(commandLineDefineType);
|
newCommandLineDefine = typeAlloc(commandLineDefineType);
|
||||||
newCommandLineDefine->name = name;
|
newCommandLineDefine->name = name;
|
||||||
|
|
33
lexer.c
33
lexer.c
|
@ -30,7 +30,12 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "lexer.h"
|
||||||
#include "lexerTables.h"
|
#include "lexerTables.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "lookups.h"
|
||||||
#include "parserMisc.h"
|
#include "parserMisc.h"
|
||||||
|
|
||||||
extern int yylval;
|
extern int yylval;
|
||||||
|
@ -52,24 +57,6 @@ 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 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
|
int
|
||||||
yylex(void)
|
yylex(void)
|
||||||
{
|
{
|
||||||
|
@ -89,8 +76,6 @@ lexer(void)
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
char skipWhitespaceAndComments(void);
|
|
||||||
|
|
||||||
if ((c = skipWhitespaceAndComments()) == EOF)
|
if ((c = skipWhitespaceAndComments()) == EOF)
|
||||||
return(lexLiteral(c));
|
return(lexLiteral(c));
|
||||||
else
|
else
|
||||||
|
@ -101,12 +86,6 @@ lexer(void)
|
||||||
initializeLexDispatchTable(void)
|
initializeLexDispatchTable(void)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int lexIdentifier(char c);
|
|
||||||
int lexNumber(char c);
|
|
||||||
int lexLiteral(char c);
|
|
||||||
int lexCharacterConstant(void);
|
|
||||||
int lexStringConstant(void);
|
|
||||||
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=='$')
|
||||||
|
@ -152,7 +131,6 @@ char nameBuffer[MAX_NAME_SIZE+1];
|
||||||
int
|
int
|
||||||
lexIdentifier(char c)
|
lexIdentifier(char c)
|
||||||
{
|
{
|
||||||
char *saveString(char *s);
|
|
||||||
int hashValue;
|
int hashValue;
|
||||||
|
|
||||||
snarfAlphanumericString(c, nameBuffer);
|
snarfAlphanumericString(c, nameBuffer);
|
||||||
|
@ -270,7 +248,6 @@ getStringCharacter(FILE *input)
|
||||||
char c;
|
char c;
|
||||||
char *numberPtr;
|
char *numberPtr;
|
||||||
int result;
|
int result;
|
||||||
char controlCharacter(char c);
|
|
||||||
|
|
||||||
escaped = FALSE;
|
escaped = FALSE;
|
||||||
c = getNextChar();
|
c = getNextChar();
|
||||||
|
|
13
listing.c
13
listing.c
|
@ -29,7 +29,10 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "emitStuff.h"
|
||||||
|
#include "lexer.h"
|
||||||
#include "listing.h"
|
#include "listing.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -44,15 +47,7 @@ static int nextMacroAddress;
|
||||||
static int macroDepth;
|
static int macroDepth;
|
||||||
static int nextMacroDepth;
|
static int nextMacroDepth;
|
||||||
|
|
||||||
|
void
|
||||||
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)
|
outputListing(void)
|
||||||
{
|
{
|
||||||
rewind(saveFileForPass2);
|
rewind(saveFileForPass2);
|
||||||
|
|
47
lookups.c
47
lookups.c
|
@ -29,6 +29,14 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "buildStuff.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "garbage.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
#include "operandStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
These routines all do basically the same thing. Various kinds of keywords
|
These routines all do basically the same thing. Various kinds of keywords
|
||||||
|
@ -36,25 +44,11 @@
|
||||||
lists that are sorted alphabetically.
|
lists that are sorted alphabetically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
conditionType
|
||||||
extern void botch (char *message, ...);
|
|
||||||
extern void freeValue (valueType *value);
|
|
||||||
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)
|
lookupConditionCode(char *s, int hashValue)
|
||||||
{
|
{
|
||||||
conditionTableEntryType *result;
|
conditionTableEntryType *result;
|
||||||
|
|
||||||
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
|
||||||
|
|
||||||
result = (conditionTableEntryType *) prehashedStringLookup(s,
|
result = (conditionTableEntryType *) prehashedStringLookup(s,
|
||||||
conditionTable, hashValue);
|
conditionTable, hashValue);
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
|
@ -68,8 +62,6 @@ lookupKeyword(char *s, int hashValue)
|
||||||
{
|
{
|
||||||
keywordTableEntryType *result;
|
keywordTableEntryType *result;
|
||||||
|
|
||||||
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
|
||||||
|
|
||||||
result = (keywordTableEntryType *) prehashedStringLookup(s,
|
result = (keywordTableEntryType *) prehashedStringLookup(s,
|
||||||
keywordTable, hashValue);
|
keywordTable, hashValue);
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
|
@ -81,8 +73,6 @@ lookupKeyword(char *s, int hashValue)
|
||||||
macroTableEntryType *
|
macroTableEntryType *
|
||||||
lookupMacroName(char *s, int hashValue)
|
lookupMacroName(char *s, int hashValue)
|
||||||
{
|
{
|
||||||
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
|
||||||
|
|
||||||
return((macroTableEntryType *) prehashedStringLookup(s, macroTable,
|
return((macroTableEntryType *) prehashedStringLookup(s, macroTable,
|
||||||
hashValue));
|
hashValue));
|
||||||
}
|
}
|
||||||
|
@ -90,8 +80,6 @@ lookupMacroName(char *s, int hashValue)
|
||||||
opcodeTableEntryType *
|
opcodeTableEntryType *
|
||||||
lookupOpcode(char *s, int hashValue)
|
lookupOpcode(char *s, int hashValue)
|
||||||
{
|
{
|
||||||
genericTableEntryType *prehashedStringLookup(char *s, genericTableEntryType **table, int hashValue);
|
|
||||||
|
|
||||||
return((opcodeTableEntryType *) prehashedStringLookup(s,
|
return((opcodeTableEntryType *) prehashedStringLookup(s,
|
||||||
opcodeTable, hashValue));
|
opcodeTable, hashValue));
|
||||||
}
|
}
|
||||||
|
@ -104,9 +92,6 @@ lookupOpcode(char *s, int hashValue)
|
||||||
lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind)
|
lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind)
|
||||||
{
|
{
|
||||||
symbolTableEntryType *result;
|
symbolTableEntryType *result;
|
||||||
genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table);
|
|
||||||
genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table);
|
|
||||||
symbolTableEntryType *buildSymbolTableEntry(stringType *name, symbolUsageKindType usage);
|
|
||||||
|
|
||||||
if (result = (symbolTableEntryType *)hashStringLookup(s,symbolTable)){
|
if (result = (symbolTableEntryType *)hashStringLookup(s,symbolTable)){
|
||||||
/* result->referenceCount++;*/
|
/* result->referenceCount++;*/
|
||||||
|
@ -151,11 +136,6 @@ createMacro(stringType *macroName)
|
||||||
macroTableEntryType *result;
|
macroTableEntryType *result;
|
||||||
symbolTableEntryType *testSymbol;
|
symbolTableEntryType *testSymbol;
|
||||||
|
|
||||||
genericTableEntryType *hashStringLookup(char *s, genericTableEntryType **table);
|
|
||||||
genericTableEntryType *hashStringEnter(genericTableEntryType *entry, genericTableEntryType **table);
|
|
||||||
macroTableEntryType *buildMacroTableEntry(stringType *name);
|
|
||||||
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) {
|
||||||
error(SYMBOL_ALREADY_THERE_ERROR, symbName(testSymbol));
|
error(SYMBOL_ALREADY_THERE_ERROR, symbName(testSymbol));
|
||||||
|
@ -297,8 +277,6 @@ purgeSymbol(symbolTableEntryType *symbol)
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
if ((context = getWorkingContext(symbol)) != NULL)
|
if ((context = getWorkingContext(symbol)) != NULL)
|
||||||
context->usage = DEAD_SYMBOL;
|
context->usage = DEAD_SYMBOL;
|
||||||
}
|
}
|
||||||
|
@ -319,8 +297,6 @@ reincarnateSymbol(symbolInContextType *context, symbolUsageKindType newUsage)
|
||||||
void
|
void
|
||||||
pushBinding(symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage)
|
pushBinding(symbolTableEntryType *symbol, valueType *newBinding, symbolUsageKindType newUsage)
|
||||||
{
|
{
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
|
|
||||||
pushSymbol(symbol);
|
pushSymbol(symbol);
|
||||||
if (newBinding == NULL)
|
if (newBinding == NULL)
|
||||||
newBinding = newValue(FAIL, 0, EXPRESSION_OPND);
|
newBinding = newValue(FAIL, 0, EXPRESSION_OPND);
|
||||||
|
@ -346,8 +322,6 @@ bindMacroArguments(argumentDefinitionListType *argumentList, operandListType *pa
|
||||||
valueType **arrayContents;
|
valueType **arrayContents;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
|
|
||||||
if (argumentList == NULL)
|
if (argumentList == NULL)
|
||||||
arrayTag = FALSE;
|
arrayTag = FALSE;
|
||||||
else
|
else
|
||||||
|
@ -409,9 +383,6 @@ bindFunctionArguments(argumentDefinitionListType *argumentList, operandListType
|
||||||
valueType *firstArgument;
|
valueType *firstArgument;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
|
||||||
valueType *evaluateOperand(operandType *operand);
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
|
|
||||||
if (argumentList == NULL)
|
if (argumentList == NULL)
|
||||||
arrayTag = FALSE;
|
arrayTag = FALSE;
|
||||||
else
|
else
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "builtInFunctions.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
/* All those NULLs are used to string together lists after this all gets
|
/* All those NULLs are used to string together lists after this all gets
|
||||||
|
@ -205,21 +207,6 @@ int operandClassTable[] = { /* indexed by operandKindType */
|
||||||
BLOCK_OPND_BIT,
|
BLOCK_OPND_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
int actionsRelative(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDir1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDir2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDirIndir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDirX1(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDirX2(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDirX3(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsImmDir(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsImmDirX(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsImmDirY(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsNone(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
int actionsImmIndex(opcodeTableEntryType *opcode, int numberOfOperands, valueType **evaluatedOperands);
|
|
||||||
|
|
||||||
/* indexed by opcodeClass */
|
/* indexed by opcodeClass */
|
||||||
int (*instructionActionTable[])() = {
|
int (*instructionActionTable[])() = {
|
||||||
actionsRelative,
|
actionsRelative,
|
||||||
|
@ -303,54 +290,6 @@ valueType undefinedValueValue = { UNDEFINED_VALUE, 0,
|
||||||
EXPRESSION_OPND };
|
EXPRESSION_OPND };
|
||||||
valueType *UndefinedValue = &undefinedValueValue;
|
valueType *UndefinedValue = &undefinedValueValue;
|
||||||
|
|
||||||
valueType *addressModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *applyBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *arrayLengthBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *atasciiBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *atasciiColorBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *debugModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *debugModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *emitModeOffBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *emitModeOnBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isAbsoluteValueBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isARegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isBlockBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isBuiltInFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isConditionCodeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isDefinedBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isDirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isExternalBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isFieldBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isFunctionBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isImmediateModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isIndirectModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isPostIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isPreIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isRelocatableValueBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isStringBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isStructBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isSymbolBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isXIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isXRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isYIndexedModeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *isYRegisterBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *listingOffBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *listingOnBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *makeArrayBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *nthCharBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *printfBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *strcatBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *strcmpBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *strcmplcBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *strlenBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *substrBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *symbolDefineBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *symbolLookupBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *symbolNameBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *symbolUsageBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
valueType *valueTypeBIF(operandListType *parameterList, fixupKindType kindOfFixup);
|
|
||||||
|
|
||||||
/* Used to initialize symbols representing built-in functions */
|
/* Used to initialize symbols representing built-in functions */
|
||||||
struct {
|
struct {
|
||||||
stringType *functionName;
|
stringType *functionName;
|
||||||
|
|
14
main.c
14
main.c
|
@ -29,12 +29,11 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "initialize.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
#include "y.tab.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
extern void initializeStuff (int argc, char **argv);
|
|
||||||
extern int yyparse (void);
|
|
||||||
extern void finishUp (void);
|
|
||||||
extern void chokePukeAndDie (void);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
|
@ -44,15 +43,14 @@ main(int argc, char **argv)
|
||||||
#else
|
#else
|
||||||
extern char end;
|
extern char end;
|
||||||
#endif
|
#endif
|
||||||
char *sbrk(int);
|
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
initializeStuff(argc, argv);
|
initializeStuff(argc, argv);
|
||||||
yyparse();
|
yyparse();
|
||||||
finishUp();
|
finishUp();
|
||||||
if (emitPrint)
|
if (emitPrint)
|
||||||
printf("storage high water mark 0x%x == %d\n", sbrk(0) - &end,
|
printf("storage high water mark 0x%x == %d\n", sbrk(0) - (void *)(&end),
|
||||||
sbrk(0) - &end);
|
sbrk(0) - (void *)(&end));
|
||||||
if (errorFlag)
|
if (errorFlag)
|
||||||
chokePukeAndDie();
|
chokePukeAndDie();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
46
object.c
46
object.c
|
@ -29,6 +29,14 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
|
#include "encode.h"
|
||||||
|
#include "expressionSemantics.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "garbage.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
#include "object.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -36,29 +44,9 @@ static int symbolTableSize;
|
||||||
static int symbolTableStringSize;
|
static int symbolTableStringSize;
|
||||||
bool encodingFunction;
|
bool encodingFunction;
|
||||||
|
|
||||||
|
void
|
||||||
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)
|
outputObjectFile(void)
|
||||||
{
|
{
|
||||||
void outputPartition(void);
|
|
||||||
void outputReferenceInfo(void);
|
|
||||||
void outputSymbolTableInfo(void);
|
|
||||||
void outputAbsoluteCode(void);
|
|
||||||
void outputRelocatableCode(void);
|
|
||||||
void outputReservations(void);
|
|
||||||
void outputExpressions(void);
|
|
||||||
void outputFunctions(void);
|
|
||||||
void dumpSymbolTable(void);
|
|
||||||
void enumerateAndCountSymbols(void);
|
|
||||||
|
|
||||||
if (debug || emitPrint)
|
if (debug || emitPrint)
|
||||||
printCodeBuffers();
|
printCodeBuffers();
|
||||||
outputPartition();
|
outputPartition();
|
||||||
|
@ -138,9 +126,6 @@ outputRelocatableCode(void)
|
||||||
addressType codeStartAddress;
|
addressType codeStartAddress;
|
||||||
addressType codeEndAddress;
|
addressType codeEndAddress;
|
||||||
|
|
||||||
void outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress);
|
|
||||||
void outputBreak(codeBreakType *codeBreak);
|
|
||||||
|
|
||||||
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
||||||
kindOfValue == RELOCATABLE_VALUE)
|
kindOfValue == RELOCATABLE_VALUE)
|
||||||
outputStartAddress(startAddress->value);
|
outputStartAddress(startAddress->value);
|
||||||
|
@ -194,7 +179,6 @@ outputAbsoluteCode(void)
|
||||||
int startSegment;
|
int startSegment;
|
||||||
int endSegment;
|
int endSegment;
|
||||||
int nextSegment;
|
int nextSegment;
|
||||||
void outputOneCodeBuffer(codeSegmentType *segment);
|
|
||||||
|
|
||||||
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
if (haveUserStartAddress && !fixupStartAddress && startAddress->
|
||||||
kindOfValue==ABSOLUTE_VALUE)
|
kindOfValue==ABSOLUTE_VALUE)
|
||||||
|
@ -252,9 +236,6 @@ outputPseudoSegment(addressType codeStartAddress, addressType codeEndAddress)
|
||||||
int segment;
|
int segment;
|
||||||
codeSegmentType *segmentPtr;
|
codeSegmentType *segmentPtr;
|
||||||
|
|
||||||
void outputWord(int aWord);
|
|
||||||
void outputByte(byte aByte);
|
|
||||||
|
|
||||||
outputWord(codeStartAddress);
|
outputWord(codeStartAddress);
|
||||||
outputWord(codeEndAddress);
|
outputWord(codeEndAddress);
|
||||||
startSegment = bufferNumber(codeStartAddress);
|
startSegment = bufferNumber(codeStartAddress);
|
||||||
|
@ -365,7 +346,6 @@ outputOneSymbol(symbolTableEntryType *symbol)
|
||||||
{
|
{
|
||||||
byte symbolClass;
|
byte symbolClass;
|
||||||
valueType *symbolValue;
|
valueType *symbolValue;
|
||||||
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);
|
||||||
|
@ -431,9 +411,6 @@ dumpSymbolTable(void)
|
||||||
int symbolPtr;
|
int symbolPtr;
|
||||||
valueType *value;
|
valueType *value;
|
||||||
|
|
||||||
valueType *evaluateIdentifier(symbolTableEntryType *identifier, bool isTopLevel, fixupKindType kindOfFixup);
|
|
||||||
void printValueTersely(valueType *value);
|
|
||||||
|
|
||||||
numberOfSymbols = 0;
|
numberOfSymbols = 0;
|
||||||
for (i=0; i<HASH_TABLE_SIZE; i++)
|
for (i=0; i<HASH_TABLE_SIZE; i++)
|
||||||
for (symb=symbolTable[i]; symb!=NULL; symb=symb->nextSymbol) {
|
for (symb=symbolTable[i]; symb!=NULL; symb=symb->nextSymbol) {
|
||||||
|
@ -560,9 +537,6 @@ outputOneExpression(expressionType *expression)
|
||||||
{
|
{
|
||||||
expressionType *newExpression;
|
expressionType *newExpression;
|
||||||
|
|
||||||
expressionType *generateFixupExpression(expressionType *expression);
|
|
||||||
bool encodeExpression(expressionType *expression);
|
|
||||||
|
|
||||||
expressionBufferSize = 0;
|
expressionBufferSize = 0;
|
||||||
if (expression == NULL) {
|
if (expression == NULL) {
|
||||||
encodeRelocatableNumber(0);
|
encodeRelocatableNumber(0);
|
||||||
|
@ -598,8 +572,6 @@ outputExpressions(void)
|
||||||
outputOneFunction(functionDefinitionType *function)
|
outputOneFunction(functionDefinitionType *function)
|
||||||
{
|
{
|
||||||
argumentDefinitionListType *argumentList;
|
argumentDefinitionListType *argumentList;
|
||||||
bool encodeBlock(blockType *block);
|
|
||||||
int countArguments(functionDefinitionType *function);
|
|
||||||
|
|
||||||
outputByte((byte)countArguments(function));
|
outputByte((byte)countArguments(function));
|
||||||
argumentList = function->arguments;
|
argumentList = function->arguments;
|
||||||
|
|
|
@ -30,21 +30,19 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "expressionSemantics.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "garbage.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "operandStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
#include "statementSemantics.h"
|
||||||
|
|
||||||
/* corresponds to routines in buildStuff2.c */
|
/* corresponds to routines in buildStuff2.c */
|
||||||
|
|
||||||
|
operandType *
|
||||||
extern void botch (char *message, ...);
|
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
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)
|
buildOperand(operandKindType kindOfOperand, anyOldThing *arg)
|
||||||
{
|
{
|
||||||
operandType *result;
|
operandType *result;
|
||||||
|
@ -142,8 +140,6 @@ duplicateOperandForFixup(operandListType *operand, bool isSpecialFunctionOperand
|
||||||
{
|
{
|
||||||
operandListType *result;
|
operandListType *result;
|
||||||
|
|
||||||
expressionType *duplicateExpressionForFixup(expressionType *expression, bool isTopLevel, bool isSpecialFunctionOperand);
|
|
||||||
|
|
||||||
result = typeAlloc(operandListType);
|
result = typeAlloc(operandListType);
|
||||||
result->kindOfOperand = operand->kindOfOperand;
|
result->kindOfOperand = operand->kindOfOperand;
|
||||||
result->nextOperand = NULL;
|
result->nextOperand = NULL;
|
||||||
|
@ -289,10 +285,6 @@ evaluateOperand(operandType *operand)
|
||||||
bool saveExpansion;
|
bool saveExpansion;
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
|
|
||||||
valueType *evaluateExpression(expressionType *expression, fixupKindType kindOfFixup);
|
|
||||||
valueType *evaluateSelectionList(selectionListType *selectionList);
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
|
|
||||||
nullEvaluate(operand);
|
nullEvaluate(operand);
|
||||||
if (operand->kindOfOperand != EXPRESSION_OPND)
|
if (operand->kindOfOperand != EXPRESSION_OPND)
|
||||||
newFixupAddressMode = operand->kindOfOperand;
|
newFixupAddressMode = operand->kindOfOperand;
|
||||||
|
|
12
parserMisc.c
12
parserMisc.c
|
@ -32,20 +32,18 @@
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
#include "buildStuff.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "initialize.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
#include "parserMisc.h"
|
#include "parserMisc.h"
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
statementType *
|
||||||
extern void chokePukeAndDie (void);
|
|
||||||
extern void puntOnError (errorType theError, ...);
|
|
||||||
|
|
||||||
statementType *
|
|
||||||
addLabelToStatement(labelListType *labelList, statementType *statement)
|
addLabelToStatement(labelListType *labelList, statementType *statement)
|
||||||
{
|
{
|
||||||
statementType *newStatement(statementKindType kind, statementBodyType body);
|
|
||||||
|
|
||||||
if (statement == NULL)
|
if (statement == NULL)
|
||||||
statement = newStatement(NULL_STATEMENT, (statementBodyType){ NULL });
|
statement = newStatement(NULL_STATEMENT, (statementBodyType){ NULL });
|
||||||
statement->labels = labelList;
|
statement->labels = labelList;
|
||||||
|
|
|
@ -33,7 +33,17 @@
|
||||||
#include "y.tab.h"
|
#include "y.tab.h"
|
||||||
|
|
||||||
#include "semanticMisc.h"
|
#include "semanticMisc.h"
|
||||||
|
#include "buildStuff.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
|
#include "emitStuff.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
#include "expressionSemantics.h"
|
#include "expressionSemantics.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "lookups.h"
|
||||||
|
#include "object.h"
|
||||||
|
#include "operandStuff.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -44,26 +54,7 @@
|
||||||
These are miscellaneous routines called by the primary semantics routines.
|
These are miscellaneous routines called by the primary semantics routines.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
bool
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
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)
|
absoluteValue(valueType *address)
|
||||||
{
|
{
|
||||||
return(address->kindOfValue == ABSOLUTE_VALUE);
|
return(address->kindOfValue == ABSOLUTE_VALUE);
|
||||||
|
@ -305,8 +296,6 @@ createArray(expressionType *dimension, expressionListType *initializers)
|
||||||
arrayType *result;
|
arrayType *result;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
valueType *newValue(valueKindType kindOfValue, int value, operandKindType addressMode);
|
|
||||||
|
|
||||||
initCount = expressionListLength(initializers);
|
initCount = expressionListLength(initializers);
|
||||||
if ((int)dimension == -1) {
|
if ((int)dimension == -1) {
|
||||||
arraySize = initCount;
|
arraySize = initCount;
|
||||||
|
@ -378,7 +367,6 @@ expressionListLength(expressionListType *expressionList)
|
||||||
fieldValue(symbolTableEntryType *symbol)
|
fieldValue(symbolTableEntryType *symbol)
|
||||||
{
|
{
|
||||||
valueType *value;
|
valueType *value;
|
||||||
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) {
|
||||||
|
@ -458,8 +446,6 @@ isExternal(symbolTableEntryType *symbol)
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
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 &&
|
||||||
context->usage != DEAD_SYMBOL);
|
context->usage != DEAD_SYMBOL);
|
||||||
|
@ -747,8 +733,6 @@ swab(int i)
|
||||||
valueType *
|
valueType *
|
||||||
swabValue(valueType *value)
|
swabValue(valueType *value)
|
||||||
{
|
{
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
@ -766,9 +750,6 @@ valueField(symbolTableEntryType *symbol, valueType *value)
|
||||||
{
|
{
|
||||||
symbolInContextType *workingContext;
|
symbolInContextType *workingContext;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
|
||||||
|
|
||||||
symbol = effectiveSymbol(symbol, &workingContext);
|
symbol = effectiveSymbol(symbol, &workingContext);
|
||||||
expand(moreLabel("%s:", symbol->symbolName));
|
expand(moreLabel("%s:", symbol->symbolName));
|
||||||
if (workingContext->usage == DEAD_SYMBOL)
|
if (workingContext->usage == DEAD_SYMBOL)
|
||||||
|
@ -791,10 +772,6 @@ valueLabel(symbolTableEntryType *symbol, valueType *value)
|
||||||
{
|
{
|
||||||
symbolInContextType *workingContext;
|
symbolInContextType *workingContext;
|
||||||
|
|
||||||
symbolTableEntryType *generateLocalLabel(symbolTableEntryType *symbol);
|
|
||||||
symbolInContextType *getBaseContext(symbolTableEntryType *identifier);
|
|
||||||
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
|
||||||
|
|
||||||
symbol = effectiveSymbol(symbol, &workingContext);
|
symbol = effectiveSymbol(symbol, &workingContext);
|
||||||
expand(moreLabel("%s:", symbol->symbolName));
|
expand(moreLabel("%s:", symbol->symbolName));
|
||||||
if (workingContext->usage == DEAD_SYMBOL)
|
if (workingContext->usage == DEAD_SYMBOL)
|
||||||
|
@ -838,8 +815,6 @@ createFixup(expressionType *expression, addressType location, fixupKindType kind
|
||||||
{
|
{
|
||||||
fixupListType *newFixup;
|
fixupListType *newFixup;
|
||||||
|
|
||||||
expressionType *generateFixupExpression(expressionType *expression);
|
|
||||||
|
|
||||||
if (debug || emitPrint)
|
if (debug || emitPrint)
|
||||||
printCreateFixup(expression, location, kindOfFixup);
|
printCreateFixup(expression, location, kindOfFixup);
|
||||||
newFixup = typeAlloc(fixupListType);
|
newFixup = typeAlloc(fixupListType);
|
||||||
|
@ -869,9 +844,6 @@ createFixup(expressionType *expression, addressType location, fixupKindType kind
|
||||||
void
|
void
|
||||||
finishUp(void)
|
finishUp(void)
|
||||||
{
|
{
|
||||||
void performFixups(fixupListType *fixups);
|
|
||||||
void performStartAddressFixup(void);
|
|
||||||
|
|
||||||
if (listingOn)
|
if (listingOn)
|
||||||
terminateListingFiles();
|
terminateListingFiles();
|
||||||
performFixups(fixupList);
|
performFixups(fixupList);
|
||||||
|
@ -1036,8 +1008,6 @@ performStartAddressFixup(void)
|
||||||
{
|
{
|
||||||
expressionType *startAddressExpression;
|
expressionType *startAddressExpression;
|
||||||
|
|
||||||
expressionType *generateFixupExpression(expressionType *expression);
|
|
||||||
|
|
||||||
startAddressExpression = (expressionType *)startAddress;
|
startAddressExpression = (expressionType *)startAddress;
|
||||||
startAddress = evaluateExpression(startAddressExpression,NO_FIXUP_OK);
|
startAddress = evaluateExpression(startAddressExpression,NO_FIXUP_OK);
|
||||||
if (startAddress->kindOfValue == UNDEFINED_VALUE &&
|
if (startAddress->kindOfValue == UNDEFINED_VALUE &&
|
||||||
|
@ -1163,8 +1133,6 @@ effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTa
|
||||||
expressionType *expression;
|
expressionType *expression;
|
||||||
environmentType *saveEnvironment;
|
environmentType *saveEnvironment;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
context = getWorkingContext(symbol);
|
context = getWorkingContext(symbol);
|
||||||
saveEnvironment = currentEnvironment;
|
saveEnvironment = currentEnvironment;
|
||||||
while (context != NULL && context->usage == ARGUMENT_SYMBOL &&
|
while (context != NULL && context->usage == ARGUMENT_SYMBOL &&
|
||||||
|
@ -1193,9 +1161,6 @@ effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTa
|
||||||
symbolTableEntryType *
|
symbolTableEntryType *
|
||||||
generateLocalLabel(symbolTableEntryType *symbol)
|
generateLocalLabel(symbolTableEntryType *symbol)
|
||||||
{
|
{
|
||||||
stringType *localLabelString(symbolTableEntryType *symbol);
|
|
||||||
symbolTableEntryType *lookupOrEnterSymbol(stringType *s, symbolUsageKindType kind);
|
|
||||||
|
|
||||||
return(lookupOrEnterSymbol(localLabelString(symbol), LABEL_SYMBOL));
|
return(lookupOrEnterSymbol(localLabelString(symbol), LABEL_SYMBOL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,8 +1196,6 @@ localLabelString(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(char *s);
|
|
||||||
|
|
||||||
sprintf(nameUnderConstruction, "_%d_", localLabelTagValue(symbol));
|
sprintf(nameUnderConstruction, "_%d_", localLabelTagValue(symbol));
|
||||||
strncat(nameUnderConstruction, &(symbName(symbol)[1]),
|
strncat(nameUnderConstruction, &(symbName(symbol)[1]),
|
||||||
TEMP_SYMBOL_SIZE_LIMIT);
|
TEMP_SYMBOL_SIZE_LIMIT);
|
||||||
|
@ -1244,9 +1207,6 @@ localLabelTagValue(symbolTableEntryType *symbol)
|
||||||
{
|
{
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
void addNewLocalVariable(symbolTableEntryType *symbol);
|
|
||||||
|
|
||||||
context = getWorkingContext(symbol);
|
context = getWorkingContext(symbol);
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
botch("local label doesn't have symbol context\n");
|
botch("local label doesn't have symbol context\n");
|
||||||
|
@ -1264,7 +1224,6 @@ localLabelTagValue(symbolTableEntryType *symbol)
|
||||||
addBreak(codeBreakKindType kind, int data)
|
addBreak(codeBreakKindType kind, int data)
|
||||||
{
|
{
|
||||||
codeBreakType *newBreak;
|
codeBreakType *newBreak;
|
||||||
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) {
|
||||||
|
@ -1278,8 +1237,6 @@ addBreak(codeBreakKindType kind, int data)
|
||||||
void
|
void
|
||||||
reserveAbsolute(addressType startAddress, int blockSize)
|
reserveAbsolute(addressType startAddress, int blockSize)
|
||||||
{
|
{
|
||||||
reservationListType *buildReservation(addressType startAddress, int blockSize, reservationListType *nextReservation);
|
|
||||||
|
|
||||||
if (reservationList != NULL && reservationList->startAddress +
|
if (reservationList != NULL && reservationList->startAddress +
|
||||||
reservationList->blockSize == startAddress)
|
reservationList->blockSize == startAddress)
|
||||||
reservationList->blockSize += blockSize;
|
reservationList->blockSize += blockSize;
|
||||||
|
|
|
@ -30,12 +30,23 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "actions.h"
|
||||||
|
#include "debugPrint.h"
|
||||||
#include "emitBranch.h"
|
#include "emitBranch.h"
|
||||||
|
#include "emitStuff.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
#include "expressionSemantics.h"
|
#include "expressionSemantics.h"
|
||||||
|
#include "fixups.h"
|
||||||
|
#include "garbage.h"
|
||||||
|
#include "lexer.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "lookups.h"
|
||||||
#include "operandStuff.h"
|
#include "operandStuff.h"
|
||||||
#include "parserMisc.h"
|
#include "parserMisc.h"
|
||||||
#include "semanticMisc.h"
|
#include "semanticMisc.h"
|
||||||
#include "statementSemantics.h"
|
#include "statementSemantics.h"
|
||||||
|
#include "structSemantics.h"
|
||||||
|
#include "tokenStrings.h"
|
||||||
|
|
||||||
operandType *dbOperand; /* safe temps for dbx hacking */
|
operandType *dbOperand; /* safe temps for dbx hacking */
|
||||||
expressionType *dbExpression;
|
expressionType *dbExpression;
|
||||||
|
@ -54,48 +65,7 @@ bool nullStatementFlag = FALSE;
|
||||||
#define expansionOff() {saveExpansion=expandMacros; expandMacros=FALSE;}
|
#define expansionOff() {saveExpansion=expandMacros; expandMacros=FALSE;}
|
||||||
#define expansionOn() expandMacros=saveExpansion;
|
#define expansionOn() expandMacros=saveExpansion;
|
||||||
|
|
||||||
|
void
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
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)
|
assembleBlock(blockType *block)
|
||||||
{
|
{
|
||||||
nullAssemble(block);
|
nullAssemble(block);
|
||||||
|
@ -1185,13 +1155,7 @@ assembleWordStatement(wordStatementBodyType *wordStatement)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
assembleStatementBody(kind, body, cumulativeLineNumber, worryAboutIf,
|
assembleStatementBody(statementKindType kind, statementBodyType body, int cumulativeLineNumber, bool worryAboutIf, simpleFixupListType **ifFixupList)
|
||||||
ifFixupList)
|
|
||||||
statementKindType kind;
|
|
||||||
statementBodyType body;
|
|
||||||
int cumulativeLineNumber;
|
|
||||||
bool worryAboutIf;
|
|
||||||
simpleFixupListType **ifFixupList;
|
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
|
|
|
@ -29,22 +29,15 @@
|
||||||
|
|
||||||
#include "macrossTypes.h"
|
#include "macrossTypes.h"
|
||||||
#include "macrossGlobals.h"
|
#include "macrossGlobals.h"
|
||||||
|
#include "emitStuff.h"
|
||||||
|
#include "errorStuff.h"
|
||||||
|
#include "listing.h"
|
||||||
|
#include "parserMisc.h"
|
||||||
|
#include "semanticMisc.h"
|
||||||
|
#include "statementSemantics.h"
|
||||||
|
#include "structSemantics.h"
|
||||||
|
|
||||||
|
void
|
||||||
extern void botch (char *message, ...);
|
|
||||||
extern void error (errorType theError, ...);
|
|
||||||
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)
|
putStructFixups(int base, fixupListType *fixups)
|
||||||
{
|
{
|
||||||
fixupListType *newFixup;
|
fixupListType *newFixup;
|
||||||
|
@ -96,8 +89,6 @@ instantiateStruct(structStatementBodyType *structStatement)
|
||||||
int base;
|
int base;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolInContextType *getWorkingContext(symbolTableEntryType *identifier);
|
|
||||||
|
|
||||||
#define structInstance ((structInstanceType *) context->value->value)
|
#define structInstance ((structInstanceType *) context->value->value)
|
||||||
|
|
||||||
context = getWorkingContext(structStatement->structName);
|
context = getWorkingContext(structStatement->structName);
|
||||||
|
@ -157,8 +148,6 @@ assembleStructDefinition(structStatementBodyType *structStatement)
|
||||||
symbolTableEntryType *name;
|
symbolTableEntryType *name;
|
||||||
symbolInContextType *context;
|
symbolInContextType *context;
|
||||||
|
|
||||||
symbolTableEntryType *effectiveSymbol(symbolTableEntryType *symbol, symbolInContextType **assignmentTargetContext);
|
|
||||||
|
|
||||||
name = effectiveSymbol(structStatement->structName, &context);
|
name = effectiveSymbol(structStatement->structName, &context);
|
||||||
if (context == NULL)
|
if (context == NULL)
|
||||||
botch("struct definition doesn't have working context\n");
|
botch("struct definition doesn't have working context\n");
|
||||||
|
|
Loading…
Reference in New Issue