Changeset 201 for branches/interpreter2/USource.pas
- Timestamp:
- Apr 16, 2020, 7:40:38 PM (5 years ago)
- Location:
- branches/interpreter2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2
-
Property svn:ignore
set to
lib
interpreter
interpreter.lps
interpreter.res
heaptrclog.trc
-
Property svn:ignore
set to
-
branches/interpreter2/USource.pas
r200 r201 30 30 TConstants = class(TObjectList) 31 31 function SearchByName(Name: string): TConstant; 32 function AddNew(Name: string): TConstant; 32 33 end; 33 34 … … 66 67 67 68 TExpression = class 68 Variable : TVariable;69 Constant : TConstant;69 VariableRef: TVariable; 70 ConstantRef: TConstant; 70 71 FunctionCall: TFunctionCall; 71 72 end; … … 73 74 TExpressions = class(TObjectList) 74 75 end; 76 77 { TAssignment } 75 78 76 79 TAssignment = class(TCommand) 77 80 Variable: TVariable; 78 81 Expression: TExpression; 79 end; 82 constructor Create; 83 destructor Destroy; override; 84 end; 85 86 { TIfThenElse } 80 87 81 88 TIfThenElse = class(TCommand) … … 83 90 CommandThen: TCommand; 84 91 CommandElse: TCommand; 85 end; 92 constructor Create; 93 destructor Destroy; override; 94 end; 95 96 { TWhileDo } 86 97 87 98 TWhileDo = class(TCommand) 88 99 Expression: TExpression; 89 100 Command: TCommand; 101 constructor Create; 102 destructor Destroy; override; 90 103 end; 91 104 … … 98 111 Functions: TFunctions; 99 112 BeginEnd: TBeginEnd; 113 procedure Clear; 100 114 function GetFunction(Name: string): TFunction; 101 115 constructor Create; … … 116 130 implementation 117 131 132 { TAssignment } 133 134 constructor TAssignment.Create; 135 begin 136 Variable := nil; 137 Expression := TExpression.Create; 138 end; 139 140 destructor TAssignment.Destroy; 141 begin 142 Variable := nil; 143 Expression.Free; 144 inherited Destroy; 145 end; 146 147 { TIfThenElse } 148 149 constructor TIfThenElse.Create; 150 begin 151 Expression := TExpression.Create; 152 CommandThen := TCommand.Create; 153 CommandElse := TCommand.Create; 154 end; 155 156 destructor TIfThenElse.Destroy; 157 begin 158 Expression.Free; 159 CommandThen.Free; 160 CommandElse.Free; 161 inherited Destroy; 162 end; 163 164 { TWhileDo } 165 166 constructor TWhileDo.Create; 167 begin 168 Expression := TExpression.Create; 169 Command := TCommand.Create; 170 end; 171 172 destructor TWhileDo.Destroy; 173 begin 174 Expression.Free; 175 Command.Free; 176 inherited Destroy; 177 end; 178 118 179 { TFunctionCall } 119 180 … … 160 221 end; 161 222 223 function TConstants.AddNew(Name: string): TConstant; 224 begin 225 Result := TConstant.Create; 226 Result.Name := Name; 227 Add(Result); 228 end; 229 162 230 { TVariables } 163 231 … … 174 242 { TBlock } 175 243 244 procedure TBlock.Clear; 245 begin 246 Functions.Clear; 247 Constants.Clear; 248 Variables.Clear; 249 end; 250 176 251 function TBlock.GetFunction(Name: string): TFunction; 177 252 begin
Note:
See TracChangeset
for help on using the changeset viewer.