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