Skip to content

Commit

Permalink
class bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
thecodacus committed Jul 30, 2022
1 parent c399f6d commit e02f30b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class ClassDeclaration implements Visitor {
const classConstructor=classMethods["janam"];
let classConstructorArgs:string[]=[];
if(classConstructor){
classConstructorArgs=(classConstructor?.id?.args?.map(param=>param?.name).filter(arg => arg)||[])as string[];
classConstructorArgs=(classConstructor?.signature?.args?.map(param=>param?.id?.name).filter(arg => arg)||[])as string[];
}
value={
args:classConstructorArgs,
Expand Down Expand Up @@ -69,8 +69,8 @@ export default class ClassDeclaration implements Visitor {
throw new InvalidStateException(`Sirf funda or variable me shamjha na bhai`);
}
if(member.type==NodeType.FunctionStatement){
if(member?.declaration?.id?.name)
classMethods[member?.declaration?.id?.name]=member.declaration;
if(member?.declaration?.signature?.name)
classMethods[member?.declaration?.signature?.name]=member.declaration;
}
else {
let dataMembers=member.declarations?.map(declaration=>declaration?.id?.name)||[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ export default class FunctionDeclaration implements Visitor {
if (!node.signature || !node.body||!node) {
throw new InvalidStateException(`id or body not found for ${node.type}`);
}

const functionName = node.signature.name

let value;
const body = node.body;
if (body && !Array.isArray(body)) {
let scope=InterpreterModule.getCurrentScope()
value={
const value={
args:node.signature.args?.map(arg=>arg.id?.name)||[],
code:(args:{identifier:string,value:DataObject}[]):any=>{
let oldScope=InterpreterModule.getCurrentScope()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class FunctionStatement implements Visitor {
);
let functionObject=sanatizeData(InterpreterModule.getVisitor(node.declaration.type).visitNode(node.declaration));

const identifier=node?.declaration?.id?.name
const identifier=node?.declaration?.id?.signature?.name
if(identifier){
let scope=InterpreterModule.getCurrentScope();
scope.declare(identifier,functionObject);
Expand Down

0 comments on commit e02f30b

Please sign in to comment.