Changeset 146 for branches/easy compiler/USourceExecutor.pas
- Timestamp:
- Jan 17, 2018, 2:25:45 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/easy compiler/USourceExecutor.pas
r145 r146 31 31 FOnOutput: TOutputEvent; 32 32 Variables: TExecutorVariables; 33 procedure ExecuteBeginEnd(BeginEnd: T SourceBeginEnd);33 procedure ExecuteBeginEnd(BeginEnd: TCommandBeginEnd); 34 34 public 35 35 constructor Create; … … 84 84 end; 85 85 86 procedure TSourceExecutor.ExecuteBeginEnd(BeginEnd: T SourceBeginEnd);86 procedure TSourceExecutor.ExecuteBeginEnd(BeginEnd: TCommandBeginEnd); 87 87 var 88 88 IP: Integer; 89 Instruction: TSource Instruction;89 Instruction: TSourceCommand; 90 90 Variable: TSourceVariable; 91 91 Value: TSourceValue; … … 93 93 Text: string; 94 94 IntValue: Integer; 95 SkipNext: Boolean; 95 96 96 97 function ReadValueReference(Reference: TSourceReference): TSourceValue; … … 114 115 115 116 begin 117 SkipNext := False; 116 118 IP := 0; 117 119 while IP < BeginEnd.Instructions.Count do begin 118 Instruction := TSourceInstruction(BeginEnd.Instructions[IP]); 119 if Instruction is TSourceFunctionCall then 120 with TSourceFunctionCall(Instruction) do begin 120 if SkipNext then begin 121 SkipNext := False; 122 Inc(IP); 123 Continue; 124 end; 125 Instruction := TSourceCommand(BeginEnd.Instructions[IP]); 126 if Instruction is TCommandFunctionCall then 127 with TCommandFunctionCall(Instruction) do begin 121 128 if Name = 'print' then begin 122 129 if Assigned(FOnOutput) then begin … … 178 185 else raise Exception.Create('Wrong type for increment'); 179 186 end else 180 raise Exception.Create('Unsupported function: ' + T SourceFunctionCall(Instruction).Name);187 raise Exception.Create('Unsupported function: ' + TCommandFunctionCall(Instruction).Name); 181 188 end else 182 if Instruction is TSourceBeginEnd then begin 183 ExecuteBeginEnd(TSourceBeginEnd(Instruction)); 189 if Instruction is TCommandBeginEnd then begin 190 ExecuteBeginEnd(TCommandBeginEnd(Instruction)); 191 end else 192 if Instruction is TCommandIfZero then begin 193 ExecutorVar := Variables.Search(TCommandIfZero(Instruction).Variable); 194 if Assigned(ExecutorVar) then begin 195 if ExecutorVar.Variable.ValueType.Name = 'Integer' then begin 196 if TSourceValueInteger(ExecutorVar.Value).Value = 0 then SkipNext := True; 197 end else 198 raise Exception.Create('Can compare only integers'); 199 end else 200 raise Exception.Create('Variable not found'); 184 201 end else 185 202 raise Exception.Create('Unsupported instruction');
Note:
See TracChangeset
for help on using the changeset viewer.