add AppMode for best boundaries over stdlib
JaCoCo Coverage #### Project Overview No changes detected, that affect the code coverage. * Line Coverage: 61.98% (17344/27983) * Branch Coverage: 53.07% (6720/12663) * Lines of Code: 27983 * Cyclomatic Complexity: 11207 #### Quality Gates Summary Output truncated.
Test / Build skipped: 11, passed: 581
Intrepid/Prometeu/Studio/pipeline/head This commit looks good
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good

This commit is contained in:
2026-05-14 11:15:00 +01:00
parent 22887b56cd
commit 991863d086
54 changed files with 700 additions and 546 deletions
@@ -0,0 +1,5 @@
[BuiltinType(name = "Color", version = 1)]
declare builtin type Color(
pub raw: int
) {
}
@@ -0,0 +1,36 @@
declare host LowAssets {
[Host(module = "asset", name = "load", version = 1)]
[Capability(name = "asset")]
[AssetLowering(param = 0)]
fn load(addressable: Addressable, slot: int) -> (status: int, loading_handle: int);
[Host(module = "asset", name = "status", version = 1)]
[Capability(name = "asset")]
fn status(loading_handle: int) -> int;
[Host(module = "asset", name = "commit", version = 1)]
[Capability(name = "asset")]
fn commit(loading_handle: int) -> int;
[Host(module = "asset", name = "cancel", version = 1)]
[Capability(name = "asset")]
fn cancel(loading_handle: int) -> int;
}
declare service Assets {
fn load(addressable: Addressable, slot: int) -> (status: int, loading_handle: int) {
return LowAssets.load(addressable, slot);
}
fn status(loading_handle: int) -> int {
return LowAssets.status(loading_handle);
}
fn commit(loading_handle: int) -> int {
return LowAssets.commit(loading_handle);
}
fn cancel(loading_handle: int) -> int {
return LowAssets.cancel(loading_handle);
}
}
@@ -0,0 +1,2 @@
mod host LowAssets;
pub service Assets;
@@ -0,0 +1,60 @@
declare host LowComposer {
[Host(module = "composer", name = "set_camera", version = 1)]
[Capability(name = "gfx")]
fn set_camera(x: int, y: int) -> void;
[Host(module = "composer", name = "bind_scene", version = 1)]
[Capability(name = "gfx")]
fn bind_scene(scene_bank_id: int) -> int;
[Host(module = "composer", name = "unbind_scene", version = 1)]
[Capability(name = "gfx")]
fn unbind_scene() -> int;
[Host(module = "composer", name = "emit_sprite", version = 1)]
[Capability(name = "gfx")]
fn emit_sprite(
glyph_id: int,
palette_id: int,
x: int,
y: int,
layer: int,
bank_id: int,
flip_x: bool,
flip_y: bool,
priority: int
) -> int;
}
declare service Composer
{
fn set_camera(x: int, y: int) -> void
{
LowComposer.set_camera(x, y);
}
fn bind_scene(scene_bank_id: int) -> int
{
return LowComposer.bind_scene(scene_bank_id);
}
fn unbind_scene() -> int
{
return LowComposer.unbind_scene();
}
fn emit_sprite(
glyph_id: int,
palette_id: int,
x: int,
y: int,
layer: int,
bank_id: int,
flip_x: bool,
flip_y: bool,
priority: int
) -> int
{
return LowComposer.emit_sprite(glyph_id, palette_id, x, y, layer, bank_id, flip_x, flip_y, priority);
}
}
@@ -0,0 +1,2 @@
mod host LowComposer;
pub service Composer;
@@ -0,0 +1,78 @@
import { Color } from @core:color;
declare host LowGfx {
[Host(module = "gfx", name = "clear", version = 1)]
[Capability(name = "gfx")]
fn clear(color: Color) -> void;
[Host(module = "gfx", name = "fill_rect", version = 1)]
[Capability(name = "gfx")]
fn fill_rect(x: int, y: int, w: int, h: int, color: Color) -> void;
[Host(module = "gfx", name = "draw_line", version = 1)]
[Capability(name = "gfx")]
fn draw_line(x1: int, y1: int, x2: int, y2: int, color: Color) -> void;
[Host(module = "gfx", name = "draw_circle", version = 1)]
[Capability(name = "gfx")]
fn draw_circle(x: int, y: int, r: int, color: Color) -> void;
[Host(module = "gfx", name = "draw_disc", version = 1)]
[Capability(name = "gfx")]
fn draw_disc(x: int, y: int, r: int, border_color: Color, fill_color: Color) -> void;
[Host(module = "gfx", name = "draw_square", version = 1)]
[Capability(name = "gfx")]
fn draw_square(x: int, y: int, w: int, h: int, border_color: Color, fill_color: Color) -> void;
[Host(module = "gfx", name = "draw_text", version = 1)]
[Capability(name = "gfx")]
fn draw_text(x: int, y: int, message: str, color: Color) -> void;
[Host(module = "gfx", name = "clear_565", version = 1)]
[Capability(name = "gfx")]
fn clear_565(color_565: int) -> void;
}
declare service Gfx
{
fn clear(color: Color) -> void
{
LowGfx.clear(color);
}
fn fill_rect(x: int, y: int, w: int, h: int, color: Color) -> void
{
LowGfx.fill_rect(x, y, w, h, color);
}
fn draw_line(x1: int, y1: int, x2: int, y2: int, color: Color) -> void
{
LowGfx.draw_line(x1, y1, x2, y2, color);
}
fn draw_circle(x: int, y: int, r: int, color: Color) -> void
{
LowGfx.draw_circle(x, y, r, color);
}
fn draw_disc(x: int, y: int, r: int, border_color: Color, fill_color: Color) -> void
{
LowGfx.draw_disc(x, y, r, border_color, fill_color);
}
fn draw_square(x: int, y: int, w: int, h: int, border_color: Color, fill_color: Color) -> void
{
LowGfx.draw_square(x, y, w, h, border_color, fill_color);
}
fn draw_text(x: int, y: int, message: str, color: Color) -> void
{
LowGfx.draw_text(x, y, message, color);
}
fn clear_565(color_565: int) -> void
{
LowGfx.clear_565(color_565);
}
}
@@ -0,0 +1,2 @@
mod host LowGfx;
pub service Gfx;
@@ -0,0 +1,90 @@
[BuiltinType(name = "input", version = 1)]
declare builtin type InputType() {
[IntrinsicCall(name = "pad", version = 1)]
fn pad() -> InputPad;
[IntrinsicCall(name = "touch", version = 1)]
fn touch() -> InputTouch;
}
[BuiltinType(name = "input.pad", version = 1)]
declare builtin type InputPad() {
[IntrinsicCall(name = "up", version = 1)]
fn up() -> InputButton;
[IntrinsicCall(name = "down", version = 1)]
fn down() -> InputButton;
[IntrinsicCall(name = "left", version = 1)]
fn left() -> InputButton;
[IntrinsicCall(name = "right", version = 1)]
fn right() -> InputButton;
[IntrinsicCall(name = "a", version = 1)]
fn a() -> InputButton;
[IntrinsicCall(name = "b", version = 1)]
fn b() -> InputButton;
[IntrinsicCall(name = "x", version = 1)]
fn x() -> InputButton;
[IntrinsicCall(name = "y", version = 1)]
fn y() -> InputButton;
[IntrinsicCall(name = "l", version = 1)]
fn l() -> InputButton;
[IntrinsicCall(name = "r", version = 1)]
fn r() -> InputButton;
[IntrinsicCall(name = "start", version = 1)]
fn start() -> InputButton;
[IntrinsicCall(name = "select", version = 1)]
fn select() -> InputButton;
}
[BuiltinType(name = "input.touch", version = 1)]
declare builtin type InputTouch() {
[IntrinsicCall(name = "button", version = 1)]
fn button() -> InputButton;
[IntrinsicCall(name = "x", version = 1)]
fn x() -> int;
[IntrinsicCall(name = "y", version = 1)]
fn y() -> int;
}
[BuiltinType(name = "input.button", version = 1)]
declare builtin type InputButton() {
[IntrinsicCall(name = "pressed", version = 1)]
fn pressed() -> bool;
[IntrinsicCall(name = "released", version = 1)]
fn released() -> bool;
[IntrinsicCall(name = "down", version = 1)]
fn down() -> bool;
[IntrinsicCall(name = "hold", version = 1)]
fn hold() -> int;
}
[BuiltinConst(target = "input", name = "global", version = 1)]
declare const LowInput: InputType;
declare service Input
{
fn pad() -> InputPad
{
return LowInput.pad();
}
fn touch() -> InputTouch
{
return LowInput.touch();
}
}
@@ -0,0 +1,4 @@
pub struct InputPad;
pub struct InputTouch;
pub struct InputButton;
pub service Input;
@@ -0,0 +1,62 @@
declare host LowLog {
[Host(module = "log", name = "write", version = 1)]
[Capability(name = "log")]
fn write(level: int, message: str) -> void;
[Host(module = "log", name = "write_tag", version = 1)]
[Capability(name = "log")]
fn write_tag(level: int, tag: int, message: str) -> void;
}
declare service Log
{
fn trace(msg: str) -> void
{
LowLog.write(0, msg);
}
fn debug(msg: str) -> void
{
LowLog.write(1, msg);
}
fn info(msg: str) -> void
{
LowLog.write(2, msg);
}
fn warn(msg: str) -> void
{
LowLog.write(3, msg);
}
fn failure(msg: str) -> void
{
LowLog.write(4, msg);
}
fn trace(tag: int, msg: str) -> void
{
LowLog.write_tag(0, tag, msg);
}
fn debug(tag: int, msg: str) -> void
{
LowLog.write_tag(1, tag, msg);
}
fn info(tag: int, msg: str) -> void
{
LowLog.write_tag(2, tag, msg);
}
fn warn(tag: int, msg: str) -> void
{
LowLog.write_tag(3, tag, msg);
}
fn failure(tag: int, msg: str) -> void
{
LowLog.write_tag(4, tag, msg);
}
}
@@ -0,0 +1,2 @@
mod host LowLog;
pub service Log;