From 4d5489cdea22f7dad1e3419476a98cab10138047 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 18 Jun 2022 16:39:39 +0300 Subject: [PATCH] Cleanup export.h See #42 --- src/export.cc | 28 ++++++++++++++++++++++++++-- src/export.h | 25 ------------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/export.cc b/src/export.cc index 2d2ce98..273ce9b 100644 --- a/src/export.cc +++ b/src/export.cc @@ -7,11 +7,35 @@ #include #include +typedef struct ExternalVariable { + char name[32]; + char* programName; + opcode_t type; + union { + int value; + char* stringValue; + }; +} ExternalVariable; + +typedef struct ExternalProcedure { + char name[32]; + Program* program; + int argumentCount; + int address; +} ExternalProcedure; + +static unsigned int _hashName(const char* identifier); +static ExternalProcedure* externalProcedureFind(const char* identifier); +static ExternalProcedure* externalProcedureAdd(const char* identifier); +static ExternalVariable* externalVariableFind(const char* identifier); +static ExternalVariable* externalVariableAdd(const char* identifier); +static void _removeProgramReferences(Program* program); + // 0x570C00 -ExternalProcedure gExternalProcedures[1013]; +static ExternalProcedure gExternalProcedures[1013]; // 0x57BA1C -ExternalVariable gExternalVariables[1013]; +static ExternalVariable gExternalVariables[1013]; // NOTE: Inlined. // diff --git a/src/export.h b/src/export.h index b8466c6..9371c83 100644 --- a/src/export.h +++ b/src/export.h @@ -3,34 +3,9 @@ #include "interpreter.h" -typedef struct ExternalVariable { - char name[32]; - char* programName; - opcode_t type; - union { - int value; - char* stringValue; - }; -} ExternalVariable; - -typedef struct ExternalProcedure { - char name[32]; - Program* program; - int argumentCount; - int address; -} ExternalProcedure; - -extern ExternalProcedure gExternalProcedures[1013]; -extern ExternalVariable gExternalVariables[1013]; - -ExternalProcedure* externalProcedureFind(const char* identifier); -ExternalProcedure* externalProcedureAdd(const char* identifier); -ExternalVariable* externalVariableFind(const char* identifier); -ExternalVariable* externalVariableAdd(const char* identifier); int externalVariableSetValue(Program* program, const char* identifier, opcode_t opcode, int data); int externalVariableGetValue(Program* program, const char* name, opcode_t* opcodePtr, int* dataPtr); int externalVariableCreate(Program* program, const char* identifier); -void _removeProgramReferences(Program* program); void _initExport(); void externalVariablesClear(); Program* externalProcedureGetProgram(const char* identifier, int* addressPtr, int* argumentCountPtr);