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{