update: TypeOfNode

This commit is contained in:
Dmitry Bushev 2024-11-20 16:57:55 +00:00
parent 386f4028b1
commit 86bfb986d1
No known key found for this signature in database
GPG Key ID: 87C16090D6910E91
2 changed files with 12 additions and 12 deletions

View File

@ -15,7 +15,6 @@ import org.enso.interpreter.instrument.profiling.ExecutionTime;
import org.enso.interpreter.instrument.profiling.ProfilingInfo;
import org.enso.interpreter.node.callable.FunctionCallInstrumentationNode;
import org.enso.interpreter.runtime.callable.UnresolvedSymbol;
import org.enso.interpreter.runtime.data.EnsoMultiValue;
import org.enso.interpreter.runtime.data.Type;
import org.enso.interpreter.runtime.library.dispatch.TypeOfNode;
import org.enso.interpreter.runtime.type.Constants;
@ -220,22 +219,18 @@ final class ExecutionCallbacks implements IdExecutionService.Callbacks {
return new String[] {Constants.UNRESOLVED_SYMBOL};
}
if (value instanceof EnsoMultiValue multiValue) {
var valueTypes = multiValue.allTypes();
var resultTypes = new String[valueTypes.length];
for (int i = 0; i < valueTypes.length; i++) {
resultTypes[i] = getTypeQualifiedName(valueTypes[i]);
}
return resultTypes;
}
var typeOfNode = TypeOfNode.getUncached();
Object typeResult = value == null ? null : typeOfNode.execute(value);
if (typeResult instanceof Type t) {
return new String[] {getTypeQualifiedName(t)};
}
if (typeResult instanceof Type[] types) {
var result = new String[types.length];
for (int i = 0; i < types.length; i++) {
result[i] = getTypeQualifiedName(types[i]);
}
return result;
}
return null;
}

View File

@ -75,6 +75,11 @@ public abstract class TypeOfNode extends Node {
return withoutWarning.execute(value.getValue());
}
@Specialization
Object doEnsoMultiValue(EnsoMultiValue value) {
return value.allTypes();
}
static boolean isWithType(Object value, TypesLibrary types, InteropLibrary iop) {
if (value instanceof EnsoMultiValue) {
return true;