bug fixes

This commit is contained in:
jusax23 2022-10-16 15:49:34 +02:00
parent 675a3d552a
commit 16e08bded6

View file

@ -17,11 +17,12 @@ export class context{
f32: { size: 4,type: 2, content: false }, f32: { size: 4,type: 2, content: false },
f64: { size: 8,type: 2, content: false }, f64: { size: 8,type: 2, content: false },
char: {link:"u8"}, char: {link:"u8"},
c: {link:"u8"},
bool: {link:"u8"}, bool: {link:"u8"},
b: {link:"bool"}, b: {link:"bool"},
}; };
#upper = []; #upper = [];
constructor(upper =[]){ constructor(upper = null){
this.#upper = upper; this.#upper = upper;
} }
nextLevel(){ nextLevel(){
@ -34,8 +35,8 @@ export class context{
find(name, vType,pos=name.pos,quit=true){ find(name, vType,pos=name.pos,quit=true){
let elem = (this.#list[vType]??{})[name+""]??null; let elem = (this.#list[vType]??{})[name+""]??null;
if(!elem){ if (!elem && this.#upper){
elem = this.#upper.find(name,vType,pos,false); elem = this.#upper.find(name+"",vType,pos,false);
} }
if(!elem&&quit) error("Can not find '"+name+"' in context!",...pos); if(!elem&&quit) error("Can not find '"+name+"' in context!",...pos);
return elem; return elem;
@ -43,10 +44,10 @@ export class context{
getType(name,pos=name.pos, quit = true){ getType(name,pos=name.pos, quit = true){
let lastName = name; let lastName = name;
let type = this.#types[name]; let type = this.#types[name+""];
if(!type){ 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); if (!type) error("Can not find '" + name + "' in context", ...pos);
return type; return type;
}else{ }else{