Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
!mise.toml
!package-lock.json
!package.json
!patches/
!patches/**
!packages/
!packages/**
!pnpm-lock.yaml
Expand Down
4 changes: 2 additions & 2 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# mise configuration for tinywhale monorepo
[tools]
node = "24.13.0"
pnpm = "10.28.1"
node = "24.15.0"
pnpm = "10.33.0"

[tasks.install]
description = "Install dependencies"
Expand Down
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"author": "",
"description": "A programming language with compiler, CLI, and LSP server",
"devDependencies": {
"@biomejs/biome": "2.3.12",
"@types/node": "25.0.10",
"fast-check": "4.5.3",
"typescript": "5.9.3"
"@biomejs/biome": "2.4.12",
"@types/node": "25.6.0",
"fast-check": "4.7.0",
"typescript": "6.0.3"
},
"engines": {
"node": "24.13.0",
"pnpm": "10.28.0"
"node": "24.15.0",
"pnpm": "10.33.0"
},
"keywords": [
"compiler",
Expand All @@ -18,7 +18,12 @@
],
"license": "MIT",
"name": "tinywhale",
"packageManager": "pnpm@10.28.0",
"packageManager": "pnpm@10.33.0",
"pnpm": {
"patchedDependencies": {
"binaryen@129.0.0-nightly.20260419": "patches/binaryen@129.0.0-nightly.20260419.patch"
}
},
"private": true,
"scripts": {
"start": "mise run"
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"tinywhale": "./dist/cli.js"
},
"dependencies": {
"@adonisjs/ace": "13.4.0",
"@adonisjs/ace": "14.1.0",
"@tinywhale/compiler": "workspace:*",
"@tinywhale/diagnostics": "workspace:*"
},
"description": "TinyWhale command-line interface",
"devDependencies": {
"@types/node": "25.0.10",
"typescript": "5.9.3"
"@types/node": "25.6.0",
"typescript": "6.0.3"
},
"exports": {
".": {
Expand Down
8 changes: 4 additions & 4 deletions packages/cli-grammar-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"tw-grammar-test": "./dist/cli/index.js"
},
"dependencies": {
"@adonisjs/ace": "13.4.0",
"@adonisjs/ace": "14.1.0",
"@tinywhale/grammar-test": "workspace:*",
"ohm-js": "17.3.0"
"ohm-js": "17.5.0"
},
"description": "CLI for grammar testing and analysis",
"devDependencies": {
"@types/node": "25.0.10",
"typescript": "5.9.3"
"@types/node": "25.6.0",
"typescript": "6.0.3"
},
"files": [
"dist"
Expand Down
6 changes: 3 additions & 3 deletions packages/cli-lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"tinywhale-lsp": "./dist/cli.js"
},
"dependencies": {
"@adonisjs/ace": "13.4.0",
"@adonisjs/ace": "14.1.0",
"@tinywhale/lsp": "workspace:*"
},
"description": "TinyWhale Language Server CLI",
"devDependencies": {
"@types/node": "25.0.10",
"typescript": "5.9.3"
"@types/node": "25.6.0",
"typescript": "6.0.3"
},
"exports": {
".": {
Expand Down
8 changes: 4 additions & 4 deletions packages/compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"author": "",
"dependencies": {
"@tinywhale/diagnostics": "workspace:*",
"binaryen": "125.0.0",
"ohm-js": "17.3.0"
"binaryen": "129.0.0-nightly.20260419",
"ohm-js": "17.5.0"
},
"description": "TinyWhale compiler library",
"devDependencies": {
"@ohm-js/cli": "2.0.1",
"@tinywhale/grammar-test": "workspace:*",
"@types/node": "25.0.10",
"typescript": "5.9.3"
"@types/node": "25.6.0",
"typescript": "6.0.3"
},
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/check/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,4 @@ export function finalizeTypeDecl(state: CheckerState, _context: CompilationConte
// ============================================================================

// These are used by checker.ts for FieldInit handling in TypeDecl context
export { getFieldDeclFromLine, resolveUserDefinedFieldType, addFieldToTypeDeclContext }
export { addFieldToTypeDeclContext, getFieldDeclFromLine, resolveUserDefinedFieldType }
4 changes: 4 additions & 0 deletions packages/compiler/src/check/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export function splitBigIntTo32BitParts(
return { high, low }
}

export function combine32BitPartsToBigInt(low: number, high: number): bigint {
return (BigInt(high) << 32n) | BigInt(low >>> 0)
}

/**
* Checks if a value is representable as f32.
*/
Expand Down
15 changes: 7 additions & 8 deletions packages/compiler/src/codegen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
type SymbolId,
type TypeId,
} from '../check/types.ts'
import { combine32BitPartsToBigInt } from '../check/utils.ts'
import { type CompilationContext, DiagnosticSeverity, type StringId } from '../core/context.ts'
import type { DiagnosticCode } from '../core/diagnostics.ts'
import { type NodeId, NodeKind } from '../core/nodes.ts'
Expand Down Expand Up @@ -108,7 +109,7 @@ function emitIntConst(
): binaryen.ExpressionRef {
const binaryenType = toBinaryenType(inst.typeId, context)
if (binaryenType === binaryen.i64) {
return mod.i64.const(getIntConstLow(inst), getIntConstHigh(inst))
return mod.i64.const(combine32BitPartsToBigInt(getIntConstLow(inst), getIntConstHigh(inst)))
}
return mod.i32.const(getIntConstLow(inst))
}
Expand Down Expand Up @@ -210,7 +211,7 @@ function emitNegate(
case binaryen.i32:
return mod.i32.sub(mod.i32.const(0), operand)
case binaryen.i64:
return mod.i64.sub(mod.i64.const(0, 0), operand)
return mod.i64.sub(mod.i64.const(0n), operand)
case binaryen.f32:
return mod.f32.neg(operand)
case binaryen.f64:
Expand All @@ -236,7 +237,7 @@ function emitBitwiseNot(
case binaryen.i32:
return mod.i32.xor(operand, mod.i32.const(-1))
case binaryen.i64:
return mod.i64.xor(operand, mod.i64.const(-1, -1))
return mod.i64.xor(operand, mod.i64.const(-1n))
default:
return null
}
Expand Down Expand Up @@ -268,8 +269,8 @@ function emitEuclideanMod(
}
if (binaryenType === binaryen.i64) {
const absB = mod.select(
mod.i64.lt_s(right, mod.i64.const(0, 0)),
mod.i64.sub(mod.i64.const(0, 0), right),
mod.i64.lt_s(right, mod.i64.const(0n)),
mod.i64.sub(mod.i64.const(0n), right),
right
)
const remainder = mod.i64.rem_s(left, right)
Expand Down Expand Up @@ -493,9 +494,7 @@ function emitLiteralComparison(
const binaryenType = toBinaryenType(typeId, context)

if (binaryenType === binaryen.i64) {
const low = Number(BigInt.asIntN(32, value))
const high = Number(BigInt.asIntN(32, value >> 32n))
return mod.i64.eq(scrutineeExpr, mod.i64.const(low, high))
return mod.i64.eq(scrutineeExpr, mod.i64.const(value))
}

return mod.i32.eq(scrutineeExpr, mod.i32.const(Number(value)))
Expand Down
14 changes: 5 additions & 9 deletions packages/compiler/test/compile.property.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const validProgramArb = fc.oneof(
// Single panic
fc.constant('panic\n'),
// Multiple panics
fc
.integer({ max: 10, min: 1 })
.map((n) => 'panic\n'.repeat(n)),
fc.integer({ max: 10, min: 1 }).map((n) => 'panic\n'.repeat(n)),
// Variable binding with panic
fc
.tuple(fc.constantFrom('i32', 'i64', 'f32', 'f64'), fc.integer({ max: 1000, min: 0 }))
Expand All @@ -20,12 +18,10 @@ const validProgramArb = fc.oneof(
return `x:${type} = ${value}\npanic\n`
}),
// Multiple bindings with panic
fc
.integer({ max: 5, min: 1 })
.map((n) => {
const bindings = Array.from({ length: n }, (_, i) => `v${i}:i32 = ${i}`).join('\n')
return `${bindings}\npanic\n`
})
fc.integer({ max: 5, min: 1 }).map((n) => {
const bindings = Array.from({ length: n }, (_, i) => `v${i}:i32 = ${i}`).join('\n')
return `${bindings}\npanic\n`
})
)

describe('compile/pipeline properties', () => {
Expand Down
6 changes: 3 additions & 3 deletions packages/grammar-test/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"author": "",
"dependencies": {
"ohm-js": "17.3.0"
"ohm-js": "17.5.0"
},
"description": "Generic Ohm.js grammar testing framework and library",
"devDependencies": {
"@types/node": "25.0.10",
"typescript": "5.9.3"
"@types/node": "25.6.0",
"typescript": "6.0.3"
},
"exports": {
".": {
Expand Down
4 changes: 2 additions & 2 deletions packages/lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
},
"description": "TinyWhale Language Server Protocol implementation",
"devDependencies": {
"@types/node": "25.0.10",
"typescript": "5.9.3"
"@types/node": "25.6.0",
"typescript": "6.0.3"
},
"exports": {
".": {
Expand Down
13 changes: 13 additions & 0 deletions patches/binaryen@129.0.0-nightly.20260419.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/index.d.ts b/index.d.ts
index 0000000..0000001 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1331,7 +1331,7 @@ declare module binaryen {
ge_u(left: ExpressionRef, right: ExpressionRef): ExpressionRef;
atomic: {
load(offset: number, ptr: ExpressionRef, name?: string, order?: MemoryOrder): ExpressionRef;
- load8_u(offset: number, ptr: ExpressionRef, name?: string, order?: MemoryOrder: ExpressionRef;
+ load8_u(offset: number, ptr: ExpressionRef, name?: string, order?: MemoryOrder): ExpressionRef;
load16_u(offset: number, ptr: ExpressionRef, name?: string, order?: MemoryOrder): ExpressionRef;
load32_u(offset: number, ptr: ExpressionRef, name?: string, order?: MemoryOrder): ExpressionRef;
store(offset: number, ptr: ExpressionRef, value: ExpressionRef, name?: string, order?: MemoryOrder): ExpressionRef;
Loading
Loading