65 lines
2.2 KiB
JavaScript
65 lines
2.2 KiB
JavaScript
// Code generated by k2js from instance.kry. DO NOT EDIT.
|
|
import * as kryon from "./kryon-runtime.js";
|
|
|
|
function number_501dbd3c_float(x, w, sign) {
|
|
const bound = 2 ** (w - (sign ? 1 : 0));
|
|
if(!(x >= (sign ? -bound : 0) && x < bound)) throw new RangeError('float conversion out of range');
|
|
return BigInt(Math.trunc(x));
|
|
}
|
|
function number_501dbd3c_value(x, w, sign) {
|
|
if (typeof x === 'number' && !Number.isSafeInteger(x)) throw new RangeError('integer argument requires an exact value');
|
|
x = sign ? BigInt.asIntN(w, BigInt(x)) : BigInt.asUintN(w, BigInt(x));
|
|
return w > 32 ? x : Number(x);
|
|
}
|
|
function number_501dbd3c_bool(x) { if(typeof x !== 'boolean') throw new TypeError('boolean value required'); return x; }
|
|
function number_501dbd3c_bits(a, b, w, sign, op) {
|
|
const shift = BigInt(b); a = BigInt.asUintN(w, BigInt(a)); b = BigInt.asUintN(w, BigInt(b));
|
|
let result;
|
|
switch (op) {
|
|
case 0: result=a; break; case 1: result=a+b; break; case 2: result=a-b; break; case 3: result=a*b; break;
|
|
case 4: case 5:
|
|
if(b === 0n) throw new RangeError('integer division by zero');
|
|
if(sign) { a=BigInt.asIntN(w,a); b=BigInt.asIntN(w,b); }
|
|
result=op === 4 ? a/b : a%b; break;
|
|
case 6: case 7:
|
|
if(shift < 0n || shift >= BigInt(w)) throw new RangeError('invalid shift count');
|
|
result=op === 6 ? a<<shift : (sign ? BigInt.asIntN(w,a) : a)>>shift; break;
|
|
case 8: result=a&b; break; case 9: result=a|b; break; case 10: result=a^b; break;
|
|
default: throw new Error('invalid numeric operation');
|
|
}
|
|
return number_501dbd3c_value(result,w,sign);
|
|
}
|
|
|
|
export const app = {
|
|
title: "instance",
|
|
width: 800,
|
|
height: 600,
|
|
fps: 60,
|
|
frame: "",
|
|
styles: [
|
|
],
|
|
routes: [
|
|
]
|
|
};
|
|
|
|
export function createState() {
|
|
const $state = {};
|
|
return $state;
|
|
}
|
|
|
|
export const moduleState = createState();
|
|
let moduleHost = null;
|
|
export function setHost(host) { moduleHost = host; }
|
|
|
|
export function Instance_InstanceExpired($rt, $state = moduleState, $host = moduleHost, age) {
|
|
$state = $state || moduleState;
|
|
$rt = $rt || kryon.createRuntime();
|
|
return age < 0 || age > 12;
|
|
}
|
|
|
|
export function frame(rt = kryon.createRuntime(), state = moduleState, host = moduleHost) {
|
|
return kryon.snapshot(rt);
|
|
}
|
|
|
|
export default { app, createState, moduleState, setHost, frame };
|