Changeset 203 for branches/interpreter2/USource.pas
- Timestamp:
- Apr 17, 2020, 10:16:25 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/USource.pas
r202 r203 12 12 TFunctions = class; 13 13 14 { TValue } 15 14 16 TValue = class 15 end; 17 function Clone: TValue; virtual; 18 end; 19 20 { TValueString } 16 21 17 22 TValueString = class(TValue) 18 23 Value: string; 19 end; 24 function Clone: TValue; override; 25 end; 26 27 { TValueInteger } 20 28 21 29 TValueInteger = class(TValue) 22 30 Value: Integer; 23 end; 31 function Clone: TValue; override; 32 end; 33 34 { TValueBoolean } 24 35 25 36 TValueBoolean = class(TValue) 26 37 Value: Boolean; 38 function Clone: TValue; override; 27 39 end; 28 40 … … 140 152 end; 141 153 142 TExpressionOperandType = (otVariable , otConstant, otFunctionCall);154 TExpressionOperandType = (otVariableRef, otConstantRef, otConstantDirect, otFunctionCall); 143 155 144 156 { TExpressionOperand } … … 148 160 VariableRef: TVariable; 149 161 ConstantRef: TConstant; 162 ConstantDirect: TConstant; 150 163 FunctionCall: TFunctionCall; 151 164 function GetType: TType; override; 165 constructor Create; 166 destructor Destroy; override; 152 167 end; 153 168 … … 225 240 implementation 226 241 242 { TValueBoolean } 243 244 function TValueBoolean.Clone: TValue; 245 begin 246 Result := TValueBoolean.Create; 247 TValueBoolean(Result).Value := Value; 248 end; 249 250 { TValueInteger } 251 252 function TValueInteger.Clone: TValue; 253 begin 254 Result := TValueInteger.Create; 255 TValueInteger(Result).Value := Value; 256 end; 257 258 { TValueString } 259 260 function TValueString.Clone: TValue; 261 begin 262 Result := TValueString.Create; 263 TValueString(Result).Value := Value; 264 end; 265 266 { TValue } 267 268 function TValue.Clone: TValue; 269 begin 270 Result := nil; 271 end; 272 227 273 { TForToDo } 228 274 … … 254 300 begin 255 301 if OperandType = otFunctionCall then Result := FunctionCall.FunctionDef.ResultType 256 else if OperandType = otConstant then Result := ConstantRef.TypeRef 257 else if OperandType = otVariable then Result := VariableRef.TypeRef 302 else if OperandType = otConstantRef then Result := ConstantRef.TypeRef 303 else if OperandType = otConstantDirect then Result := ConstantDirect.TypeRef 304 else if OperandType = otVariableRef then Result := VariableRef.TypeRef 258 305 else raise Exception.Create('Unsupported operand type'); 306 end; 307 308 constructor TExpressionOperand.Create; 309 begin 310 end; 311 312 destructor TExpressionOperand.Destroy; 313 begin 314 if Assigned(ConstantDirect) then ConstantDirect.Free; 259 315 end; 260 316
Note:
See TracChangeset
for help on using the changeset viewer.