-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathuDataObject.pas
More file actions
109 lines (76 loc) · 1.94 KB
/
Copy pathuDataObject.pas
File metadata and controls
109 lines (76 loc) · 1.94 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
unit uDataObject;
// This source is distributed under Apache 2.0
// All data objects, such as lists, functions, etc descend from this.
// Copyright (C) 2019-2024 Herbert M Sauro
// Author Contact Information:
// email: hsauro@gmail.com
interface
Uses Classes, SysUtils,
uHelpUnit,
uRhodusTypes,
uDataObjectMethods;
type
TDataObject = class (TObject)
blockType : TBlockType;
objectType : TElementType;
methodCount : integer;
methods : TMethodsBase;
help : THelpModule;
procedure getHelp (vm : TObject);
function getSize : integer; virtual; abstract;
function clone : TDataObject; virtual; abstract;
//function toString : string; virtual; <- This already exists in the base class
function isConstant : boolean;
function isBound : boolean;
function isOwned : boolean;
function isGarbage : boolean;
constructor Create;
destructor Destroy; override;
end;
implementation
Uses uStringObject,
uMemoryManager,
uMachineStack,
uVM;
constructor TDataObject.Create;
begin
inherited;
help := nil;
blockType := btGarbage;
memoryList.addNode(self);
end;
destructor TDataObject.destroy;
begin
help.Free;
inherited
end;
function TDataObject.isConstant : boolean;
begin
result := (blockType = btConstant);
end;
function TDataObject.isBound : boolean;
begin
result := (blockType = btBound);
end;
function TDataObject.isOwned : boolean;
begin
result := (blockType = btOwned);
end;
function TDataObject.isGarbage : boolean;
begin
result := (blockType = btGarbage);
end;
procedure TDataObject.getHelp (vm : TObject);
var m : TMethodDetails;
obj : TDataObject;
begin
m := TVM (vm).popMethodDetails();
obj := TDataObject (m.self);
if obj.help <> nil then
begin
TVM (vm).push(TStringObject.Create(obj.help.getHelp()));
end
else
TVM (vm).push (TStringObject.Create('No help'));
end;
end.