Skip to content

Commit

Permalink
Add Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
spotandjake committed Aug 25, 2022
1 parent 9b35714 commit 56e4b22
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 5 deletions.
Binary file added Brisk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/LinkTest/index.br.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
9 changes: 8 additions & 1 deletion src/Compiler/Codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Binary file added src/extension/Brisk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
16 changes: 12 additions & 4 deletions src/wasmBuilder/Build/WasmModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const createFunctionImport = (
return {
kind: WasmExternalKind.function,
name: importField,
valueName: importField,
importData: [
...encodeString(importModule),
...encodeString(importField),
Expand All @@ -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),
Expand Down Expand Up @@ -87,6 +90,9 @@ export const createModule = (imports?: WasmImport[]): WasmModule => {
elementSection: [],
codeSection: [],
dataSection: [],
// Maps
importGlobals: 0,
importFunctions: 0,
};
// Handle Imports
if (imports != undefined) {
Expand All @@ -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);
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/wasmBuilder/Types/Nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const enum WasmSection {
export interface WasmImport {
kind: WasmExternalKind;
name: string;
valueName: string;
importData: number[];
}
export interface WasmModule {
Expand All @@ -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
Expand Down

0 comments on commit 56e4b22

Please sign in to comment.