|
|
@@ -426,7 +426,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
arg_types.push_back(&arg->static_type());
|
|
|
}
|
|
|
SetStaticType(e, arena_->New<TupleValue>(std::move(arg_types)));
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
case ExpressionKind::StructLiteral: {
|
|
|
@@ -436,7 +436,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
arg_types.push_back({arg.name(), &arg.expression().static_type()});
|
|
|
}
|
|
|
SetStaticType(e, arena_->New<StructType>(std::move(arg_types)));
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
case ExpressionKind::StructTypeLiteral: {
|
|
|
@@ -455,7 +455,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
} else {
|
|
|
SetStaticType(&struct_type, arena_->New<TypeType>());
|
|
|
}
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
case ExpressionKind::FieldAccessExpression: {
|
|
|
@@ -490,7 +490,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
for (auto& method : t_class.methods()) {
|
|
|
if (access.field() == method.name) {
|
|
|
SetStaticType(&access, method.value);
|
|
|
- access.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ access.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -512,7 +512,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
arena_->New<FunctionType>(
|
|
|
std::vector<Nonnull<const GenericBinding*>>(),
|
|
|
*parameter_types, &aggregate_type));
|
|
|
- access.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ access.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
default:
|
|
|
@@ -534,17 +534,15 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
}
|
|
|
}
|
|
|
SetStaticType(&ident, &ident.named_entity().static_type());
|
|
|
- // TODO: this should depend on what entity this name resolves to, but
|
|
|
- // we don't have access to that information yet.
|
|
|
- ident.set_value_category(Expression::ValueCategory::Var);
|
|
|
+ ident.set_value_category(ident.named_entity().value_category());
|
|
|
return;
|
|
|
}
|
|
|
case ExpressionKind::IntLiteral:
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
SetStaticType(e, arena_->New<IntType>());
|
|
|
return;
|
|
|
case ExpressionKind::BoolLiteral:
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
SetStaticType(e, arena_->New<BoolType>());
|
|
|
return;
|
|
|
case ExpressionKind::PrimitiveOperatorExpression: {
|
|
|
@@ -559,7 +557,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectExactType(e->source_loc(), "negation", arena_->New<IntType>(),
|
|
|
ts[0]);
|
|
|
SetStaticType(&op, arena_->New<IntType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Add:
|
|
|
ExpectExactType(e->source_loc(), "addition(1)",
|
|
|
@@ -567,7 +565,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectExactType(e->source_loc(), "addition(2)",
|
|
|
arena_->New<IntType>(), ts[1]);
|
|
|
SetStaticType(&op, arena_->New<IntType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Sub:
|
|
|
ExpectExactType(e->source_loc(), "subtraction(1)",
|
|
|
@@ -575,7 +573,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectExactType(e->source_loc(), "subtraction(2)",
|
|
|
arena_->New<IntType>(), ts[1]);
|
|
|
SetStaticType(&op, arena_->New<IntType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Mul:
|
|
|
ExpectExactType(e->source_loc(), "multiplication(1)",
|
|
|
@@ -583,7 +581,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectExactType(e->source_loc(), "multiplication(2)",
|
|
|
arena_->New<IntType>(), ts[1]);
|
|
|
SetStaticType(&op, arena_->New<IntType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::And:
|
|
|
ExpectExactType(e->source_loc(), "&&(1)", arena_->New<BoolType>(),
|
|
|
@@ -591,7 +589,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectExactType(e->source_loc(), "&&(2)", arena_->New<BoolType>(),
|
|
|
ts[1]);
|
|
|
SetStaticType(&op, arena_->New<BoolType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Or:
|
|
|
ExpectExactType(e->source_loc(), "||(1)", arena_->New<BoolType>(),
|
|
|
@@ -599,27 +597,27 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectExactType(e->source_loc(), "||(2)", arena_->New<BoolType>(),
|
|
|
ts[1]);
|
|
|
SetStaticType(&op, arena_->New<BoolType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Not:
|
|
|
ExpectExactType(e->source_loc(), "!", arena_->New<BoolType>(), ts[0]);
|
|
|
SetStaticType(&op, arena_->New<BoolType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Eq:
|
|
|
ExpectExactType(e->source_loc(), "==", ts[0], ts[1]);
|
|
|
SetStaticType(&op, arena_->New<BoolType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case Operator::Deref:
|
|
|
ExpectPointerType(e->source_loc(), "*", ts[0]);
|
|
|
SetStaticType(&op, &cast<PointerType>(*ts[0]).type());
|
|
|
- op.set_value_category(Expression::ValueCategory::Var);
|
|
|
+ op.set_value_category(ValueCategory::Var);
|
|
|
return;
|
|
|
case Operator::Ptr:
|
|
|
ExpectExactType(e->source_loc(), "*", arena_->New<TypeType>(), ts[0]);
|
|
|
SetStaticType(&op, arena_->New<TypeType>());
|
|
|
- op.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ op.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
break;
|
|
|
@@ -656,7 +654,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
&call.argument().static_type());
|
|
|
}
|
|
|
SetStaticType(&call, return_type);
|
|
|
- call.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ call.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
default: {
|
|
|
@@ -674,12 +672,12 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
ExpectIsConcreteType(fn.return_type().source_loc(),
|
|
|
interpreter_.InterpExp(values, &fn.return_type()));
|
|
|
SetStaticType(&fn, arena_->New<TypeType>());
|
|
|
- fn.set_value_category(Expression::ValueCategory::Let);
|
|
|
+ fn.set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
case ExpressionKind::StringLiteral:
|
|
|
SetStaticType(e, arena_->New<StringType>());
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
case ExpressionKind::IntrinsicExpression: {
|
|
|
auto& intrinsic_exp = cast<IntrinsicExpression>(*e);
|
|
|
@@ -694,7 +692,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
arena_->New<StringType>(),
|
|
|
&intrinsic_exp.args().fields()[0]->static_type());
|
|
|
SetStaticType(e, TupleValue::Empty());
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -703,7 +701,7 @@ void TypeChecker::TypeCheckExp(Nonnull<Expression*> e, Env values) {
|
|
|
case ExpressionKind::StringTypeLiteral:
|
|
|
case ExpressionKind::TypeTypeLiteral:
|
|
|
case ExpressionKind::ContinuationTypeLiteral:
|
|
|
- e->set_value_category(Expression::ValueCategory::Let);
|
|
|
+ e->set_value_category(ValueCategory::Let);
|
|
|
SetStaticType(e, arena_->New<TypeType>());
|
|
|
return;
|
|
|
case ExpressionKind::UnimplementedExpression:
|
|
|
@@ -861,7 +859,7 @@ void TypeChecker::TypeCheckStmt(Nonnull<Statement*> s, Env values) {
|
|
|
TypeCheckExp(&assign.lhs(), values);
|
|
|
ExpectType(s->source_loc(), "assign", &assign.lhs().static_type(),
|
|
|
&assign.rhs().static_type());
|
|
|
- if (assign.lhs().value_category() != Expression::ValueCategory::Var) {
|
|
|
+ if (assign.lhs().value_category() != ValueCategory::Var) {
|
|
|
FATAL_COMPILATION_ERROR(assign.source_loc())
|
|
|
<< "Cannot assign to rvalue '" << assign.lhs() << "'";
|
|
|
}
|