bug fixes
This commit is contained in:
parent
675a3d552a
commit
16e08bded6
1 changed files with 6 additions and 5 deletions
11
js/ctx.js
11
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{
|
||||
|
|
Loading…
Reference in a new issue