|
@@ -109,6 +109,18 @@ type
|
|
property Item[i: integer]: TWasmInstr read GetItem; default;
|
|
property Item[i: integer]: TWasmInstr read GetItem; default;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { TWasmGlobal }
|
|
|
|
+
|
|
|
|
+ TWasmGlobal = class(TObject)
|
|
|
|
+ public
|
|
|
|
+ id : TWasmId;
|
|
|
|
+ tp : byte; // byte;
|
|
|
|
+ value : TWasmInstrList;
|
|
|
|
+ LinkInfo : TLinkInfo;
|
|
|
|
+ function StartValue: TWasmInstrList;
|
|
|
|
+ destructor Destroy; override;
|
|
|
|
+ end;
|
|
|
|
+
|
|
{ TWasmFunc }
|
|
{ TWasmFunc }
|
|
|
|
|
|
TWasmFunc = class(TObject)
|
|
TWasmFunc = class(TObject)
|
|
@@ -199,6 +211,7 @@ type
|
|
|
|
|
|
TWasmModule = class(TObject)
|
|
TWasmModule = class(TObject)
|
|
private
|
|
private
|
|
|
|
+ globals : TList;
|
|
memes : TList;
|
|
memes : TList;
|
|
imports : TList;
|
|
imports : TList;
|
|
types : TList;
|
|
types : TList;
|
|
@@ -242,6 +255,10 @@ type
|
|
function AddData: TWasmData;
|
|
function AddData: TWasmData;
|
|
function GetData(i: integer): TWasmData;
|
|
function GetData(i: integer): TWasmData;
|
|
function DataCount: Integer;
|
|
function DataCount: Integer;
|
|
|
|
+
|
|
|
|
+ function AddGlobal: TWasmGlobal;
|
|
|
|
+ function GetGlobal(i: integer): TWasmGlobal;
|
|
|
|
+ function GlobalCount: Integer;
|
|
end;
|
|
end;
|
|
|
|
|
|
// making binary friendly. finding proper "nums" for each symbol "index"
|
|
// making binary friendly. finding proper "nums" for each symbol "index"
|
|
@@ -326,6 +343,21 @@ begin
|
|
l.Clear;
|
|
l.Clear;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ TWasmGlobal }
|
|
|
|
+
|
|
|
|
+function TWasmGlobal.StartValue: TWasmInstrList;
|
|
|
|
+begin
|
|
|
|
+ if not Assigned(value) then
|
|
|
|
+ value:=TWasmInstrList.Create;
|
|
|
|
+ Result:=value;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+destructor TWasmGlobal.Destroy;
|
|
|
|
+begin
|
|
|
|
+ value.Free;
|
|
|
|
+ inherited Destroy;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TWasmTable }
|
|
{ TWasmTable }
|
|
|
|
|
|
function TWasmTable.AddElem: TWasmElement;
|
|
function TWasmTable.AddElem: TWasmElement;
|
|
@@ -364,7 +396,7 @@ var
|
|
begin
|
|
begin
|
|
w.id:='';
|
|
w.id:='';
|
|
w.idNum:=idx;
|
|
w.idNum:=idx;
|
|
- AddFuncId(w);
|
|
|
|
|
|
+ Result := AddFuncId(w);
|
|
end;
|
|
end;
|
|
|
|
|
|
function TWasmElement.AddFuncId(const idx: TWasmID): integer;
|
|
function TWasmElement.AddFuncId(const idx: TWasmID): integer;
|
|
@@ -574,6 +606,7 @@ end;
|
|
constructor TWasmModule.Create;
|
|
constructor TWasmModule.Create;
|
|
begin
|
|
begin
|
|
inherited Create;
|
|
inherited Create;
|
|
|
|
+ globals := TList.Create;
|
|
types := TList.Create;
|
|
types := TList.Create;
|
|
funcs := TList.Create;
|
|
funcs := TList.Create;
|
|
exp := TList.Create;
|
|
exp := TList.Create;
|
|
@@ -602,6 +635,8 @@ begin
|
|
types.Free;
|
|
types.Free;
|
|
ClearList(funcs);
|
|
ClearList(funcs);
|
|
funcs.Free;
|
|
funcs.Free;
|
|
|
|
+ ClearList(globals);
|
|
|
|
+ globals.Free;
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -757,6 +792,25 @@ begin
|
|
Result:=data.Count;
|
|
Result:=data.Count;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TWasmModule.AddGlobal: TWasmGlobal;
|
|
|
|
+begin
|
|
|
|
+ Result:=TWasmGlobal.Create;
|
|
|
|
+ globals.Add(Result);
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TWasmModule.GetGlobal(i: integer): TWasmGlobal;
|
|
|
|
+begin
|
|
|
|
+ if (i>=0) and (i<globals.Count) then
|
|
|
|
+ Result:=TWasmGlobal(globals[i])
|
|
|
|
+ else
|
|
|
|
+ Result:=nil;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TWasmModule.GlobalCount: Integer;
|
|
|
|
+begin
|
|
|
|
+ Result:=globals.Count;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TWasmFunc }
|
|
{ TWasmFunc }
|
|
|
|
|
|
constructor TWasmFunc.Create;
|
|
constructor TWasmFunc.Create;
|