Changeset 97 for branches/interpreter/Execute3.pas
- Timestamp:
- Feb 2, 2017, 11:35:09 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter/Execute3.pas
r96 r97 11 11 implementation 12 12 13 procedure ExecuteCommand(Command: PCommand); forward; 14 15 procedure ExecuteBeginEnd(BeginEnd: PBeginEnd); 16 var 17 I: Integer; 18 begin 19 for I := 0 to Length(BeginEnd^.Commands) - 1 do 20 ExecuteCommand(@BeginEnd^.Commands[I]); 21 end; 22 23 function ExecuteExpression(Expression: PExpression): Boolean; 24 begin 25 26 end; 27 28 procedure ExecuteWhileDo(WhileDo: PWhileDo); 29 begin 30 if ExecuteExpression(@WhileDo^.Condition) then 31 ExecuteCommand(@WhileDo^.Command); 32 end; 33 34 procedure ExecuteIfThenElse(IfThenElse: PIfThenElse); 35 begin 36 if ExecuteExpression(@IfThenElse^.Condition) then 37 ExecuteCommand(@IfThenElse^.DoThen) 38 else ExecuteCommand(@IfThenElse^.DoElse); 39 end; 40 41 procedure ExecuteExecution(Execution: PExecution); 42 begin 43 // Set parameters 44 ExecuteBeginEnd(@Execution^.Func^.BeginEnd); 45 end; 46 47 procedure ExecuteAssignment(Assignment: PAssignment); 48 begin 49 50 end; 51 52 procedure ExecuteCommand(Command: PCommand); 53 begin 54 case Command^.CmdType of 55 ctBeginEnd: ExecuteBeginEnd(PBeginEnd(Command^.Ptr)); 56 ctWhileDo: ExecuteWhileDo(PWhileDo(Command^.Ptr)); 57 ctIfThenElse: ExecuteIfThenElse(PIfThenElse(Command^.Ptr)); 58 ctExecution: ExecuteExecution(PExecution(Command^.Ptr)); 59 ctAssignment: ExecuteAssignment(PAssignment(Command^.Ptr)); 60 end; 61 end; 62 13 63 procedure ExecuteProgram(ProgramCode: PProgramCode); 14 64 begin 15 65 ExecuteBeginEnd(@ProgramCode^.BeginEnd); 16 66 end; 17 67
Note:
See TracChangeset
for help on using the changeset viewer.