Fixing too much. also, the OS is actually spawning and managing windows
This commit is contained in:
parent
62f6e202b0
commit
db4abfa450
5 changed files with 168 additions and 130 deletions
18
src/main.ts
18
src/main.ts
|
|
@ -2,7 +2,7 @@ import { compileAndRun } from './compiler'
|
|||
import { tokenize } from './lexer'
|
||||
import { Parser } from './parser'
|
||||
import { runAppCompiled } from './runtime-compiled'
|
||||
import { _rt, loadDefinitions, saveDefinitions } from './runtime-js'
|
||||
import { _rt, store, loadDefinitions, saveDefinitions } from './runtime-js'
|
||||
|
||||
const modules = import.meta.glob('./cg/*.cg', { query: 'raw', import: 'default', eager: true });
|
||||
const cgCode = Object.keys(modules)
|
||||
|
|
@ -13,20 +13,22 @@ const cgCode = Object.keys(modules)
|
|||
const canvas = document.createElement('canvas') as HTMLCanvasElement;
|
||||
document.body.appendChild(canvas);
|
||||
|
||||
// Populate store with natives
|
||||
for (const [name, value] of Object.entries(_rt)) {
|
||||
store[name] = value;
|
||||
}
|
||||
|
||||
store.viewport = { width: window.innerWidth, height: window.innerHeight };
|
||||
|
||||
try {
|
||||
const tokens = tokenize(cgCode);
|
||||
const parser = new Parser(tokens, cgCode);
|
||||
const defs = parser.parse();
|
||||
loadDefinitions();
|
||||
const os = compileAndRun(defs);
|
||||
compileAndRun(defs);
|
||||
saveDefinitions();
|
||||
|
||||
runAppCompiled(
|
||||
{ init: os.init, update: os.update, view: os.view },
|
||||
canvas,
|
||||
_rt
|
||||
);
|
||||
|
||||
runAppCompiled(canvas, store);
|
||||
} catch(error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue