declaringVisitor property

InterpreterVisitor? declaringVisitor
getter/setter pair

The visitor that declared this class, kept so a script's own toString() override can still be dispatched after the interpreter has unwound.

SCD72. InterpretedInstance.toString() is a plain Object override with nowhere to receive a visitor, and dispatching to interpreted code needs one — which is why the diagnostic form was all a host ever saw. Measured: inside a D4rt.onUncaughtError hook, D4.activeVisitor is NULL, because the interpreter has already unwound by the time the embedder is called. So the ambient visitor cannot carry this and something has to be stored.

ONE REFERENCE PER CLASS, NOT PER INSTANCE, which is the whole reason this field is here rather than on InterpretedInstance: classes are few and instances are many, the class is what owns the method being dispatched, and a per-instance reference would add an allocation to every script object for a string almost none of them are ever asked for.

Assigned once, from InterpreterVisitor.visitClassDeclaration / visitMixinDeclaration. Measured usable after execute returns: a visitor captured during execution still dispatches an instance method afterwards, because it holds the global environment the D4rt instance keeps alive.

Implementation

InterpreterVisitor? declaringVisitor;