Skip to content

Commit 60793e6

Browse files
authored
Merge pull request #7 from btc-vision/upgrade/deps
feat: memory runtime, fixed collections & low-level stdlib primitives
2 parents e08a07e + b2542ac commit 60793e6

363 files changed

Lines changed: 187487 additions & 422557 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ module.exports = {
6565
// Quite often, dealing with multiple related cases at once or otherwise
6666
// falling through is exactly the point of using a switch.
6767
"no-fallthrough": "off",
68+
"no-useless-assignment": "off",
69+
"no-unassigned-vars": "off",
70+
"preserve-caught-error": "off",
6871

6972
// Typical false-positives here are `do { ... } while (true)` statements or
7073
// similar, but the only option provided here is not checking any loops.

.github/workflows/test.yml

Lines changed: 102 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,48 @@ name: Test
22
on:
33
push:
44
branches:
5-
- main
5+
- main
66
pull_request:
77
jobs:
88
check:
99
name: "Check"
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v6
13-
- name: "Check that distribution files are unmodified"
14-
if: github.event_name == 'pull_request'
15-
run: |
16-
if git --no-pager diff --name-only $(git rev-parse origin/${{ github.base_ref }})...${{ github.sha }} | grep -q "^dist/"; then
17-
printf "\nThe pull request modifies distribution files, but it shouldn't.\n" &&
18-
printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/main/CONTRIBUTING.md\n" &&
19-
exit 1;
20-
else
21-
printf "\nOK: Distributions files have not been modified.\n";
22-
fi
12+
- uses: actions/checkout@v6
13+
- uses: actions/setup-node@v6
14+
with:
15+
node-version: '24'
16+
- name: "Check that distribution files are unmodified"
17+
if: github.event_name == 'pull_request'
18+
run: |
19+
if git --no-pager diff --name-only $(git rev-parse origin/${{ github.base_ref }})...${{ github.sha }} | grep -q "^dist/"; then
20+
printf "\nThe pull request modifies distribution files, but it shouldn't.\n" &&
21+
printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/main/CONTRIBUTING.md\n" &&
22+
exit 1;
23+
else
24+
printf "\nOK: Distributions files have not been modified.\n";
25+
fi
2326
compiler:
2427
name: "Compiler (${{ matrix.os }}, node ${{ matrix.node_version }})"
2528
runs-on: ${{ matrix.os }}-latest
2629
needs: check
2730
strategy:
2831
matrix:
2932
os: ["ubuntu", "macos", "windows"]
30-
node_version: ["current", "lts/*"]
33+
node_version: ["25", "lts/*"]
3134
steps:
32-
- uses: actions/checkout@v6
33-
- uses: actions/setup-node@v6
34-
with:
35-
node-version: ${{ matrix.node_version }}
36-
- name: Install dependencies
37-
run: npm ci --no-audit
38-
- name: Build
39-
run: npm run build
40-
- name: Check
41-
run: npm run check
42-
- name: Test
43-
run: npm test
35+
- uses: actions/checkout@v6
36+
- uses: actions/setup-node@v6
37+
with:
38+
node-version: ${{ matrix.node_version }}
39+
- name: Install dependencies
40+
run: npm ci --no-audit
41+
- name: Build
42+
run: npm run build
43+
- name: Check
44+
run: npm run check
45+
- name: Test
46+
run: npm test
4447
bootstrap:
4548
name: "Bootstrap (${{ matrix.target }})"
4649
runs-on: ubuntu-latest
@@ -49,95 +52,97 @@ jobs:
4952
matrix:
5053
target: ["debug", "release"]
5154
steps:
52-
- uses: actions/checkout@v6
53-
- uses: actions/setup-node@v6
54-
with:
55-
node-version: current
56-
- name: Install dependencies
57-
run: npm ci --no-audit
58-
- name: Build
59-
run: npm run build
60-
- name: "Bootstrap ${{ matrix.target }}"
61-
run: npm run bootstrap:${{ matrix.target }}
62-
- name: "Test ${{ matrix.target }}"
63-
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target }}-bootstrap.js
64-
- name: "Compile ${{ matrix.target }} -> ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
65-
run: node bin/asc --config src/asconfig.json --target ${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap --wasm ./build/assemblyscript.${{ matrix.target }}-bootstrap.js
66-
- name: "Test ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
67-
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap.js
55+
- uses: actions/checkout@v6
56+
- uses: actions/setup-node@v6
57+
with:
58+
node-version: current
59+
- name: Install dependencies
60+
run: npm ci --no-audit
61+
- name: Build
62+
run: npm run build
63+
- name: "Bootstrap ${{ matrix.target }}"
64+
run: npm run bootstrap:${{ matrix.target }}
65+
- name: "Test ${{ matrix.target }}"
66+
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target }}-bootstrap.js
67+
- name: "Compile ${{ matrix.target }} -> ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
68+
run: node bin/asc --config src/asconfig.json --target ${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap --wasm ./build/assemblyscript.${{ matrix.target }}-bootstrap.js
69+
- name: "Test ${{ matrix.target == 'debug' && 'release' || 'debug' }}"
70+
run: npm run test:compiler -- --wasm build/assemblyscript.${{ matrix.target == 'debug' && 'release' || 'debug' }}-bootstrap.js
6871
features:
6972
name: "Features"
7073
runs-on: ubuntu-latest
7174
needs: check
7275
steps:
73-
- uses: actions/checkout@v6
74-
- uses: actions/setup-node@v6
75-
- name: Install dependencies
76-
run: npm ci --no-audit
77-
- name: Build
78-
run: npm run build
79-
- name: Test experimental features
80-
env:
81-
ASC_FEATURES: threads,reference-types,gc,exception-handling
82-
run: |
83-
npm run test:compiler features/threads features/reference-types features/gc features/exception-handling bindings/esm bindings/raw
76+
- uses: actions/checkout@v6
77+
- uses: actions/setup-node@v6
78+
with:
79+
node-version: '24'
80+
- name: Install dependencies
81+
run: npm ci --no-audit
82+
- name: Build
83+
run: npm run build
84+
- name: Test experimental features
85+
env:
86+
ASC_FEATURES: threads,reference-types,gc,exception-handling
87+
run: |
88+
npm run test:compiler features/threads features/reference-types features/gc features/exception-handling bindings/esm bindings/raw
8489
runtimes:
8590
name: "Runtimes"
8691
runs-on: ubuntu-latest
8792
needs: check
8893
steps:
89-
- uses: actions/checkout@v6
90-
- uses: actions/setup-node@v6
91-
with:
92-
node-version: current
93-
- name: Install dependencies
94-
run: npm ci --no-audit
95-
- name: Build
96-
run: npm run build
97-
- name: Test default allocator
98-
run: |
99-
cd tests/allocators/default
100-
npm run build
101-
cd ..
102-
npm test default
103-
- name: Test stub allocator
104-
run: |
105-
cd tests/allocators/stub
106-
npm run build
107-
cd ..
108-
npm test stub
94+
- uses: actions/checkout@v6
95+
- uses: actions/setup-node@v6
96+
with:
97+
node-version: current
98+
- name: Install dependencies
99+
run: npm ci --no-audit
100+
- name: Build
101+
run: npm run build
102+
- name: Test default allocator
103+
run: |
104+
cd tests/allocators/default
105+
npm run build
106+
cd ..
107+
npm test default
108+
- name: Test stub allocator
109+
run: |
110+
cd tests/allocators/stub
111+
npm run build
112+
cd ..
113+
npm test stub
109114
loader:
110115
name: "Loader"
111116
runs-on: ubuntu-latest
112117
needs: check
113118
steps:
114-
- uses: actions/checkout@v6
115-
- uses: actions/setup-node@v6
116-
with:
117-
node-version: current
118-
- name: Install dependencies
119-
run: npm ci --no-audit
120-
- name: Build
121-
run: npm run build
122-
- name: Test the loader
123-
run: |
124-
cd lib/loader
125-
npm run asbuild
126-
npm run test
119+
- uses: actions/checkout@v6
120+
- uses: actions/setup-node@v6
121+
with:
122+
node-version: current
123+
- name: Install dependencies
124+
run: npm ci --no-audit
125+
- name: Build
126+
run: npm run build
127+
- name: Test the loader
128+
run: |
129+
cd lib/loader
130+
npm run asbuild
131+
npm run test
127132
coverage:
128133
name: "Coverage"
129134
runs-on: ubuntu-latest
130135
needs: check
131136
steps:
132-
- uses: actions/checkout@v6
133-
- uses: actions/setup-node@v6
134-
with:
135-
node-version: 24
136-
- name: Install dependencies
137-
run: npm ci --no-audit
138-
- name: Build
139-
run: npm run build
140-
- name: Collect coverage
141-
run: npx c8 -r none -- npm test
142-
- name: Output coverage summary
143-
run: npx c8 report -r text-summary
137+
- uses: actions/checkout@v6
138+
- uses: actions/setup-node@v6
139+
with:
140+
node-version: 24
141+
- name: Install dependencies
142+
run: npm ci --no-audit
143+
- name: Build
144+
run: npm run build
145+
- name: Collect coverage
146+
run: npx c8 -r none -- npm test
147+
- name: Output coverage summary
148+
run: npx c8 report -r text-summary

cli/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ export async function main(argv, options) {
300300
switch (opts.runtime) {
301301
case "stub": runtime = 0; break;
302302
case "minimal": runtime = 1; break;
303+
case "memory": runtime = 3; break;
303304
/* incremental */
304305
default: runtime = 2; break;
305306
}
@@ -731,6 +732,12 @@ export async function main(argv, options) {
731732
try {
732733
module = assemblyscript.compile(program);
733734
} catch (e) {
735+
let numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
736+
if (numErrors) {
737+
const err = Error(`${numErrors} compile error(s)`);
738+
err.stack = err.message;
739+
return prepareResult(err);
740+
}
734741
crash("compile", e);
735742
}
736743
stats.compileTime += stats.end(begin);

eslint.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default tseslint.config(
1414
]
1515
},
1616

17+
1718
eslint.configs.recommended,
1819

1920
// === General rules =========================================================
@@ -65,14 +66,17 @@ export default tseslint.config(
6566
// It is perfectly fine to declare top-level variables with `var`, yet this
6667
// rule doesn't provide configuration options that would help.
6768
"no-var": "off",
69+
"no-useless-assignment": "off",
70+
"no-unassigned-vars": "off",
71+
"preserve-caught-error": "off",
6872

6973
// Quite often, dealing with multiple related cases at once or otherwise
7074
// falling through is exactly the point of using a switch.
7175
"no-fallthrough": "off",
7276

7377
// Typical false-positives here are `do { ... } while (true)` statements or
7478
// similar, but the only option provided here is not checking any loops.
75-
"no-constant-condition": ["error", { checkLoops: false }],
79+
"no-constant-condition": ["error", {checkLoops: false}],
7680

7781
// Functions are nested in blocks occasionally, and there haven't been any
7882
// problems with this so far, so turning the check off.

lib/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Additional packages provided by the main package.
55

66
| Package | Description
77
|------------------------------------|-------------------------
8-
| [@assemblyscript/loader](./loader) | Module loader utility
8+
| [@btc-vision/as-loader](./loader) | Module loader utility
99
| [@assemblyscript/rtrace](./rtrace) | Runtime tracing utility
1010
| binaryen | Binaryen proxy
1111

lib/loader/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ A tiny module loader that makes working with AssemblyScript modules as convenien
77
## Example
88

99
```ts
10-
import loader from "@assemblyscript/loader"; // or require
10+
import loader from "@btc-vision/as-loader"; // or require
1111
loader.instantiate(
1212
// Binary to instantiate
1313
fetch("optimized.wasm"), // or fs.readFileSync
@@ -24,19 +24,19 @@ The loader basically instantiates the module using `WebAssembly` APIs, but also
2424

2525
## Installation
2626

27-
The loader can be installed from [npm](https://www.npmjs.com/package/@assemblyscript/loader):
27+
The loader can be installed from [npm](https://www.npmjs.com/package/@btc-vision/as-loader):
2828

2929
```sh
30-
npm install --save @assemblyscript/loader
30+
npm install --save @btc-vision/as-loader
3131
```
3232

3333
On the web:
3434

3535
```html
3636
<!-- ESM -->
37-
<script type="module" src="https://cdn.jsdelivr.net/npm/@assemblyscript/loader/index.js"></script>
37+
<script type="module" src="https://cdn.jsdelivr.net/npm/@btc-vision/as-loader/index.js"></script>
3838
<!-- UMD -->
39-
<script src="https://cdn.jsdelivr.net/npm/@assemblyscript/loader/umd/index.js"></script>
39+
<script src="https://cdn.jsdelivr.net/npm/@btc-vision/as-loader/umd/index.js"></script>
4040
```
4141

4242
## Usage

0 commit comments

Comments
 (0)