added specs for linkage model

This commit is contained in:
Nilton Constantino
2026-02-02 11:41:26 +00:00
parent 239d7251c3
commit 7f831d8d37
11 changed files with 923 additions and 204 deletions
+5
View File
@@ -0,0 +1,5 @@
{
"project": "sdk",
"script_fe": "pbs",
"produces": "lib"
}
@@ -0,0 +1,12 @@
declare struct Color(raw: bounded)
[[
BLACK: Color(0b),
WHITE: Color(65535b),
RED: Color(63488b),
GREEN: Color(2016b),
BLUE: Color(31b)
]]
declare contract Gfx host {
fn clear(color: Color): void;
}
@@ -0,0 +1,29 @@
declare struct ButtonState(
pressed: bool,
released: bool,
down: bool,
hold_frames: bounded
)
declare struct Pad(
up: ButtonState,
down: ButtonState,
left: ButtonState,
right: ButtonState,
a: ButtonState,
b: ButtonState,
x: ButtonState,
y: ButtonState,
l: ButtonState,
r: ButtonState,
start: ButtonState,
select: ButtonState
)
declare contract Input host {
fn pad(): Pad;
}
fn add(a: int, b: int): int {
return a + b;
}
+5 -2
View File
@@ -1,7 +1,10 @@
{
"project": "test01",
"script_fe": "pbs",
"produces": "app",
"entry": "src/main.pbs",
"out": "build/program.pbc",
"emit_disasm": true,
"emit_symbols": true
"dependencies": {
"sdk": "../sdk"
}
}
-66
View File
@@ -1,66 +0,0 @@
// CartridgeCanonical.pbs
// Purpose: VM Heartbeat Test (Industrial Baseline)
declare struct Color(raw: bounded)
[[
BLACK: Color(0b),
WHITE: Color(65535b),
RED: Color(63488b),
GREEN: Color(2016b),
BLUE: Color(31b)
]]
declare struct ButtonState(
pressed: bool,
released: bool,
down: bool,
hold_frames: bounded
)
declare struct Pad(
up: ButtonState,
down: ButtonState,
left: ButtonState,
right: ButtonState,
a: ButtonState,
b: ButtonState,
x: ButtonState,
y: ButtonState,
l: ButtonState,
r: ButtonState,
start: ButtonState,
select: ButtonState
)
declare contract Gfx host {
fn clear(color: Color): void;
}
declare contract Input host {
fn pad(): Pad;
}
fn add(a: int, b: int): int {
return a + b;
}
fn frame(): void {
// 1. Locals & Arithmetic
let x = 10;
let y = 20;
let z = add(x, y);
// 2. Control Flow (if)
if z == 30 {
// 3. Syscall Clear
Gfx.clear(Color.GREEN);
} else {
Gfx.clear(Color.RED);
}
// 4. Input Snapshot & Nested Member Access
let p = Input.pad();
if p.a.down {
Gfx.clear(Color.BLUE);
}
}
@@ -0,0 +1,22 @@
import { Color, Gfx, Input } from "@test01:sdk";
fn frame(): void {
// 1. Locals & Arithmetic
let x = 10;
let y = 20;
let z = add(x, y);
// 2. Control Flow (if)
if z == 30 {
// 3. Syscall Clear
Gfx.clear(Color.GREEN);
} else {
Gfx.clear(Color.RED);
}
// 4. Input Snapshot & Nested Member Access
let p = Input.pad();
if p.a.down {
Gfx.clear(Color.BLUE);
}
}