From 16e08bded670c6ad192bb18a6f0e1d162fde1fa9 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Sun, 16 Oct 2022 15:49:34 +0200 Subject: [PATCH] bug fixes --- js/ctx.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/ctx.js b/js/ctx.js index 8cb9a72..1791a69 100644 --- a/js/ctx.js +++ b/js/ctx.js @@ -17,11 +17,12 @@ export class context{ f32: { size: 4,type: 2, content: false }, f64: { size: 8,type: 2, content: false }, char: {link:"u8"}, + c: {link:"u8"}, bool: {link:"u8"}, b: {link:"bool"}, }; #upper = []; - constructor(upper =[]){ + constructor(upper = null){ this.#upper = upper; } nextLevel(){ @@ -34,8 +35,8 @@ export class context{ find(name, vType,pos=name.pos,quit=true){ let elem = (this.#list[vType]??{})[name+""]??null; - if(!elem){ - elem = this.#upper.find(name,vType,pos,false); + if (!elem && this.#upper){ + elem = this.#upper.find(name+"",vType,pos,false); } if(!elem&&quit) error("Can not find '"+name+"' in context!",...pos); return elem; @@ -43,10 +44,10 @@ export class context{ getType(name,pos=name.pos, quit = true){ let lastName = name; - let type = this.#types[name]; + let type = this.#types[name+""]; if(!type){ - type = this.#upper.getType(name, pos, false); + if(this.#upper) type = this.#upper.getType(name+"", pos, false); if (!type) error("Can not find '" + name + "' in context", ...pos); return type; }else{