use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.
the class DebugExprNodeFactory method createFunctionCall.
public DebugExpressionPair createFunctionCall(DebugExpressionPair functionPair, List<DebugExpressionPair> arguments) {
checkError(functionPair, "call(...)");
if (functionPair.getNode() instanceof DebugExprVarNode) {
DebugExprVarNode varNode = (DebugExprVarNode) functionPair.getNode();
DebugExprFunctionCallNode node = varNode.createFunctionCall(arguments, globalScope);
DebugExprType type = node.getType();
return DebugExpressionPair.create(node, type);
}
throw DebugExprException.typeError(functionPair.getNode(), functionPair.getNode().toString());
}
use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.
the class DebugExprNodeFactory method createArithmeticOp.
public DebugExpressionPair createArithmeticOp(ArithmeticOperation op, DebugExpressionPair left, DebugExpressionPair right) {
checkError(left, op.name());
checkError(right, op.name());
DebugExprType commonType = DebugExprType.commonType(left.getType(), right.getType());
DebugExpressionPair leftPair = createCastIfNecessary(left, commonType);
DebugExpressionPair rightPair = createCastIfNecessary(right, commonType);
LLVMExpressionNode node = CommonNodeFactory.createArithmeticOp(op, commonType.getLLVMRuntimeType(), leftPair.getNode(), rightPair.getNode());
return DebugExpressionPair.create(node, commonType);
}
use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.
the class DebugExprNodeFactory method createDivNode.
public DebugExpressionPair createDivNode(DebugExpressionPair left, DebugExpressionPair right) {
checkError(left, "/");
checkError(right, "/");
DebugExprType commonType = DebugExprType.commonType(left.getType(), right.getType());
DebugExpressionPair leftPair = createCastIfNecessary(left, commonType);
DebugExpressionPair rightPair = createCastIfNecessary(right, commonType);
ArithmeticOperation op = commonType.isUnsigned() ? ArithmeticOperation.UDIV : ArithmeticOperation.DIV;
LLVMExpressionNode node = CommonNodeFactory.createArithmeticOp(op, commonType.getLLVMRuntimeType(), leftPair.getNode(), rightPair.getNode());
return DebugExpressionPair.create(node, commonType);
}
use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.
the class DebugExprDereferenceNode method getMemberAndType.
@TruffleBoundary
private Pair<Object, DebugExprType> getMemberAndType(Object executedPointerNode) {
if (executedPointerNode == null) {
throw DebugExprException.create(this, "debugObject to dereference is null");
}
try {
LLVMDebuggerValue llvmDebuggerValue = (LLVMDebuggerValue) executedPointerNode;
Object metaObj = llvmDebuggerValue.resolveMetaObject();
DebugExprType pointerType = DebugExprType.getTypeFromSymbolTableMetaObject(metaObj);
if (!pointerType.isPointer()) {
throw DebugExprException.create(this, llvmDebuggerValue + " is no pointer");
}
LLVMSourcePointerType llvmSourcePointerType = (LLVMSourcePointerType) metaObj;
LLVMSourceType llvmSourceType = llvmSourcePointerType.getBaseType();
LLVMDebugObject llvmPointerObject = (LLVMDebugObject) executedPointerNode;
Object llvmPointerValue = llvmPointerObject.getValue();
Builder builder = CommonNodeFactory.createDebugDeclarationBuilder();
LLVMDebugValue dereferencedValue = builder.build(llvmPointerValue);
LLVMDebugObject llvmDebugObject = LLVMDebugObject.create(llvmSourceType, 0L, dereferencedValue, null);
DebugExprType type = pointerType.getInnerType();
return Pair.create(type.parse(llvmDebugObject), type);
} catch (ClassCastException e) {
// throw cast exception of executedPointerNode (2 lines below)
}
throw DebugExprException.create(this, executedPointerNode + " cannot be casted to pointer ");
}
use of com.oracle.truffle.llvm.runtime.debug.debugexpr.parser.DebugExprType in project graal by oracle.
the class DebugExprFunctionCallNode method getType.
@TruffleBoundary
public DebugExprType getType() {
InteropLibrary library = InteropLibrary.getFactory().getUncached();
if (library.isMemberReadable(scope, functionName)) {
try {
Object member = library.readMember(scope, functionName);
if (LLVMManagedPointer.isInstance(member)) {
LLVMManagedPointer pointer = LLVMManagedPointer.cast(member);
if (pointer.getOffset() == 0) {
member = pointer.getObject();
}
}
if (member instanceof LLVMFunctionDescriptor) {
LLVMFunctionDescriptor ldv = (LLVMFunctionDescriptor) member;
Type returnType = ldv.getLLVMFunction().getType().getReturnType();
DebugExprType t = DebugExprType.getTypeFromLLVMType(returnType);
return t;
} else {
throw DebugExprException.create(this, "variable %s does not point to a function", functionName);
}
} catch (UnsupportedMessageException e) {
throw DebugExprException.create(this, "error while accessing function %s", functionName);
} catch (UnknownIdentifierException e) {
// fallthrough
}
}
throw DebugExprException.symbolNotFound(this, functionName, null);
}
Aggregations