Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasm GC #20

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"tasks": {
"build": "npx run-s build:*",
"build:syntax": "npx bnf-compile ./source/bnf/",
"build:all": "deno task build:syntax & deno task build:compiler",
"build:syntax": "deno run -A npm:bnf-parser ./source/bnf/",
"build:compiler": "deno compile --output salient.exe -A ./source/cli.ts",
"test": "deno test && deno task test:salient",
"test:all": "deno test && deno task test:salient",
"test:deno": "deno test",
"test:salient": "deno run -A ./source/cli.ts test ./tests",
"cli": "deno run -A ./source/cli.ts",
Expand All @@ -17,9 +17,8 @@
},
"imports": {
"~/": "./source/",
"bnf-parser": "npm:bnf-parser@^4.1.0",
"npm-run-all": "npm:npm-run-all@^4.1.5",
"chalk": "npm:chalk@^5.3.0"
"bnf-parser": "npm:bnf-parser@^4.1.3",
"fmt/colors": "https://deno.land/[email protected]/fmt/colors.ts"
},
"lint": {
"include": ["source/"],
Expand Down
47 changes: 24 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{
"name": "salient-lang",
"version": "0.0.0",
"description": "",
"main": "bin/compiler/index.js",
"type": "module",
"files": [
"bin/*"
],
"preferGlobal": true,
"engineStrict": true,
"engines": {
"deno": ">=2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ajanibilby/salient.git"
},
"author": "Ajani James Bilby",
"license": "MIT",
"bugs": {
"url": "https://github.com/ajanibilby/salient/issues"
},
"homepage": "https://salient.moe"
"name": "salient-lang",
"version": "0.0.0",
"description": "",
"main": "bin/compiler/index.js",
"type": "module",
"files": [
"bin/*"
],
"preferGlobal": true,
"engineStrict": true,
"engines": {
"deno": ">=2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ajanibilby/salient.git"
},
"author": "Ajani James Bilby",
"license": "MIT",
"bugs": {
"url": "https://github.com/ajanibilby/salient/issues"
},
"homepage": "https://salient.moe",
"dependencies": { "bnf-parser": "^4.1.3", "npm-run-all": "^4.1.5" }
}
7 changes: 4 additions & 3 deletions source/bnf/syntax.bnf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
program ::= %w* ( stmt_top %w* )* ;
stmt_top ::= function | structure | external | test ;
stmt_top ::= function | structure | data | external | test ;


#=============================
Expand Down Expand Up @@ -78,6 +78,8 @@ structure ::= %("struct" w*) ...name %w* struct_type? %( "{" w* ) struct_stmt* %
struct_attr ::= ...name %( w* ":" w* ) access %terminate ;
struct_spread ::= %( "..." ) access %terminate ;

data ::= %("data" w*) ...name %w* %( "{" w* ) struct_stmt* %( w* "}" w* );

container ::= %(w* "[" w*) ( container_item ( %(w* "," w*) container_item )* %w* %","? )? %("]" w*) ;
container_item ::= container_map | container_value ;
container_map ::= %"." name %(w* "=" w*) expr ;
Expand Down Expand Up @@ -112,11 +114,10 @@ expr ::= expr_arg %w* ( ...expr_infix %w* expr_arg %w* )* ;
| "%" | "*" | "/" | "+" | "-"
| "as" | "instanceof"
| "." | "->" ;
expr_postfix ::= expr_call | expr_get | expr_param | expr_loan ;
expr_postfix ::= expr_call | expr_get | expr_param ;
expr_param ::= %"#[" %w* arg_list? %w* %"]" ;
expr_call ::= %"(" %w* arg_list? %w* %")" ;
expr_get ::= %"[" %w* arg_list? %w* %"]" ;
expr_loan ::= "@" | "$" ;
expr_arg ::= expr_prefix? %w* expr_val %w* expr_postfix* ;
expr_val ::= constant | expr_brackets | block | container | if | name ;
expr_brackets ::= %( "(" w* ) expr %( w* ")" ) ;
Expand Down
39 changes: 20 additions & 19 deletions source/bnf/syntax.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export type Term_Stmt_top = {
count: number,
ref: _Shared.ReferenceRange,
value: [
(Term_Function | Term_Structure | Term_External | Term_Test)
(Term_Function | Term_Structure | Term_Data | Term_External | Term_Test)
]
}
export declare function Parse_Stmt_top (i: string, refMapping?: boolean): _Shared.ParseError | {
Expand Down Expand Up @@ -731,6 +731,24 @@ export declare function Parse_Struct_spread (i: string, refMapping?: boolean): _
isPartial: boolean
}

export type Term_Data = {
type: 'data',
start: number,
end: number,
count: number,
ref: _Shared.ReferenceRange,
value: [
_Literal,
{ type: '(...)*', value: Array<Term_Struct_stmt>, start: number, end: number, count: number, ref: _Shared.ReferenceRange }
]
}
export declare function Parse_Data (i: string, refMapping?: boolean): _Shared.ParseError | {
root: _Shared.SyntaxNode & Term_Data,
reachBytes: number,
reach: null | _Shared.Reference,
isPartial: boolean
}

export type Term_Container = {
type: 'container',
start: number,
Expand Down Expand Up @@ -1111,7 +1129,7 @@ export type Term_Expr_postfix = {
count: number,
ref: _Shared.ReferenceRange,
value: [
(Term_Expr_call | Term_Expr_get | Term_Expr_param | Term_Expr_loan)
(Term_Expr_call | Term_Expr_get | Term_Expr_param)
]
}
export declare function Parse_Expr_postfix (i: string, refMapping?: boolean): _Shared.ParseError | {
Expand Down Expand Up @@ -1172,23 +1190,6 @@ export declare function Parse_Expr_get (i: string, refMapping?: boolean): _Share
isPartial: boolean
}

export type Term_Expr_loan = {
type: 'expr_loan',
start: number,
end: number,
count: number,
ref: _Shared.ReferenceRange,
value: [
(_Literal & {value: "\x40"} | _Literal & {value: "\x24"})
]
}
export declare function Parse_Expr_loan (i: string, refMapping?: boolean): _Shared.ParseError | {
root: _Shared.SyntaxNode & Term_Expr_loan,
reachBytes: number,
reach: null | _Shared.Reference,
isPartial: boolean
}

export type Term_Expr_arg = {
type: 'expr_arg',
start: number,
Expand Down
8 changes: 4 additions & 4 deletions source/bnf/syntax.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import { Compile } from "~/compile.ts";
import { Panic } from "~/compiler/helper.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compile.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve, join, relative, dirname } from "https://deno.land/[email protected]/path/mod.ts";
import { existsSync } from "https://deno.land/[email protected]/fs/mod.ts";
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import Function from "~/compiler/function.ts";
import Package from "~/compiler/package.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import type { Scope } from "~/compiler/codegen/scope.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import { IntrinsicType, bool, u8, i8, u16, i16, u32, i32, u64, i64, f32, f64 } from "~/compiler/intrinsic.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/container.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import Structure from "~/compiler/structure.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/flow-control.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import { LinearType, SolidType, OperandType } from "~/compiler/codegen/expression/type.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as Syntax from "~/bnf/syntax.d.ts";
import { red } from "https://deno.land/[email protected]/fmt/colors.ts";
import { red } from "fmt/colors";

import * as WasmTypes from "~/wasm/type.ts";
import { AssertUnreachable, LatentOffset } from "~/helper.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/infix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import * as WasmTypes from "~/wasm/type.ts";
import Structure from "~/compiler/structure.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/operand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import Structure from "~/compiler/structure.ts";
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/postfix/call.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import Function from "~/compiler/function.ts";
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/codegen/expression/postfix/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import { AssertUnreachable } from "~/helper.ts";
Expand All @@ -21,7 +21,7 @@ export function CompilePostfixes(ctx: Context, syntax: Syntax.Term_Expr_postfix[
switch (act.type) {
case "expr_call": res = CompileCall(ctx, act, res, shouldTail); break;

case "expr_get": case "expr_loan": case "expr_param":
case "expr_get": case "expr_param":
Panic(
`${colors.red("Error")}: Unimplemented postfix operation ${act.type}\n`,
{ path: ctx.file.path, name: ctx.file.name, ref: act.ref }
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/codegen/expression/prefix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as colors from "https://deno.land/[email protected]/fmt/colors.ts";
import * as colors from "fmt/colors";

import type * as Syntax from "~/bnf/syntax.d.ts";
import { IntrinsicValue, f32, f64, i16, i32, i64, i8, u16, u32, u64, u8 } from "~/compiler/intrinsic.ts";
Expand Down
Loading
Loading