mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 03:46:10 +02:00
[PATCH 124/188] adding modules for data and memory
From 920032a5497061296459a379a49597161d45fa07 Mon Sep 17 00:00:00 2001 From: Dmitry Boyarintsev <skalogryz.lists@gmail.com> Date: Mon, 23 Mar 2020 16:10:03 -0400 git-svn-id: branches/wasm@46120 -
This commit is contained in:
parent
5f4ca22e1a
commit
10cc3d3a54
@ -170,20 +170,42 @@ type
|
|||||||
max : LongWord;
|
max : LongWord;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TWasmData }
|
||||||
|
|
||||||
|
TWasmData = class(TObject)
|
||||||
|
id : TWasmData;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TWasmMemory }
|
||||||
|
|
||||||
|
TWasmMemory = class(TObject)
|
||||||
|
id : TWasmId;
|
||||||
|
min : LongWord;
|
||||||
|
max : LongWord; // limit
|
||||||
|
LinkInfo : TLinkInfo;
|
||||||
|
exportInfo : TExportInfo;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWasmModule }
|
{ TWasmModule }
|
||||||
|
|
||||||
TWasmModule = class(TObject)
|
TWasmModule = class(TObject)
|
||||||
private
|
private
|
||||||
|
memes : TList;
|
||||||
imports : TList;
|
imports : TList;
|
||||||
types : TList;
|
types : TList;
|
||||||
funcs : TList;
|
funcs : TList;
|
||||||
exp : TList;
|
exp : TList;
|
||||||
tables : TList;
|
tables : TList;
|
||||||
elems : TList;
|
elems : TList;
|
||||||
|
data : TList;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function AddMemory: TWasmMemory;
|
||||||
|
function GetMemory(i: integer): TWasmMemory;
|
||||||
|
function MemoryCount: Integer;
|
||||||
|
|
||||||
function AddTable: TWasmTable;
|
function AddTable: TWasmTable;
|
||||||
function GetTable(i: integer): TWasmTable;
|
function GetTable(i: integer): TWasmTable;
|
||||||
function TableCount: Integer;
|
function TableCount: Integer;
|
||||||
@ -207,6 +229,10 @@ type
|
|||||||
function AddElement: TWasmElement;
|
function AddElement: TWasmElement;
|
||||||
function GetElement(i: integer): TWasmElement;
|
function GetElement(i: integer): TWasmElement;
|
||||||
function ElementCount: Integer;
|
function ElementCount: Integer;
|
||||||
|
|
||||||
|
function AddData: TWasmData;
|
||||||
|
function GetData(i: integer): TWasmData;
|
||||||
|
function DataCount: Integer;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// making binary friendly. finding proper "nums" for each symbol "index"
|
// making binary friendly. finding proper "nums" for each symbol "index"
|
||||||
@ -500,10 +526,16 @@ begin
|
|||||||
imports := TList.Create;
|
imports := TList.Create;
|
||||||
tables := TList.Create;
|
tables := TList.Create;
|
||||||
elems := TList.Create;
|
elems := TList.Create;
|
||||||
|
memes := TList.Create;
|
||||||
|
data := TList.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TWasmModule.Destroy;
|
destructor TWasmModule.Destroy;
|
||||||
begin
|
begin
|
||||||
|
ClearList(data);
|
||||||
|
data.Free;
|
||||||
|
ClearList(memes);
|
||||||
|
memes.Free;
|
||||||
ClearList(elems);
|
ClearList(elems);
|
||||||
elems.Free;
|
elems.Free;
|
||||||
ClearList(tables);
|
ClearList(tables);
|
||||||
@ -519,6 +551,25 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TWasmModule.AddMemory: TWasmMemory;
|
||||||
|
begin
|
||||||
|
Result:=TWasmMemory.Create;
|
||||||
|
memes.Add(result);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TWasmModule.GetMemory(i: integer): TWasmMemory;
|
||||||
|
begin
|
||||||
|
if (i>=0) and (i<memes.Count) then
|
||||||
|
Result:=TWasmMemory(memes[i])
|
||||||
|
else
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TWasmModule.MemoryCount: Integer;
|
||||||
|
begin
|
||||||
|
Result:=memes.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
function TWasmModule.AddTable: TWasmTable;
|
function TWasmModule.AddTable: TWasmTable;
|
||||||
begin
|
begin
|
||||||
Result:=TWasmTable.Create;
|
Result:=TWasmTable.Create;
|
||||||
@ -633,6 +684,25 @@ begin
|
|||||||
Result := elems.Count;
|
Result := elems.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TWasmModule.AddData: TWasmData;
|
||||||
|
begin
|
||||||
|
Result:=TWasmData.Create;
|
||||||
|
data.Add(Result);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TWasmModule.GetData(i: integer): TWasmData;
|
||||||
|
begin
|
||||||
|
if (i>=0) and (i<data.Count) then
|
||||||
|
Result:=TWasmData(data[i])
|
||||||
|
else
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TWasmModule.DataCount: Integer;
|
||||||
|
begin
|
||||||
|
Result:=data.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TWasmFunc }
|
{ TWasmFunc }
|
||||||
|
|
||||||
constructor TWasmFunc.Create;
|
constructor TWasmFunc.Create;
|
||||||
|
Loading…
Reference in New Issue
Block a user