-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathOperation.pas
More file actions
57 lines (49 loc) · 1.52 KB
/
Operation.pas
File metadata and controls
57 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
unit Operation;
interface
uses
Classes, Types, SysUtils, DataType;
type
TOperation = class(TObject)
private
FLeftRawType: TRawType;
FLeftSize: Integer;
FResultType: TDataType;
FRightRawType: TRawType;
FRightSize: Integer;
FOpName: string;
FAssembly: string;
public
constructor Create(AOpName: string; ALeftType, ARightType: TRawType; ALeftSize, ARightSize: Integer;
AResultType: TDataType; AAssembly: string);
function GetAssembly(AOperands: array of string): string;
property LeftRawType: TRawType read FLeftRawType;
property RightRawType: TRawType read FRightRawType;
property LeftSize: Integer read FLeftSize;
property RightSize: Integer read FRightSize;
property OpName: string read FOpName;
property ResultType: TDataType read FResultType;
end;
implementation
{ TOperation }
constructor TOperation.Create(AOpName: string; ALeftType, ARightType: TRawType;
ALeftSize, ARightSize: Integer; AResultType: TDataType; AAssembly: string);
begin
FOpName := AOpName;
FLeftRawType := ALeftType;
FRightRawType := ARightType;
FLeftSize := ALeftSize;
FRightSize := ARightSize;
FResultType := AResultType;
FAssembly := AAssembly;
end;
function TOperation.GetAssembly(AOperands: array of string): string;
var
i: Integer;
begin
Result := FAssembly;
for i := 0 to High(AOperands) do
begin
Result := StringReplace(Result, '$' + IntToStr(i), AOperands[i], [rfReplaceAll, rfIgnoreCase]);
end;
end;
end.