Letting me save things to _ or _myVar to throw it away. fixing printing newlines in strings
This commit is contained in:
parent
d36f694d80
commit
586d55df85
3 changed files with 24 additions and 5 deletions
|
|
@ -268,6 +268,10 @@ export function compileAndRun(defs: Definition[], typeDefs: TypeDefinition[] = [
|
|||
|
||||
for (const def of defs) {
|
||||
if (!def.body) continue; // type declaration only
|
||||
if (def.name.startsWith('_')) {
|
||||
definitions.set(def.name, def);
|
||||
continue;
|
||||
}
|
||||
definitions.set(def.name, def);
|
||||
const free = freeVars(def.body);
|
||||
const deps = new Set([...free].filter(v => topLevel.has(v)));
|
||||
|
|
@ -287,6 +291,10 @@ export function compileAndRun(defs: Definition[], typeDefs: TypeDefinition[] = [
|
|||
|
||||
for (const def of defs) {
|
||||
if (!def.body) continue;
|
||||
if (def.name.startsWith('_')) {
|
||||
definitions.set(def.name, def); // keep it..
|
||||
continue; // but don't compile it
|
||||
}
|
||||
const ctx: CompileCtx = { topLevel, bound: new Set() };
|
||||
const compiled = `store[${JSON.stringify(def.name)}] = ${compile(def.body, ctx)};`;
|
||||
compiledDefs.push(compiled);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue