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 },
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{