calcium-lang
Version:
Calcium language interpreter
28 lines • 1.02 kB
JavaScript
import { default as Sym } from "../symbol";
import createMethod from "./method";
export default function createInstance({ classObj, }) {
const self = new Proxy({}, {
get(target, property, receiver) {
if (property === Sym.evaluate)
return (env) => self;
else if (property === Sym.class)
return classObj;
const instanceProp = Reflect.get(target, property);
if (instanceProp)
return instanceProp;
const classProp = Reflect.get(classObj, property);
const __class__ = Reflect.get(classProp, Sym.class);
if (__class__ === "function") {
return createMethod({ funcObj: classProp, boundObj: self });
}
else {
return classProp;
}
},
set(target, property, value, receiver) {
return Reflect.set(target, property, value);
},
});
return self;
}
//# sourceMappingURL=instance.js.map