Changeset 222 for branches/interpreter2/USource.pas
- Timestamp:
- Nov 25, 2020, 12:18:45 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/USource.pas
r221 r222 242 242 end; 243 243 244 TExpressionOperator = (eoAdd, eoSub, eoMultiply, eoDivide, eoModulo, eoAnd, eoXor, 245 eoOr, eoShl, eoShr, eoEqual, eoNotEqual); 244 TExpressionOperator = (eoNone, eoAdd, eoSub, eoMultiply, eoDivide, eoIntDivide, 245 eoModulo, eoAnd, eoXor, eoOr, eoShl, eoShr, eoEqual, eoNotEqual, eoLesser, 246 eoHigher, eoLesserOrEqual, eoHigherOrEqual, eoNot); 246 247 247 248 { TExpression } … … 270 271 end; 271 272 272 TExpressionOperandType = (otVariableRef, otConstantRef, otConstantDirect, otFunctionCall); 273 TExpressionOperandType = (otVariableRef, otConstantRef, otConstantDirect, 274 otFunctionCall); 273 275 274 276 { TExpressionOperand } … … 288 290 function GetType: TType; override; 289 291 constructor Create; 292 destructor Destroy; override; 293 end; 294 295 { TExpressionBrackets } 296 297 TExpressionBrackets = class(TExpression) 298 Expression: TExpression; 299 procedure GetValue(Index: Integer; out Value); override; 300 function GetField(Index: Integer): TField; override; 301 procedure SetValue(Index: Integer; var Value); override; 302 function GetType: TType; override; 290 303 destructor Destroy; override; 291 304 end; … … 442 455 'Integer', 'Float', 'Color', 'Time', 'Date', 'DateTime', 'Enumeration', 443 456 'Reference'); 457 ExpressionOperatorText: array[TExpressionOperator] of string = ('', '+', 458 '-', '*', '/', 'div', 'mod', 'and', 'xor', 'or', 'shl', 459 'shr', '=', '<>', '<', '>', '<=','>=', 'not'); 460 ExpressionOperatorFuncText: array[TExpressionOperator] of string = ('', '_Add', 461 '_Sub', '_Mul', '_Div', '_IntDiv', '_Mod', '_And', '_Xor', '_Or', '_Shl', 462 '_Shr', '_Equal', '_NotEqual', '_Lesser', '_Higher', '_LesserOrEqual', 463 '_HigherOrEqual', '_Not'); 464 465 function GetOperatorByName(Name: string): TExpressionOperator; 444 466 445 467 … … 452 474 SYes = 'Yes'; 453 475 SNo = 'No'; 476 477 function GetOperatorByName(Name: string): TExpressionOperator; 478 var 479 I: TExpressionOperator; 480 begin 481 Result := eoNone; 482 for I := Succ(Low(TExpressionOperator)) to High(TExpressionOperator) do begin 483 if ExpressionOperatorText[I] = Name then begin 484 Result := I; 485 Break; 486 end; 487 end; 488 end; 489 490 { TExpressionBrackets } 491 492 procedure TExpressionBrackets.GetValue(Index: Integer; out Value); 493 begin 494 if Index = 0 then begin 495 TExpression(Value) := Expression; 496 end 497 else inherited; 498 end; 499 500 function TExpressionBrackets.GetField(Index: Integer): TField; 501 begin 502 if Index = 0 then Result := TField.Create(dtObject, 'Expression') 503 else inherited; 504 end; 505 506 procedure TExpressionBrackets.SetValue(Index: Integer; var Value); 507 begin 508 if Index = 0 then begin 509 Expression := TExpression(Value); 510 end 511 else inherited; 512 end; 513 514 function TExpressionBrackets.GetType: TType; 515 begin 516 Result := Expression.GetType; 517 end; 518 519 destructor TExpressionBrackets.Destroy; 520 begin 521 FreeAndNil(Expression); 522 inherited; 523 end; 454 524 455 525 { TReturn } … … 1017 1087 function TExpressionOperation.GetFunctionName: string; 1018 1088 begin 1019 if Operation = eoAdd then Result := '_Add' 1020 else if Operation = eoSub then Result := '_Sub' 1021 else if Operation = eoEqual then Result := '_Equal' 1022 else if Operation = eoNotEqual then Result := '_NotEqual' 1023 else raise Exception.Create('Unsupported operation type.'); 1089 Result := ExpressionOperatorFuncText[Operation]; 1024 1090 end; 1025 1091
Note:
See TracChangeset
for help on using the changeset viewer.