Closed
Description
Use-case is dealing with reflection in my testing library. For example, given the following code snippet:
class Vec3 {
constructor(
public x: f64 = 0.0,
public y: f64 = 0.0,
public z: f64 = 0.0,
) {}
}
I would like to compile a few top-level statements:
// Just using this namespace as an example
Reflection.addClass(idof<Vec3>(), "Vec3");
Reflection.addClassProp(idof<Vec3>(), "x", offsetof<Vec3>("x"), Reflection.F64, 0 /* idof<T>() if reference*/);
I'm ready to do a lot of trial and error to reduce these down to something that looks like this:
Reflection.addClass(4, "Vec3"); // since id is known as a constant
Just need a way to push some statements to be parsed the backlog and this would be relatively easy.
module.exports = {
afterCompile(parser: Parser): void { // where do I get the class definition for this parameter?
parser.managedClasses; // should be useful
}
}
Thoughts?