Handle null types
This commit is contained in:
@@ -228,6 +228,9 @@ llvm::Value *ModuleBuilder::valueForExpression(shared_ptr<Expression> expression
|
|||||||
}
|
}
|
||||||
|
|
||||||
llvm::Value *ModuleBuilder::valueForLiteral(shared_ptr<ExpressionLiteral> expression) {
|
llvm::Value *ModuleBuilder::valueForLiteral(shared_ptr<ExpressionLiteral> expression) {
|
||||||
|
if (expression->getValueType() == nullptr)
|
||||||
|
return llvm::UndefValue::get(typeVoid);
|
||||||
|
|
||||||
switch (expression->getValueType()->getKind()) {
|
switch (expression->getValueType()->getKind()) {
|
||||||
case ValueTypeKind::NONE:
|
case ValueTypeKind::NONE:
|
||||||
return llvm::UndefValue::get(typeVoid);
|
return llvm::UndefValue::get(typeVoid);
|
||||||
|
|||||||
@@ -367,6 +367,9 @@ string Logger::toString(shared_ptr<ExpressionGrouping> expression) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string Logger::toString(shared_ptr<ExpressionLiteral> expression) {
|
string Logger::toString(shared_ptr<ExpressionLiteral> expression) {
|
||||||
|
if (expression->getValueType() == nullptr)
|
||||||
|
return "?";
|
||||||
|
|
||||||
switch (expression->getValueType()->getKind()) {
|
switch (expression->getValueType()->getKind()) {
|
||||||
case ValueTypeKind::NONE:
|
case ValueTypeKind::NONE:
|
||||||
return "NONE";
|
return "NONE";
|
||||||
@@ -392,6 +395,8 @@ string Logger::toString(shared_ptr<ExpressionCall> expression) {
|
|||||||
string Logger::toString(shared_ptr<ExpressionBlock> expression) {
|
string Logger::toString(shared_ptr<ExpressionBlock> expression) {
|
||||||
string text;
|
string text;
|
||||||
text += toString(expression->getStatementBlock());
|
text += toString(expression->getStatementBlock());
|
||||||
|
if (!text.empty())
|
||||||
|
text += '\n';
|
||||||
if (expression->getResultStatementExpression() != nullptr)
|
if (expression->getResultStatementExpression() != nullptr)
|
||||||
text += toString(expression->getResultStatementExpression());
|
text += toString(expression->getResultStatementExpression());
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
@@ -54,13 +54,15 @@ Expression(ExpressionKind::BINARY, nullptr), operation(ExpressionBinaryOperation
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Types must match
|
if (left->getValueType() != nullptr && right->getValueType() != nullptr) {
|
||||||
if (left->getValueType() != right->getValueType())
|
// Types must match
|
||||||
valueType = ValueType::NONE;
|
if (left->getValueType() != right->getValueType())
|
||||||
|
valueType = ValueType::NONE;
|
||||||
|
|
||||||
// Booleans can only do = or !=
|
// Booleans can only do = or !=
|
||||||
if (valueType->getKind() == ValueTypeKind::BOOL && (token->getKind() != TokenKind::EQUAL || token->getKind() != TokenKind::NOT_EQUAL))
|
if (valueType->getKind() == ValueTypeKind::BOOL && (token->getKind() != TokenKind::EQUAL || token->getKind() != TokenKind::NOT_EQUAL))
|
||||||
valueType = ValueType::NONE;
|
valueType = ValueType::NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionBinaryOperation ExpressionBinary::getOperation() {
|
ExpressionBinaryOperation ExpressionBinary::getOperation() {
|
||||||
|
|||||||
Reference in New Issue
Block a user