diff --git a/Brisk.png b/Brisk.png new file mode 100644 index 0000000..2003846 Binary files /dev/null and b/Brisk.png differ diff --git a/Resources/LinkTest/index.br.wasm b/Resources/LinkTest/index.br.wasm index 7f08af8..1d4bb2b 100644 Binary files a/Resources/LinkTest/index.br.wasm and b/Resources/LinkTest/index.br.wasm differ diff --git a/gulpfile.js b/gulpfile.js index f45aa36..0cd1e73 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -134,6 +134,7 @@ gulp.task('buildExtension', async () => { await fs.promises.mkdir(`${folder}/syntaxes/`); // Copy Extension Files await fs.promises.copyFile('./src/extension/package.json', './dist/extension/package.json'); + await fs.promises.copyFile('./src/extension/Brisk.png', './dist/extension/Brisk.png'); await fs.promises.copyFile( './src/extension/language-configuration.json', './dist/extension/language-configuration.json' diff --git a/src/Compiler/Codegen/index.ts b/src/Compiler/Codegen/index.ts index f52e9ab..2bb4bc7 100644 --- a/src/Compiler/Codegen/index.ts +++ b/src/Compiler/Codegen/index.ts @@ -116,6 +116,7 @@ const generateCode = ( wasmModule, createGlobalImport( `${brisk_moduleIdentifier}${node.source.value}.wasm`, + `${brisk_moduleIdentifier}${node.variable.name}`, generateVariableName(node.variable.name, node.variable.reference!), importType, false @@ -151,7 +152,13 @@ const generateCode = ( // Must Be A Global Import addImport( wasmModule, - createGlobalImport(node.source.value, node.variable.name, importType, false) + createGlobalImport( + node.source.value, + node.variable.name, + node.variable.name, + importType, + false + ) ); } // Return Blank Statement diff --git a/src/extension/Brisk.png b/src/extension/Brisk.png new file mode 100644 index 0000000..2003846 Binary files /dev/null and b/src/extension/Brisk.png differ diff --git a/src/extension/package.json b/src/extension/package.json index 0e0e032..1e8b182 100644 --- a/src/extension/package.json +++ b/src/extension/package.json @@ -4,6 +4,11 @@ "description": "Visual Studio Code Support For Brisk.", "version": "0.0.1", "publisher": "brisk-dev", + "icon": "Brisk.png", + "repository": { + "type": "git", + "url": "https://github.com/spotandjake/Brisk" + }, "engines": { "vscode": "^1.66.0" }, diff --git a/src/wasmBuilder/Build/WasmModule.ts b/src/wasmBuilder/Build/WasmModule.ts index 1616669..b036efa 100644 --- a/src/wasmBuilder/Build/WasmModule.ts +++ b/src/wasmBuilder/Build/WasmModule.ts @@ -36,6 +36,7 @@ export const createFunctionImport = ( return { kind: WasmExternalKind.function, name: importField, + valueName: importField, importData: [ ...encodeString(importModule), ...encodeString(importField), @@ -47,12 +48,14 @@ export const createFunctionImport = ( export const createGlobalImport = ( importModule: string, importField: string, + variableName: string, importType: ResolvedBytes, mutable: boolean ): WasmImport => { return { kind: WasmExternalKind.global, name: importField, + valueName: variableName, importData: [ ...encodeString(importModule), ...encodeString(importField), @@ -87,6 +90,9 @@ export const createModule = (imports?: WasmImport[]): WasmModule => { elementSection: [], codeSection: [], dataSection: [], + // Maps + importGlobals: 0, + importFunctions: 0, }; // Handle Imports if (imports != undefined) { @@ -100,7 +106,7 @@ export const createModule = (imports?: WasmImport[]): WasmModule => { if (wasmImport.kind == WasmExternalKind.function) moduleState.functionMap.set(wasmImport.name, moduleState.functionSection.length - 1); else if (wasmImport.kind == WasmExternalKind.global) - moduleState.globalMap.set(wasmImport.name, moduleState.globalSection.length - 1); + moduleState.globalMap.set(wasmImport.name, moduleState.importGlobals++); // Add Import To Import Section moduleState.importSection.push(wasmImport.importData); } @@ -112,9 +118,9 @@ export const createModule = (imports?: WasmImport[]): WasmModule => { export const addImport = (wasmModule: WasmModule, wasmImport: WasmImport): number => { // Set Import Label if (wasmImport.kind == WasmExternalKind.function) - wasmModule.functionMap.set(wasmImport.name, wasmModule.functionSection.length); + wasmModule.functionMap.set(wasmImport.valueName, wasmModule.functionSection.length); else if (wasmImport.kind == WasmExternalKind.global) - wasmModule.globalMap.set(wasmImport.name, wasmModule.globalSection.length); + wasmModule.globalMap.set(wasmImport.valueName, wasmModule.importGlobals++); // Add Import To Import Section wasmModule.importSection.push(wasmImport.importData); // Add a Empty Section Element So The Index's are correct @@ -160,6 +166,8 @@ export const addFunction = (wasmModule: WasmModule, func: WasmFunction): WasmMod } else if (lastByte == 0x22 && localNames.has(byte)) { wasmBody.push(...unsignedLEB128(localNames.get(byte)!)); // Wasm Local Tee } else if (lastByte == 0x23 && wasmModule.globalMap.has(byte)) { + console.log(byte); + console.log(wasmModule.globalMap); wasmBody.push(...unsignedLEB128(wasmModule.globalMap.get(byte)!)); // Wasm Global Get } else if (lastByte == 0x24 && wasmModule.globalMap.has(byte)) { wasmBody.push(...unsignedLEB128(wasmModule.globalMap.get(byte)!)); // Wasm Global Set @@ -240,7 +248,7 @@ export const addGlobal = ( value: number[] ): number => { // Set Global Label - wasmModule.globalMap.set(globalName, wasmModule.globalSection.length); + wasmModule.globalMap.set(globalName, wasmModule.importGlobals + wasmModule.globalSection.length); // Add The Module wasmModule.globalSection.push([ ...globalType, // Global Type diff --git a/src/wasmBuilder/Types/Nodes.ts b/src/wasmBuilder/Types/Nodes.ts index d494ff4..62c0d5e 100644 --- a/src/wasmBuilder/Types/Nodes.ts +++ b/src/wasmBuilder/Types/Nodes.ts @@ -30,6 +30,7 @@ export const enum WasmSection { export interface WasmImport { kind: WasmExternalKind; name: string; + valueName: string; importData: number[]; } export interface WasmModule { @@ -52,6 +53,9 @@ export interface WasmModule { elementSection: number[][]; codeSection: number[][]; dataSection: number[][]; + // Counts + importGlobals: number; + importFunctions: number; } export interface WasmFunction { name: string; // TODO: Not All Functions Need Names