refactor(general): Clean up and add a logger (#587)

* feat(utils): Add logger

* chore: Clean up some classes and add more logging

* chore: Fix conflicts
This commit is contained in:
Luan
2024-01-25 19:01:28 -03:00
committed by GitHub
parent 7fbc37f9d1
commit e86a0daf45
65 changed files with 432 additions and 350 deletions

View File

@@ -1,10 +1,21 @@
import { Jinter } from 'jintr';
import type { VMPrimative } from '../../types/PlatformShim.js';
import { Log } from '../lib.js';
const TAG = 'JsRuntime';
export default function evaluate(code: string, env: Record<string, VMPrimative>) {
Log.info(TAG, 'Evaluating JavaScript.\n', code);
const runtime = new Jinter(code);
for (const [ key, value ] of Object.entries(env)) {
runtime.scope.set(key, value);
}
return runtime.interpret();
const result = runtime.interpret();
Log.info(TAG, 'Done. Result:', result);
return result;
}