2016-01-14 15:23:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1987 Fujitsu
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2014-05-04 05:20:34 +00:00
|
|
|
/*
|
|
|
|
debugPrint.c -- Routines to print out things for debugging purposes.
|
|
|
|
|
|
|
|
Chip Morningstar -- Lucasfilm Ltd.
|
|
|
|
|
|
|
|
5-November-1984
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "macrossTypes.h"
|
|
|
|
#include "macrossGlobals.h"
|
2016-01-24 05:50:12 +00:00
|
|
|
#include "debugPrint.h"
|
2014-05-04 05:20:34 +00:00
|
|
|
#include "y.tab.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Print out the parse-tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int tablevel = 0;
|
|
|
|
|
|
|
|
/* Fundamental nop print operation */
|
|
|
|
#define nullPrint(thing) if (thing==NULL) { tab(); printf("()\n"); return; }
|
|
|
|
|
|
|
|
/* For keeping nested structures looking pretty */
|
2016-01-23 18:18:42 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
tab(void)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
int n;
|
|
|
|
|
|
|
|
n = tablevel;
|
|
|
|
while (n-- > 0)
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
The following routines print readable strings for the values of various
|
|
|
|
enumerated types and pre-defined constants. Each contains a static table
|
|
|
|
of strings that must be kept consistent with the type or set of
|
|
|
|
definitions that it represents.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printAssignmentKind(assignmentKindType assignmentKind)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
/* This table MUST be maintained congruently with the definition of the
|
|
|
|
enumerated type 'assignmentKindType'. */
|
|
|
|
static char *assignmentTable[] = {
|
|
|
|
"ASSIGN_ASSIGN",
|
|
|
|
"ADD_ASSIGN",
|
|
|
|
"SUB_ASSIGN",
|
|
|
|
"MUL_ASSIGN",
|
|
|
|
"DIV_ASSIGN",
|
|
|
|
"MOD_ASSIGN",
|
|
|
|
"AND_ASSIGN",
|
|
|
|
"OR_ASSIGN",
|
|
|
|
"XOR_ASSIGN",
|
|
|
|
"LEFT_SHIFT_ASSIGN",
|
|
|
|
"RIGHT_SHIFT_ASSIGN",
|
|
|
|
"NO_ASSIGN",
|
|
|
|
};
|
|
|
|
|
|
|
|
printf("%s", assignmentTable[(int)assignmentKind]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printExpressionKind(expressionTermKindType kind)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
/* This table MUST be maintained congruently with the definition of the
|
|
|
|
enumerated type 'expressionTermKindType'. */
|
|
|
|
static char *expressionKindTable[] = {
|
|
|
|
"identifier expr",
|
|
|
|
"function call expr",
|
|
|
|
"number expr",
|
|
|
|
"subexpression",
|
|
|
|
"unop expr",
|
|
|
|
"binop expr",
|
|
|
|
"preop expr",
|
|
|
|
"postop expr",
|
|
|
|
"here",
|
|
|
|
"assignment expr",
|
|
|
|
"condition code expr",
|
|
|
|
"string expr",
|
|
|
|
"value",
|
|
|
|
"array expr",
|
|
|
|
};
|
|
|
|
|
|
|
|
printf("%s", expressionKindTable[(int)kind]);
|
|
|
|
}
|
|
|
|
|
|
|
|
stringType *
|
2016-01-23 18:18:42 +00:00
|
|
|
statementKindString(statementKindType kind)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
/* This table MUST be maintained congruently with the definition of
|
|
|
|
the enumerated type 'statementKindType'. */
|
|
|
|
static char *statementKindTable[] = {
|
|
|
|
"if",
|
|
|
|
"while",
|
|
|
|
"do_while",
|
|
|
|
"do_until",
|
|
|
|
"word",
|
|
|
|
"dbyte",
|
|
|
|
"byte",
|
|
|
|
"string",
|
|
|
|
"struct",
|
|
|
|
"instruction",
|
|
|
|
"define",
|
|
|
|
"undefine",
|
|
|
|
"mif",
|
|
|
|
"freturn",
|
|
|
|
"mfor",
|
|
|
|
"mdo_while",
|
|
|
|
"mdo_until",
|
|
|
|
"include",
|
|
|
|
"extern",
|
|
|
|
"start",
|
|
|
|
"align",
|
|
|
|
"org",
|
|
|
|
"rel",
|
|
|
|
"perform",
|
|
|
|
"block",
|
|
|
|
"mwhile",
|
|
|
|
"mdefine",
|
|
|
|
"null",
|
|
|
|
"group",
|
|
|
|
"macro",
|
|
|
|
"function",
|
|
|
|
"variable",
|
|
|
|
"mvariable",
|
|
|
|
"constrain",
|
|
|
|
"assert",
|
|
|
|
"mswitch",
|
|
|
|
"long",
|
|
|
|
"target",
|
|
|
|
};
|
|
|
|
return(statementKindTable[(int)kind]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printStatementKind(statementKindType kind)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
printf("%s", statementKindString(kind));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
These routines collectively print expressions and values.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printValue(valueType *value)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
/* This table MUST be maintained congruently with the definition of the
|
|
|
|
enumerated type 'valueKindType'. */
|
|
|
|
static char *valueKindTable[NUM_OF_VALUE_KINDS] = {
|
|
|
|
"ABSOLUTE_VALUE",
|
|
|
|
"DATA_VALUE",
|
|
|
|
"RELOCATABLE_VALUE",
|
|
|
|
"BSS_VALUE",
|
|
|
|
"STRUCT_VALUE",
|
|
|
|
"FIELD_VALUE",
|
|
|
|
"MACRO_VALUE",
|
|
|
|
"OPERAND_VALUE",
|
|
|
|
"STRING_VALUE",
|
|
|
|
"CONDITION_VALUE",
|
|
|
|
"UNDEFINED_VALUE",
|
|
|
|
"FUNCTION_VALUE",
|
|
|
|
"BLOCK_VALUE",
|
|
|
|
"BUILT_IN_FUNCTION_VALUE",
|
|
|
|
"ARRAY_VALUE",
|
|
|
|
"FAIL",
|
|
|
|
};
|
|
|
|
|
|
|
|
if (value != NULL) {
|
|
|
|
printf("(%s: %d==0x%x ", valueKindTable[(int)value->
|
|
|
|
kindOfValue], value->value, value->value);
|
|
|
|
printOperandKind(value->addressMode);
|
|
|
|
printf(")");
|
|
|
|
} else
|
|
|
|
printf("(no value)");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printSymbol(symbolTableEntryType *symbol)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
/* This table MUST be maintained congruent with the definition of the
|
|
|
|
enumerated type 'symbolUsageKindType'. */
|
|
|
|
static char *symbolUsageTable[] = {
|
|
|
|
"STRUCT_NAME_SYMBOL",
|
|
|
|
"STRUCT_FIELD_SYMBOL",
|
|
|
|
"MACRO_SYMBOL",
|
|
|
|
"ARGUMENT_SYMBOL",
|
|
|
|
"LABEL_SYMBOL",
|
|
|
|
"EXTERNAL_SYMBOL",
|
|
|
|
"VARIABLE_SYMBOL",
|
|
|
|
"MVARIABLE_SYMBOL",
|
|
|
|
"UNKNOWN_SYMBOL",
|
|
|
|
"DEAD_SYMBOL",
|
|
|
|
"FUNCTION_SYMBOL",
|
|
|
|
"BUILT_IN_FUNCTION_SYMBOL",
|
|
|
|
"NESTED_UNKNOWN_SYMBOL",
|
|
|
|
"DEFINE_SYMBOL",
|
|
|
|
"MDEFINE_SYMBOL",
|
|
|
|
"UNKNOWN_FUNCTION_SYMBOL",
|
|
|
|
"UNKNOWN_MACRO_SYMBOL",
|
|
|
|
};
|
|
|
|
|
|
|
|
nullPrint(symbol);
|
|
|
|
tab(); printf("(symbol: %s ", symbol->symbolName);
|
|
|
|
printValue(symbol->context->value);
|
|
|
|
printf(" %d %s", symbol->context->attributes,
|
|
|
|
symbolUsageTable[(int)symbol->context->usage]);
|
|
|
|
if (symbol->context->pushedContexts != NULL)
|
|
|
|
printf(" ...");
|
|
|
|
printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printArgumentDefinitionList(argumentDefinitionListType *list)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(list);
|
|
|
|
tab(); printf("(arguments:\n");
|
|
|
|
tablevel++;
|
|
|
|
while (list != NULL) {
|
|
|
|
printSymbol(list->theArgument);
|
|
|
|
list = list->nextArgument;
|
|
|
|
}
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printBlock(blockType *block)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(block);
|
|
|
|
tab(); printf("(block:\n");
|
|
|
|
tablevel++;
|
|
|
|
printStatement(block);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printArrayTerm(arrayTermType *arrayTerm)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(arrayTerm);
|
|
|
|
tab(); printf("(array\n");
|
|
|
|
tablevel++;
|
|
|
|
printExpression(arrayTerm->arrayName);
|
|
|
|
printExpression(arrayTerm->arrayIndex);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printAssignmentTerm(binopTermType *assignmentTerm)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
nullPrint(assignmentTerm);
|
|
|
|
tab(); printf("(assignment [");
|
|
|
|
printAssignmentKind(assignmentTerm->binop);
|
|
|
|
printf("]\n");
|
|
|
|
tablevel++;
|
|
|
|
printExpression(assignmentTerm->leftArgument);
|
|
|
|
printExpression(assignmentTerm->rightArgument);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printBinopTerm(binopTermType *binopTerm)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(binopTerm);
|
|
|
|
tab(); printf("(binop [");
|
|
|
|
printToken(binopTerm->binop);
|
|
|
|
printf("]\n");
|
|
|
|
tablevel++;
|
|
|
|
printExpression(binopTerm->leftArgument);
|
|
|
|
if (binopTerm->binop == SELECT)
|
|
|
|
printIdentifier(binopTerm->rightArgument);
|
|
|
|
else
|
|
|
|
printExpression(binopTerm->rightArgument);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printFunctionCall(functionCallTermType *functionCall)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(functionCall);
|
|
|
|
tab(); printf("(function call %s\n", functionCall->functionName->
|
|
|
|
symbolName);
|
|
|
|
tablevel++;
|
|
|
|
printOperandList(functionCall->parameters);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printHere(void)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
tab(); printf("(here)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printIdentifier(symbolTableEntryType *identifier)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(identifier);
|
|
|
|
printSymbol(identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printNumber(numberTermType number)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
tab(); printf("(number: %d)\n", number);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printPostopTerm(postOpTermType *postopTerm)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(postopTerm);
|
|
|
|
tab(); printf("(postop [");
|
|
|
|
printToken(postopTerm->postOp);
|
|
|
|
printf("]\n");
|
|
|
|
tablevel++;
|
|
|
|
printExpression(postopTerm->postOpArgument);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printPreopTerm(preOpTermType *preopTerm)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(preopTerm);
|
|
|
|
tab(); printf("(preop [");
|
|
|
|
printToken(preopTerm->preOp);
|
|
|
|
printf("]\n");
|
|
|
|
tablevel++;
|
|
|
|
printExpression(preopTerm->preOpArgument);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printUnopTerm(unopTermType *unopTerm)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(unopTerm);
|
|
|
|
tab(); printf("(unop [");
|
|
|
|
printToken(unopTerm->unop);
|
|
|
|
printf("]\n");
|
|
|
|
tablevel++;
|
|
|
|
printExpression(unopTerm->unopArgument);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printExpression(expressionType *expression)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(expression);
|
|
|
|
tab(); printf("(expression: [");
|
|
|
|
printExpressionKind(expression->kindOfTerm);
|
|
|
|
printf("]\n");
|
|
|
|
tablevel++;
|
|
|
|
switch (expression->kindOfTerm) {
|
|
|
|
|
|
|
|
case ARRAY_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printArrayTerm(expression->expressionTerm.arrayUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ASSIGN_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printAssignmentTerm(expression->expressionTerm.binopUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BINOP_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printBinopTerm(expression->expressionTerm.binopUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONDITION_CODE_EXPR:
|
2016-01-23 17:34:23 +00:00
|
|
|
printCondition(expression->expressionTerm.conditionTypeUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FUNCTION_CALL_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printFunctionCall(expression->expressionTerm.functionCallUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HERE_EXPR:
|
|
|
|
printHere();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDENTIFIER_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printIdentifier(expression->expressionTerm.symbolTableUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NUMBER_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printNumber(expression->expressionTerm.numberUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case POSTOP_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printPostopTerm(expression->expressionTerm.postOpUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PREOP_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printPreopTerm(expression->expressionTerm.preOpUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRING_EXPR:
|
|
|
|
tab(); printf("%s\n", expression->expressionTerm);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SUBEXPRESSION_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printExpression(expression->expressionTerm.expressionUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNOP_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printUnopTerm(expression->expressionTerm.unopUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VALUE_EXPR:
|
2014-05-04 05:47:33 +00:00
|
|
|
printValue(expression->expressionTerm.valueUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("eh? funny expression kind %d\n",
|
|
|
|
expression->kindOfTerm);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printExpressionList(expressionListType *expressionList)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
while (expressionList != NULL) {
|
|
|
|
printExpression(expressionList->theExpression);
|
|
|
|
expressionList = expressionList->nextExpression;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printIdentifierList(identifierListType *identifierList)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(identifierList);
|
|
|
|
printSymbol(identifierList->theSymbol);
|
|
|
|
if (identifierList->nextIdentifier != NULL)
|
|
|
|
printIdentifierList(identifierList->nextIdentifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
These routines collectively print statements and statement fragments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printCase(caseType *aCase)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
tab(); printf("(case:\n"); tablevel++;
|
|
|
|
if (aCase->caseTags == NULL) {
|
|
|
|
tab(); printf("(default case)\n");
|
|
|
|
} else {
|
|
|
|
printExpressionList(aCase->caseTags);
|
|
|
|
}
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
tab(); printf("(body:\n"); tablevel++;
|
|
|
|
printBlock(aCase->caseBody);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printCaseList(caseListType *caseList)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
tab(); printf("(cases:\n");
|
|
|
|
tablevel++;
|
|
|
|
while (caseList != NULL) {
|
|
|
|
printCase(caseList->theCase);
|
|
|
|
caseList = caseList->nextCase;
|
|
|
|
}
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMacro(macroTableEntryType *macroInstruction)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(macroInstruction);
|
|
|
|
tab(); printf("(macro: %s)\n", macroInstruction->macroName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printOpcode(opcodeTableEntryType *opcode)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(opcode);
|
|
|
|
tab(); printf("(opcode: %s)\n", opcode->mnemonic);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printOperandList(operandListType *operandList)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(operandList);
|
|
|
|
printOperand(operandList);
|
|
|
|
if (operandList->nextOperand != NULL)
|
|
|
|
printOperandList(operandList->nextOperand);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printAlignStatement(alignStatementBodyType *alignStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(alignStatement);
|
|
|
|
printExpression(alignStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printAssertStatement(assertStatementBodyType *assertStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(assertStatement);
|
|
|
|
printExpression(assertStatement->condition);
|
|
|
|
printExpression(assertStatement->message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printBlockStatement(blockStatementBodyType *blockStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(blockStatement);
|
|
|
|
printExpressionList(blockStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printByteStatement(byteStatementBodyType *byteStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(byteStatement);
|
|
|
|
printExpressionList(byteStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printConstrainStatement(constrainStatementBodyType *constrainStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(constrainStatement);
|
|
|
|
printExpression(constrainStatement->constraint);
|
|
|
|
printBlock(constrainStatement->constrainedBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printDbyteStatement(dbyteStatementBodyType *dbyteStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(dbyteStatement);
|
|
|
|
printExpressionList(dbyteStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printDefineStatement(defineStatementBodyType *defineStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(defineStatement);
|
|
|
|
printSymbol(defineStatement->theSymbol);
|
|
|
|
printExpression(defineStatement->theValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printDoUntilStatement(doUntilStatementBodyType *doUntilStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(doUntilStatement);
|
|
|
|
printBlock(doUntilStatement->doUntilLoop);
|
|
|
|
tab(); printf("(condition: ");
|
|
|
|
printCondition(doUntilStatement->doUntilCondition);
|
|
|
|
printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printDoWhileStatement(doWhileStatementBodyType *doWhileStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(doWhileStatement);
|
|
|
|
printBlock(doWhileStatement->doWhileLoop);
|
|
|
|
tab(); printf("(condition: ");
|
|
|
|
printCondition(doWhileStatement->doWhileCondition);
|
|
|
|
printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printExternStatement(externStatementBodyType *externStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(externStatement);
|
|
|
|
printIdentifierList(externStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printFreturnStatement(freturnStatementBodyType *freturnStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(freturnStatement);
|
|
|
|
printExpression(freturnStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printFunctionStatement(functionStatementBodyType *functionStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(functionStatement);
|
|
|
|
tab();printf("(function name: %s)\n",functionStatement->functionName);
|
|
|
|
printArgumentDefinitionList(functionStatement->theArguments);
|
|
|
|
printBlock(functionStatement->theBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printIfStatement(ifStatementBodyType *ifStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(ifStatement);
|
|
|
|
tab(); printf("(condition: ");
|
|
|
|
printCondition(ifStatement->ifCondition);
|
|
|
|
printf(")\n");
|
|
|
|
printBlock(ifStatement->consequence);
|
|
|
|
tab(); printf("(else:\n");
|
|
|
|
tablevel++;
|
2014-05-04 05:47:33 +00:00
|
|
|
printIfStatement(ifStatement->continuation.blockUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printIncludeStatement(includeStatementBodyType *includeStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(includeStatement);
|
|
|
|
printExpression(includeStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printInstructionStatement(instructionStatementBodyType *instructionStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(instructionStatement);
|
|
|
|
switch(instructionStatement->kindOfInstruction) {
|
|
|
|
case OPCODE_INSTRUCTION:
|
2014-05-04 05:47:33 +00:00
|
|
|
printOpcode(instructionStatement->theInstruction.opcodeUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACRO_INSTRUCTION:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMacro(instructionStatement->theInstruction.macroUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("huh? instruction type=%d\n", instructionStatement->
|
|
|
|
kindOfInstruction);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printOperandList(instructionStatement->theOperands);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printLongStatement(longStatementBodyType *longStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(longStatement);
|
|
|
|
printExpressionList(longStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMacroStatement(macroStatementBodyType *macroStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(macroStatement);
|
|
|
|
tab(); printf("(macro name: %s)\n", macroStatement->theMacro);
|
|
|
|
printArgumentDefinitionList(macroStatement->theArguments);
|
|
|
|
printBlock(macroStatement->theBlock);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMdefineStatement(defineStatementBodyType *mdefineStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mdefineStatement);
|
|
|
|
printSymbol(mdefineStatement->theSymbol);
|
|
|
|
printExpression(mdefineStatement->theValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMdoUntilStatement(mdoUntilStatementBodyType *mdoUntilStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mdoUntilStatement);
|
|
|
|
printBlock(mdoUntilStatement->mdoUntilLoop);
|
|
|
|
printExpression(mdoUntilStatement->mdoUntilCondition);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMdoWhileStatement(mdoWhileStatementBodyType *mdoWhileStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mdoWhileStatement);
|
|
|
|
printBlock(mdoWhileStatement->mdoWhileLoop);
|
|
|
|
printExpression(mdoWhileStatement->mdoWhileCondition);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMforStatement(mforStatementBodyType *mforStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mforStatement);
|
|
|
|
printExpression(mforStatement->initExpression);
|
|
|
|
printExpression(mforStatement->testExpression);
|
|
|
|
printExpression(mforStatement->incrExpression);
|
|
|
|
printBlock(mforStatement->forLoop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMifStatement(mifStatementBodyType *mifStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mifStatement);
|
|
|
|
printExpression(mifStatement->mifCondition);
|
|
|
|
printBlock(mifStatement->mifConsequence);
|
|
|
|
tab(); printf("(melse:\n");
|
|
|
|
tablevel++;
|
2014-05-04 05:47:33 +00:00
|
|
|
printMifStatement(mifStatement->mifContinuation.mifContinuationBodyUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMswitchStatement(mswitchStatementBodyType *mswitchStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mswitchStatement);
|
|
|
|
printExpression(mswitchStatement->switchExpression);
|
|
|
|
printCaseList(mswitchStatement->cases);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMvariableStatement(mvariableStatementBodyType *mvariableStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mvariableStatement);
|
|
|
|
printSymbol(mvariableStatement->theSymbol);
|
|
|
|
printExpression(mvariableStatement->theValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printMwhileStatement(mwhileStatementBodyType *mwhileStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(mwhileStatement);
|
|
|
|
printExpression(mwhileStatement->mwhileCondition);
|
|
|
|
printBlock(mwhileStatement->mwhileLoop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printOrgStatement(orgStatementBodyType *orgStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(orgStatement);
|
|
|
|
printExpression(orgStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printPerformStatement(performStatementBodyType *performStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(performStatement);
|
|
|
|
printExpression(performStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printRelStatement(relStatementBodyType *relStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
/* there's nothing here... */
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printStartStatement(startStatementBodyType *startStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(startStatement);
|
|
|
|
printExpression(startStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printStringStatement(stringStatementBodyType *stringStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(stringStatement);
|
|
|
|
printExpressionList(stringStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printStructStatement(structStatementBodyType *structStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(structStatement);
|
|
|
|
printSymbol(structStatement->structName);
|
|
|
|
printBlock(structStatement->structBody);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printTargetStatement(targetStatementBodyType *targetStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(targetStatement);
|
|
|
|
printExpression(targetStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printUndefineStatement(undefineStatementBodyType *undefineStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(undefineStatement);
|
|
|
|
printIdentifierList(undefineStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printVariableStatement(variableStatementBodyType *variableStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(variableStatement);
|
|
|
|
printSymbol(variableStatement->theSymbol);
|
|
|
|
printExpression(variableStatement->theValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printWhileStatement(whileStatementBodyType *whileStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(whileStatement);
|
|
|
|
tab(); printf("(condition: ");
|
|
|
|
printCondition(whileStatement->whileCondition);
|
|
|
|
printf(")\n");
|
|
|
|
printBlock(whileStatement->whileLoop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printWordStatement(wordStatementBodyType *wordStatement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(wordStatement);
|
|
|
|
printExpressionList(wordStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printLabelList(labelListType *labelList)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(labelList);
|
|
|
|
tab(); printf("(\n");
|
|
|
|
tablevel++;
|
|
|
|
while (labelList != NULL) {
|
|
|
|
printSymbol(labelList->theLabel);
|
|
|
|
labelList = labelList->nextLabel;
|
|
|
|
}
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printStatementBody(statementKindType kind, statementBodyType body)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
switch (kind) {
|
|
|
|
|
|
|
|
case ALIGN_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printAlignStatement(body.alignUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ASSERT_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printAssertStatement(body.assertUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printBlockStatement(body.blockUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BYTE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printByteStatement(body.byteUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CONSTRAIN_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printConstrainStatement(body.constrainUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DBYTE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printDbyteStatement(body.dbyteUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DEFINE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printDefineStatement(body.defineUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DO_UNTIL_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printDoUntilStatement(body.doUntilUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DO_WHILE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printDoWhileStatement(body.doWhileUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EXTERN_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printExternStatement(body.externUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FRETURN_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printFreturnStatement(body.freturnUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FUNCTION_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printFunctionStatement(body.functionUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GROUP_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printBlock(body.groupUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IF_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printIfStatement(body.ifUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INCLUDE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printIncludeStatement(body.includeUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INSTRUCTION_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printInstructionStatement(body.instructionUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LONG_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printLongStatement(body.longUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MACRO_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMacroStatement(body.macroUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MDEFINE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMdefineStatement(body.defineUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MDO_UNTIL_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMdoUntilStatement(body.mdoUntilUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MDO_WHILE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMdoWhileStatement(body.mdoWhileUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MFOR_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMforStatement(body.mforUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MIF_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMifStatement(body.mifUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MSWITCH_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMswitchStatement(body.mswitchUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MVARIABLE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMvariableStatement(body.mvariableUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MWHILE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printMwhileStatement(body.mwhileUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case NULL_STATEMENT:
|
|
|
|
/* do nothing */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ORG_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printOrgStatement(body.orgUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PERFORM_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printPerformStatement(body.performUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case REL_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printRelStatement(body.relUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case START_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printStartStatement(body.startUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRING_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printStringStatement(body.stringUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STRUCT_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printStructStatement(body.structUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TARGET_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printTargetStatement(body.targetUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UNDEFINE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printUndefineStatement(body.undefineUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case VARIABLE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printVariableStatement(body.variableUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WHILE_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printWhileStatement(body.whileUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WORD_STATEMENT:
|
2014-05-04 05:47:33 +00:00
|
|
|
printWordStatement(body.wordUnion);
|
2014-05-04 05:20:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("Say what? statement kind=%d\n", kind);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printStatement(statementType *statement)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
nullPrint(statement);
|
|
|
|
tab(); printf("(statement[");
|
|
|
|
printStatementKind(statement->kindOfStatement);
|
|
|
|
printf("]: \n");
|
|
|
|
tablevel++;
|
|
|
|
printLabelList(statement->labels);
|
|
|
|
printStatementBody(statement->kindOfStatement,
|
|
|
|
statement->statementBody);
|
|
|
|
tablevel--;
|
|
|
|
tab(); printf(")\n");
|
|
|
|
if (statement->nextStatement != NULL)
|
|
|
|
printStatement(statement->nextStatement);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Other debug print routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printPendingFixupList(fixupListType *fixupList)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
printf("fixup list: (");
|
|
|
|
tablevel++;
|
|
|
|
while (fixupList != NULL) {
|
|
|
|
printExpression(fixupList->theFixupExpression);
|
|
|
|
fixupList = fixupList->nextFixup;
|
|
|
|
}
|
|
|
|
tablevel--;
|
|
|
|
printf(")\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printCreateFixup(expressionType *expression, addressType location, fixupKindType kindOfFixup)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
static char *fixupStringTable[] = {
|
|
|
|
"BYTE FIXUP",
|
|
|
|
"WORD FIXUP",
|
|
|
|
"NO FIXUP",
|
|
|
|
"OPERAND FIXUP",
|
|
|
|
"BYTE RELATIVE FIXUP",
|
|
|
|
"DBYTE FIXUP",
|
|
|
|
"NO FIXUP (OK)",
|
|
|
|
"LONG FIXUP",
|
|
|
|
"WORD RELATIVE FIXUP",
|
|
|
|
};
|
|
|
|
|
|
|
|
printf("created fixup: expr=0x%x at 0x%x (%s)\n", expression,
|
|
|
|
location, fixupStringTable[(int)kindOfFixup]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Print internal code buffers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printExpressionBuffer(void)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
int line;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
printf("expression length = %d:\n", expressionBufferSize);
|
|
|
|
for (line=0; line<expressionBufferSize; line+=16) {
|
|
|
|
printf(" %4x:", line);
|
|
|
|
for (i=line; i<line+16 && i<expressionBufferSize; i++)
|
|
|
|
printf(" %2x", expressionBuffer[i]);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printOneCodeBuffer(codeSegmentType *codeSegment, int bufferNum)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
int line;
|
|
|
|
int i;
|
|
|
|
int start;
|
|
|
|
int end;
|
|
|
|
|
|
|
|
start = bufferPosition(codeSegment->codeStartAddress);
|
|
|
|
end = bufferPosition(codeSegment->codeEndAddress);
|
|
|
|
|
|
|
|
printf("buffer 0x%x:\n", bufferNum*CODE_BUFFER_SIZE);
|
|
|
|
for (line=0; line<CODE_BUFFER_SIZE; line+=16) {
|
|
|
|
if (line+15<start || line>end){
|
|
|
|
/* skip it -- no code here */
|
|
|
|
} else {
|
|
|
|
printf(" %4x:", bufferNum*CODE_BUFFER_SIZE + line);
|
|
|
|
for (i=line; i<line+16; i++) {
|
|
|
|
if (i<start || i>end)
|
|
|
|
printf(" ");
|
|
|
|
else
|
|
|
|
printf(" %2x", (*(codeSegment->codeBuffer))[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printCodeBufferSection(codeRegionType *codeBufferSection)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
bool anyCodeThereFlag;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
anyCodeThereFlag = FALSE;
|
|
|
|
for (i=0; i<CODE_BUFFERS_IN_ADDRESS_SPACE; i++)
|
|
|
|
if (codeBufferSection->codeSegments[i] != NULL) {
|
|
|
|
printOneCodeBuffer(codeBufferSection->codeSegments[i],
|
|
|
|
i);
|
|
|
|
anyCodeThereFlag = TRUE;
|
|
|
|
}
|
|
|
|
if (!anyCodeThereFlag)
|
|
|
|
printf("no code in section\n");
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-01-23 18:18:42 +00:00
|
|
|
printCodeBuffers(void)
|
2014-05-04 05:20:34 +00:00
|
|
|
{
|
|
|
|
printf("absolute code:\n");
|
|
|
|
printCodeBufferSection(&absoluteCodeRegion);
|
|
|
|
printf("relocatable code:\n");
|
|
|
|
printCodeBufferSection(&relocatableCodeRegion);
|
|
|
|
}
|