use of com.oracle.truffle.espresso.descriptors.Utf8ConstantTable in project graal by oracle.
the class EspressoInstrumentableNode method getScope.
@ExportMessage
@TruffleBoundary
@SuppressWarnings("static-method")
public final Object getScope(Frame frame, @SuppressWarnings("unused") boolean nodeEnter) {
// construct the current scope with valid local variables information
Method method = getMethod();
Local[] liveLocals = method.getLocalVariableTable().getLocalsAt(getBci(frame));
if (liveLocals.length == 0) {
// class was compiled without a local variable table
// include "this" in method arguments throughout the method
boolean hasReceiver = !method.isStatic();
int localCount = hasReceiver ? 1 : 0;
localCount += method.getParameterCount();
liveLocals = new Local[localCount];
Klass[] parameters = (Klass[]) method.getParameters();
Utf8ConstantTable utf8Constants = getContext().getLanguage().getUtf8ConstantTable();
int startslot = 0;
if (hasReceiver) {
// include 'this' and method arguments
liveLocals[0] = new Local(utf8Constants.getOrCreate(Symbol.Name.thiz), utf8Constants.getOrCreate(method.getDeclaringKlass().getType()), 0, 65536, 0);
startslot++;
}
// include method parameters
for (int i = startslot; i < localCount; i++) {
Klass param = hasReceiver ? parameters[i - 1] : parameters[i];
liveLocals[i] = new Local(utf8Constants.getOrCreate(ByteSequence.create("param_" + (i))), utf8Constants.getOrCreate(param.getType()), 0, 65536, i);
}
}
return EspressoScope.createVariables(liveLocals, frame, method.getName());
}
Aggregations