@@ -107,30 +107,31 @@ enum TargetPlatform
107107 PlatformUKNC = 2 ,
108108};
109109
110+ // NOTE: This enum should be in the same order as RuntimeSymbolNames array in model.cpp
110111enum RuntimeSymbol
111112{
112113 RuntimeNone = 0 ,
113- RuntimeWRCH = 1 ,
114- RuntimeWREOL = 2 ,
115- RuntimeWRAT = 3 ,
116- RuntimeWRSPC = 4 ,
117- RuntimeWRTAB = 5 ,
118- RuntimeWRCOM = 6 ,
119- RuntimeWRINT = 7 ,
120- RuntimeWRSNG = 8 ,
121- RuntimeWRST = 9 , // Write String
122- RuntimeSTOP = 10 , // Show stop message and stop
123- RuntimeERRR = 11 , // Show error message and stop
124- RuntimeReserved1 = 12 ,
125- RuntimeGETCR = 13 ,
126- RuntimeCURSR = 14 ,
127- RuntimeINPU = 15 , // INPUT read to buffer
128- RuntimeINPI = 16 , // INPUT Integer
129- RuntimeIMUL = 17 ,
130- RuntimeIDIV = 18 ,
131- RuntimeITOF = 19 , // Integer to Single conversion
132- RuntimeFTOI = 20 , // Single to Integer conversion
133- RuntimeReserved2 = 21 ,
114+ RuntimeINIT = 1 , // Initialization code to copy into the assembly code
115+ RuntimeTERM = 2 , // Termination code to copy into the assembly code
116+ RuntimeWRCH = 3 ,
117+ RuntimeWREOL = 4 ,
118+ RuntimeWRAT = 5 ,
119+ RuntimeWRSPC = 6 ,
120+ RuntimeWRTAB = 7 ,
121+ RuntimeWRCOM = 8 ,
122+ RuntimeWRINT = 9 ,
123+ RuntimeWRSNG = 10 ,
124+ RuntimeWRST = 11 , // Write String
125+ RuntimeSTOP = 12 , // Show stop message and stop
126+ RuntimeERRR = 13 , // Show error message and stop
127+ RuntimeGETCR = 14 ,
128+ RuntimeCURSR = 15 ,
129+ RuntimeINPU = 16 , // INPUT read to buffer
130+ RuntimeINPI = 17 , // INPUT Integer
131+ RuntimeIMUL = 18 ,
132+ RuntimeIDIV = 19 ,
133+ RuntimeITOF = 20 , // Integer to Single conversion
134+ RuntimeFTOI = 21 , // Single to Integer conversion
134135 RuntimeFUNPK = 22 , // Print Single to buffer
135136 RuntimeFFIX = 23 ,
136137 RuntimeFINT = 24 ,
@@ -158,6 +159,7 @@ enum RuntimeSymbol
158159 RuntimeINKEY = 46 ,
159160 RuntimeSTCP = 47 , // String copy
160161 RuntimeCOLR = 48 , // COLOR
162+ __RuntimeSymbol_SIZE__
161163};
162164
163165
@@ -639,13 +641,16 @@ class Generator
639641{
640642 SourceModel* m_source;
641643 FinalModel* m_final;
644+ const std::vector<string>* m_initlines;
645+ const std::vector<string>* m_termlines;
642646 int m_lineindex;
643647 SourceLineModel* m_line; // Curent line being generated
644648 int m_local; // Counter for local labels within the current line
645649 std::set<RuntimeSymbol> m_runtimeneeds;
646650 std::set<KeywordIndex> m_notimplemented; // Statements/functions used but not implemented
647651public:
648- Generator (SourceModel* source, FinalModel* intermed);
652+ Generator (SourceModel* source, FinalModel* intermed,
653+ const std::vector<string>* initlines, const std::vector<string>* termlines);
649654public:
650655 void ProcessBegin ();
651656 bool ProcessLine ();
@@ -763,10 +768,11 @@ class RuntimeGenerator
763768 FinalModel* m_final;
764769 std::vector<RuntimeBlock> m_rtblocks;
765770public:
766- RuntimeGenerator (const std::set<RuntimeSymbol>& needs, FinalModel* intermed);
771+ RuntimeGenerator (FinalModel* intermed);
767772public:
768773 void ParseRuntimeTemplate (std::istream* pInput);
769- void GenerateRuntime ();
774+ void GenerateRuntime (const std::set<RuntimeSymbol>& needs);
775+ void GetRuntimeBlock (RuntimeSymbol rtsymbol, std::vector<string>& copyto);
770776private:
771777 RuntimeBlock FindRuntimeBlock (RuntimeSymbol rtsymbol);
772778 void AddLine (const string& str) { m_final->AddRuntimeLine (str); }
0 commit comments