calcium-lang
Version:
Calcium language interpreter
25 lines • 984 B
JavaScript
import { default as Sym } from "../symbol";
import { AttributeNotFound } from "../error";
import object from "./object";
import createMethod from "./method";
export default function createSuper({ classObj, instance, }) {
const self = new Proxy({}, {
get(target, property, receiver) {
if (typeof property === "string") {
let superclass = Reflect.get(classObj, Sym.superclass);
while (superclass !== object) {
const funcObj = Reflect.get(superclass, property);
if (funcObj) {
return createMethod({ funcObj, boundObj: instance });
}
superclass = Reflect.get(classObj, Sym.superclass);
}
}
else if (property === Sym.class)
return "super";
throw new AttributeNotFound(property.toString());
},
});
return self;
}
//# sourceMappingURL=super.js.map