module tesla.polyfill
Code Map
module tesla.polyfill;
class Func
{
public:
name: string;
ft: FuncType;
ftIndex: u32;
isImport: bool;
llvmFunc: LLVMValueRef;
public:
this(name: string, ft: FuncType, index: u32, isImport: bool) { }
this(ft: FuncType, index: u32) { }
}
class Global
{
public:
llvmValue: LLVMValueRef;
initExpr: wasm.InitExpr;
type: wasm.Type;
isImport: bool;
isPointer: bool;
public:
this() { }
}
class FuncType
{
public:
argTypes: wasm.Type[];
retType: wasm.Type;
llvmType: LLVMTypeRef;
public:
this() { }
fn hasRet() wasm.Type { }
}
class Polyfill : wasm.Reader
{
public:
ctx: LLVMContextRef;
mod: LLVMModuleRef;
builder: LLVMBuilderRef;
funcPrefix: string;
funcAnonFmtStr: string;
codeSection: const(u8)[];
lastSection: wasm.Section;
hasProccessedType: bool;
hasProccessedImport: bool;
hasProccessedFunction: bool;
hasProccessedTable: bool;
hasProccessedMemory: bool;
hasProccessedGlobal: bool;
hasProccessedExport: bool;
hasProccessedStart: bool;
hasProccessedElement: bool;
hasProccessedCode: bool;
hasProccessedData: bool;
numFuncImports: u32;
numGlobalImports: u32;
startIndex: u32;
typeVoid: LLVMTypeRef;
typeI1: LLVMTypeRef;
typeI8: LLVMTypeRef;
typeI16: LLVMTypeRef;
typeI32: LLVMTypeRef;
typeI64: LLVMTypeRef;
typeF32: LLVMTypeRef;
typeF64: LLVMTypeRef;
funcs: Func[];
funcTypes: FuncType[];
globals: Global[];
valueStack: ValueStack;
blockStack: BlockStack;
currentFunc: Func;
currentBlock: LLVMBasicBlockRef;
currentLocals: LLVMValueRef[];
currentLocalTypes: wasm.Type[];
globalTeslaStack: LLVMValueRef;
fns: InbuiltFuncs;
public:
this() { }
fn isLinkable() bool { }
fn printToString() string { }
fn writeToFile(filename: string) { }
fn close() { }
fn makeInbuilt() { }
fn toLLVMFromValueType(t: wasm.Type) LLVMTypeRef { }
fn toLLVMFromValueTypeOrVoid(t: wasm.Type) LLVMTypeRef { }
fn onSection(id: wasm.Section, data: const(u8)[]) wasm.SkipOrParse { }
fn onTypeSection(count: u32) { }
fn onTypeEntry(num: u32, from: wasm.Type, args: wasm.Type[], ret: wasm.Type) { }
fn onImportSection(count: u32) { }
fn onImportGlobal(num: u32, mod: string, field: string, t: wasm.Type, mut: bool) { }
fn onImportFunc(num: u32, mod: string, field: string, index: u32) { }
fn onFunctionSection(count: u32) { }
fn onFunctionEntry(num: u32, index: u32) { }
fn onTableSection(count: u32) { }
fn onTableEntry(num: u32, elem_type: wasm.Type, l: wasm.Limits) { }
fn onMemorySection(count: u32) { }
fn onMemoryEntry(num: u32, l: wasm.Limits) { }
fn onGlobalSection(count: u32) { }
fn onGlobalEntry(num: u32, type: wasm.Type, mut: bool, exp: wasm.InitExpr) { }
fn onExportSection(count: u32) { }
fn onExportEntry(num: u32, name: string, kind: wasm.ExternalKind, index: u32) { }
fn onRelocSection(section: wasm.Section, name: string, count: u32) { }
fn onRelocEntry(num: u32, type: wasm.RelocType, offset: u32, index: u32, addend: u32) { }
fn onRelocSectionEnd() { }
fn onReadError(err: string) { }
fn onError(err: string, loc: string) { }
fn onEOF() { }
fn onFunctionBody(num: u32, types: wasm.Type[], counts: u32[]) { }
fn onFunctionBodyEnd(num: u32) { }
fn onOpI32Const(v: i32) { }
fn onOpI64Const(v: i64) { }
fn onOpF32Const(v: f32) { }
fn onOpF64Const(v: f64) { }
fn onControl(op: wasm.Opcode, t: wasm.Type) { }
fn onBranch(op: wasm.Opcode, relative_depth: u32) { }
fn onCall(index: u32) { }
fn onCallIndirect(typeIndex: u32) { }
fn onOp(op: wasm.Opcode) { }
fn onOpMemory(op: wasm.Opcode, flags: u32, offset: u32) { }
fn onOpVar(op: wasm.Opcode, index: u32) { }
fn buildBlock(cstr: const(char)*) LLVMBasicBlockRef { }
fn buildRet() { }
fn buildICmp(t: wasm.Type, p: LLVMIntPredicate) { }
fn buildFCmp(t: wasm.Type, p: LLVMRealPredicate) { }
fn buildBinOp(t: wasm.Type, op: LLVMOpcode) { }
fn buildBinCall(t: wasm.Type, f: LLVMValueRef) { }
fn buildUnaryCall(t: wasm.Type, f: LLVMValueRef) { }
fn buildCast(from: wasm.Type, to: wasm.Type, llvmType: LLVMTypeRef, lop: LLVMOpcode) { }
fn buildBitCast(from: wasm.Type, to: wasm.Type, llvmType: LLVMTypeRef) { }
fn buildConvCall(from: wasm.Type, to: wasm.Type, func: LLVMValueRef) { }
fn buildLoad(t: wasm.Type, func: LLVMValueRef, offset: u32) { }
fn buildStore(t: wasm.Type, func: LLVMValueRef, offset: u32) { }
fn unhandledOp(op: wasm.Opcode, kind: string, loc: string) { }
fn ensureNotImportFuncIndex(index: u32, kind: string, loc: string) { }
fn ensureValidFuncIndex(index: u32, kind: string, loc: string) { }
fn ensureValidFuncTypeIndex(index: u32, kind: string, loc: string) { }
fn ensureValidGlobalIndex(index: u32, kind: string, loc: string) { }
fn ensureSectionOrder(id: wasm.Section, loc: string) { }
fn ensureOneEntry(count: u32, section: string, loc: string) { }
fn ensureTypeSection(section: string, loc: string) { }
fn ensureValidLocalIndex(index: u32, loc: string) { }
fn ensureBlock(op: wasm.Opcode, loc: string) { }
fn ensureTerminated(op: wasm.Opcode, loc: string) { }
fn onHeader(header: wasm.Header) { }
fn onCustomSection(name: string, data: const(u8)[]) { }
fn onStart(index: u32) { }
fn onCodeSection(count: u32) { }
fn onCode(data: const(u8)[]) { }
}
struct BlockEntry
{
public:
block: LLVMBasicBlockRef;
isLoop: bool;
}
struct ValueStack
{
public:
enum Max;
public:
poly: Polyfill;
public:
fn push(t: wasm.Type, v: T) { }
fn pop(t: wasm.Type, loc: string) T { }
fn pop() T { }
fn topType(loc: string) wasm.Type { }
fn getRelative(index: u32, t: wasm.Type, v: T) { }
fn checkTop(t: wasm.Type, loc: string) T { }
fn checkPush(loc: string) { }
fn checkAndPop(loc: string) { }
fn checkTypeAndPop(t: wasm.Type, loc: string) { }
}
struct BlockStack
{
public:
enum Max;
public:
poly: Polyfill;
public:
fn push(t: wasm.Type, v: T) { }
fn pop(t: wasm.Type, loc: string) T { }
fn pop() T { }
fn topType(loc: string) wasm.Type { }
fn getRelative(index: u32, t: wasm.Type, v: T) { }
fn checkTop(t: wasm.Type, loc: string) T { }
fn checkPush(loc: string) { }
fn checkAndPop(loc: string) { }
fn checkTypeAndPop(t: wasm.Type, loc: string) { }
}