diff options
author | Yizhe <yizhe@pku.edu.cn> | 2021-02-16 08:26:56 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-19 10:34:59 +0000 |
commit | 59ce2a981b15c22ab8311aa241cf5d80eada9fbd (patch) | |
tree | 2c24c7a1f7fa56ddf3d756b3cee0e9f350e92159 /gcc | |
parent | 68a2f3d7eaa60516a40037dadb6761e69b7863f7 (diff) | |
download | gcc-59ce2a981b15c22ab8311aa241cf5d80eada9fbd.zip gcc-59ce2a981b15c22ab8311aa241cf5d80eada9fbd.tar.gz gcc-59ce2a981b15c22ab8311aa241cf5d80eada9fbd.tar.bz2 |
Renamed `combine` to `unify`
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-method-resolve.h | 6 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-expr.h | 26 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-implitem.h | 6 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-item.h | 2 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-stmt.h | 6 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-toplevel.h | 4 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check.cc | 12 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty-rules.h | 30 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 68 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.h | 34 |
10 files changed, 97 insertions, 97 deletions
diff --git a/gcc/rust/typecheck/rust-hir-method-resolve.h b/gcc/rust/typecheck/rust-hir-method-resolve.h index 95009d63..b85da5a 100644 --- a/gcc/rust/typecheck/rust-hir-method-resolve.h +++ b/gcc/rust/typecheck/rust-hir-method-resolve.h @@ -66,14 +66,14 @@ public: // FIXME this can be simplified with // https://github.com/Rust-GCC/gccrs/issues/187 - auto combined = receiver->combine (self_lookup); - if (combined == nullptr) + auto unified_ty = receiver->unify (self_lookup); + if (unified_ty == nullptr) { // incompatible self argument then this is not a valid method for this // receiver return; } - delete combined; + delete unified_ty; probed.push_back (&method); } diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h index 2cd60f3..07d0d4c 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.h +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h @@ -155,7 +155,7 @@ public: return; } - infered = fn_return_tyty->combine (expr_ty); + infered = fn_return_tyty->unify (expr_ty); fn_return_tyty->append_reference (expr_ty->get_ref ()); for (auto &ref : infered->get_combined_refs ()) fn_return_tyty->append_reference (ref); @@ -245,7 +245,7 @@ public: auto lhs = TypeCheckExpr::Resolve (expr.get_lhs (), false); auto rhs = TypeCheckExpr::Resolve (expr.get_rhs (), false); - auto result = lhs->combine (rhs); + auto result = lhs->unify (rhs); if (result->get_kind () == TyTy::TypeKind::ERROR) { rust_error_at (expr.get_locus (), @@ -469,7 +469,7 @@ public: return; } - infered = lhs->combine (rhs); + infered = lhs->unify (rhs); infered->append_reference (lhs->get_ref ()); infered->append_reference (rhs->get_ref ()); } @@ -479,7 +479,7 @@ public: auto lhs = TypeCheckExpr::Resolve (expr.get_lhs (), false); auto rhs = TypeCheckExpr::Resolve (expr.get_rhs (), false); - auto result = lhs->combine (rhs); + auto result = lhs->unify (rhs); if (result == nullptr || result->get_kind () == TyTy::TypeKind::ERROR) return; @@ -496,16 +496,16 @@ public: // we expect the lhs and rhs must be bools at this point TyTy::BoolType elhs (expr.get_mappings ().get_hirid ()); - lhs = elhs.combine (lhs); + lhs = elhs.unify (lhs); if (lhs == nullptr || lhs->get_kind () == TyTy::TypeKind::ERROR) return; TyTy::BoolType rlhs (expr.get_mappings ().get_hirid ()); - rhs = elhs.combine (rhs); + rhs = elhs.unify (rhs); if (lhs == nullptr || lhs->get_kind () == TyTy::TypeKind::ERROR) return; - infered = lhs->combine (rhs); + infered = lhs->unify (rhs); infered->append_reference (lhs->get_ref ()); infered->append_reference (rhs->get_ref ()); } @@ -575,7 +575,7 @@ public: auto else_blk_resolved = TypeCheckExpr::Resolve (expr.get_else_block (), inside_loop); - infered = if_blk_resolved->combine (else_blk_resolved); + infered = if_blk_resolved->unify (else_blk_resolved); } void visit (HIR::IfExprConseqIf &expr) @@ -585,7 +585,7 @@ public: auto else_blk = TypeCheckExpr::Resolve (expr.get_conseq_if_expr (), inside_loop); - infered = if_blk->combine (else_blk); + infered = if_blk->unify (else_blk); } void visit (HIR::BlockExpr &expr); @@ -601,7 +601,7 @@ public: return; } - auto resolved_index_expr = size_ty->combine ( + auto resolved_index_expr = size_ty->unify ( TypeCheckExpr::Resolve (expr.get_index_expr (), false)); if (resolved_index_expr == nullptr) { @@ -656,7 +656,7 @@ public: infered_array_elems = types[0]; for (size_t i = 1; i < types.size (); i++) { - infered_array_elems = infered_array_elems->combine (types.at (i)); + infered_array_elems = infered_array_elems->unify (types.at (i)); } for (auto &elem : types) @@ -822,8 +822,8 @@ public: return; } - TyTy::BaseType *combined = loop_context->combine (break_expr_tyty); - context->swap_head_loop_context (combined); + TyTy::BaseType *unified_ty = loop_context->unify (break_expr_tyty); + context->swap_head_loop_context (unified_ty); } infered = new TyTy::UnitType (expr.get_mappings ().get_hirid ()); diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.h b/gcc/rust/typecheck/rust-hir-type-check-implitem.h index 6a744c8..b24a280 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-implitem.h +++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.h @@ -43,7 +43,7 @@ public: TyTy::BaseType *expr_type = TypeCheckExpr::Resolve (constant.get_expr (), false); - context->insert_type (constant.get_mappings (), type->combine (expr_type)); + context->insert_type (constant.get_mappings (), type->unify (expr_type)); } void visit (HIR::Function &function) @@ -172,7 +172,7 @@ public: context->push_return_type (expected_ret_tyty); auto result = TypeCheckExpr::Resolve (function.function_body.get (), false); - auto ret_resolved = expected_ret_tyty->combine (result); + auto ret_resolved = expected_ret_tyty->unify (result); if (ret_resolved == nullptr) return; @@ -205,7 +205,7 @@ public: auto result = TypeCheckExpr::Resolve (method.get_function_body ().get (), false); - auto ret_resolved = expected_ret_tyty->combine (result); + auto ret_resolved = expected_ret_tyty->unify (result); if (ret_resolved == nullptr) return; diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.h b/gcc/rust/typecheck/rust-hir-type-check-item.h index 35a1028..c66be57 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.h +++ b/gcc/rust/typecheck/rust-hir-type-check-item.h @@ -76,7 +76,7 @@ public: context->push_return_type (expected_ret_tyty); auto result = TypeCheckExpr::Resolve (function.function_body.get (), false); - auto ret_resolved = expected_ret_tyty->combine (result); + auto ret_resolved = expected_ret_tyty->unify (result); if (ret_resolved == nullptr) return; diff --git a/gcc/rust/typecheck/rust-hir-type-check-stmt.h b/gcc/rust/typecheck/rust-hir-type-check-stmt.h index 9b7d688..d443e87 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-stmt.h +++ b/gcc/rust/typecheck/rust-hir-type-check-stmt.h @@ -72,15 +72,15 @@ public: // let x:i32 = 123; if (specified_ty != nullptr && init_expr_ty != nullptr) { - auto combined = specified_ty->combine (init_expr_ty); - if (combined->get_kind () == TyTy::TypeKind::ERROR) + auto unified_ty = specified_ty->unify (init_expr_ty); + if (unified_ty->get_kind () == TyTy::TypeKind::ERROR) { rust_fatal_error (stmt.get_locus (), "failure in setting up let stmt type"); return; } - context->insert_type (stmt.get_mappings (), combined); + context->insert_type (stmt.get_mappings (), unified_ty); } else { diff --git a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h index d223295..838d2dc 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-toplevel.h +++ b/gcc/rust/typecheck/rust-hir-type-check-toplevel.h @@ -88,7 +88,7 @@ public: TyTy::BaseType *type = TypeCheckType::Resolve (var.get_type ()); TyTy::BaseType *expr_type = TypeCheckExpr::Resolve (var.get_expr (), false); - context->insert_type (var.get_mappings (), type->combine (expr_type)); + context->insert_type (var.get_mappings (), type->unify (expr_type)); } void visit (HIR::ConstantItem &constant) @@ -97,7 +97,7 @@ public: TyTy::BaseType *expr_type = TypeCheckExpr::Resolve (constant.get_expr (), false); - context->insert_type (constant.get_mappings (), type->combine (expr_type)); + context->insert_type (constant.get_mappings (), type->unify (expr_type)); } void visit (HIR::Function &function) diff --git a/gcc/rust/typecheck/rust-hir-type-check.cc b/gcc/rust/typecheck/rust-hir-type-check.cc index 87abb8c..a43dcf6 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.cc +++ b/gcc/rust/typecheck/rust-hir-type-check.cc @@ -73,7 +73,7 @@ TypeResolution::Resolve (HIR::Crate &crate) bool ok = context->lookup_builtin ("i32", &default_integer); rust_assert (ok); - auto result = ty->combine (default_integer); + auto result = ty->unify (default_integer); result->set_ref (id); context->insert_type ( Analysis::NodeMapping (mappings->get_current_crate (), 0, id, @@ -87,7 +87,7 @@ TypeResolution::Resolve (HIR::Crate &crate) bool ok = context->lookup_builtin ("f32", &default_float); rust_assert (ok); - auto result = ty->combine (default_float); + auto result = ty->unify (default_float); result->set_ref (id); context->insert_type ( Analysis::NodeMapping (mappings->get_current_crate (), 0, id, @@ -164,7 +164,7 @@ TypeCheckStructExpr::visit (HIR::StructExprStructFields &struct_expr) TyTy::BaseType *base_resolved = TypeCheckExpr::Resolve (struct_expr.struct_base->base_struct.get (), false); - resolved = struct_path_resolved->combine (base_resolved); + resolved = struct_path_resolved->unify (base_resolved); if (resolved == nullptr) { rust_fatal_error ( @@ -338,7 +338,7 @@ TypeCheckStructExpr::visit (HIR::StructExprFieldIdentifierValue &field) return; } - resolved_field = field_type->get_field_type ()->combine (value); + resolved_field = field_type->get_field_type ()->unify (value); if (resolved_field != nullptr) { fields_assigned.insert (field.field_name); @@ -367,7 +367,7 @@ TypeCheckStructExpr::visit (HIR::StructExprFieldIndexValue &field) return; } - resolved_field = field_type->get_field_type ()->combine (value); + resolved_field = field_type->get_field_type ()->unify (value); if (resolved_field != nullptr) { fields_assigned.insert (field_name); @@ -400,7 +400,7 @@ TypeCheckStructExpr::visit (HIR::StructExprFieldIdentifier &field) field.get_locus ()); TyTy::BaseType *value = TypeCheckExpr::Resolve (&expr, false); - resolved_field = field_type->get_field_type ()->combine (value); + resolved_field = field_type->get_field_type ()->unify (value); if (resolved_field != nullptr) { fields_assigned.insert (field.field_name); diff --git a/gcc/rust/typecheck/rust-tyty-rules.h b/gcc/rust/typecheck/rust-tyty-rules.h index f5c74a5..5593371 100644 --- a/gcc/rust/typecheck/rust-tyty-rules.h +++ b/gcc/rust/typecheck/rust-tyty-rules.h @@ -33,7 +33,7 @@ class BaseRules : public TyVisitor public: virtual ~BaseRules () {} - BaseType *combine (BaseType *other) + BaseType *unify (BaseType *other) { other->accept_vis (*this); if (resolved != nullptr) @@ -423,7 +423,7 @@ public: void visit (StructFieldType &type) { - BaseType *ty = base->get_field_type ()->combine (type.get_field_type ()); + BaseType *ty = base->get_field_type ()->unify (type.get_field_type ()); if (ty == nullptr) return; @@ -480,17 +480,17 @@ public: auto a = base->param_at (i).second; auto b = type.param_at (i).second; - auto combined_param = a->combine (b); - if (combined_param == nullptr) + auto unified_param = a->unify (b); + if (unified_param == nullptr) { BaseRules::visit (type); return; } } - auto combined_return - = base->get_return_type ()->combine (type.get_return_type ()); - if (combined_return == nullptr) + auto unified_return + = base->get_return_type ()->unify (type.get_return_type ()); + if (unified_return == nullptr) { BaseRules::visit (type); return; @@ -512,7 +512,7 @@ public: void visit (ArrayType &type) override { // check base type - auto base_resolved = base->get_type ()->combine (type.get_type ()); + auto base_resolved = base->get_type ()->unify (type.get_type ()); if (base_resolved == nullptr) { // fixme add error message @@ -670,14 +670,14 @@ public: TyTy::StructFieldType *base_field = base->get_field (i); TyTy::StructFieldType *other_field = type.get_field (i); - BaseType *combined = base_field->combine (other_field); - if (combined == nullptr) + BaseType *unified_ty = base_field->unify (other_field); + if (unified_ty == nullptr) { BaseRules::visit (type); return; } - fields.push_back ((TyTy::StructFieldType *) combined); + fields.push_back ((TyTy::StructFieldType *) unified_ty); } resolved = new TyTy::ADTType (type.get_ref (), type.get_ty_ref (), @@ -707,14 +707,14 @@ public: BaseType *bo = base->get_field (i); BaseType *fo = type.get_field (i); - BaseType *combined = bo->combine (fo); - if (combined == nullptr) + BaseType *unified_ty = bo->unify (fo); + if (unified_ty == nullptr) { BaseRules::visit (type); return; } - fields.push_back (combined->get_ref ()); + fields.push_back (unified_ty->get_ref ()); } resolved @@ -806,7 +806,7 @@ public: auto base_type = base->get_base (); auto other_base_type = type.get_base (); - TyTy::BaseType *base_resolved = base_type->combine (other_base_type); + TyTy::BaseType *base_resolved = base_type->unify (other_base_type); resolved = new ReferenceType (base->get_ref (), base->get_ty_ref (), base_resolved->get_ref ()); } diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index e6e8c63..a3a2ffe 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -38,10 +38,10 @@ UnitType::as_string () const } BaseType * -UnitType::combine (BaseType *other) +UnitType::unify (BaseType *other) { UnitRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -72,10 +72,10 @@ InferType::as_string () const } BaseType * -InferType::combine (BaseType *other) +InferType::unify (BaseType *other) { InferRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -98,7 +98,7 @@ ErrorType::as_string () const } BaseType * -ErrorType::combine (BaseType *other) +ErrorType::unify (BaseType *other) { // FIXME // rust_error_at (); @@ -124,10 +124,10 @@ StructFieldType::as_string () const } BaseType * -StructFieldType::combine (BaseType *other) +StructFieldType::unify (BaseType *other) { StructFieldTypeRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -159,10 +159,10 @@ ADTType::as_string () const } BaseType * -ADTType::combine (BaseType *other) +ADTType::unify (BaseType *other) { ADTRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -205,10 +205,10 @@ TupleType::get_field (size_t index) const } BaseType * -TupleType::combine (BaseType *other) +TupleType::unify (BaseType *other) { TupleRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -241,10 +241,10 @@ FnType::as_string () const } BaseType * -FnType::combine (BaseType *other) +FnType::unify (BaseType *other) { FnRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -273,10 +273,10 @@ ArrayType::as_string () const } BaseType * -ArrayType::combine (BaseType *other) +ArrayType::unify (BaseType *other) { ArrayRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -309,10 +309,10 @@ BoolType::as_string () const } BaseType * -BoolType::combine (BaseType *other) +BoolType::unify (BaseType *other) { BoolRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -348,10 +348,10 @@ IntType::as_string () const } BaseType * -IntType::combine (BaseType *other) +IntType::unify (BaseType *other) { IntRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -388,10 +388,10 @@ UintType::as_string () const } BaseType * -UintType::combine (BaseType *other) +UintType::unify (BaseType *other) { UintRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -422,10 +422,10 @@ FloatType::as_string () const } BaseType * -FloatType::combine (BaseType *other) +FloatType::unify (BaseType *other) { FloatRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -448,10 +448,10 @@ USizeType::as_string () const } BaseType * -USizeType::combine (BaseType *other) +USizeType::unify (BaseType *other) { USizeRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -473,10 +473,10 @@ ISizeType::as_string () const } BaseType * -ISizeType::combine (BaseType *other) +ISizeType::unify (BaseType *other) { ISizeRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -498,10 +498,10 @@ CharType::as_string () const } BaseType * -CharType::combine (BaseType *other) +CharType::unify (BaseType *other) { CharRules r (this); - return r.combine (other); + return r.unify (other); } BaseType * @@ -523,10 +523,10 @@ ReferenceType::as_string () const } BaseType * -ReferenceType::combine (BaseType *other) +ReferenceType::unify (BaseType *other) { ReferenceRules r (this); - return r.combine (other); + return r.unify (other); } const BaseType * @@ -581,7 +581,7 @@ TypeCheckCallExpr::visit (ADTType &type) return false; } - auto res = field_tyty->combine (arg); + auto res = field_tyty->unify (arg); if (res == nullptr) return false; @@ -623,7 +623,7 @@ TypeCheckCallExpr::visit (FnType &type) return false; } - auto resolved_argument_type = fnparam.second->combine (argument_expr_tyty); + auto resolved_argument_type = fnparam.second->unify (argument_expr_tyty); if (resolved_argument_type == nullptr) { rust_error_at (param->get_locus_slow (), @@ -674,7 +674,7 @@ TypeCheckMethodCallExpr::visit (FnType &type) return false; } - auto resolved_argument_type = fnparam.second->combine (argument_expr_tyty); + auto resolved_argument_type = fnparam.second->unify (argument_expr_tyty); if (resolved_argument_type == nullptr) { rust_error_at (param->get_locus_slow (), diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 2b63b93..df39d04 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -67,7 +67,7 @@ public: virtual std::string as_string () const = 0; - virtual BaseType *combine (BaseType *other) = 0; + virtual BaseType *unify (BaseType *other) = 0; virtual bool is_unit () const { return kind == TypeKind::UNIT; } @@ -118,7 +118,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; @@ -145,7 +145,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; }; @@ -167,7 +167,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; }; @@ -191,7 +191,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; std::string get_name () const { return name; } @@ -223,7 +223,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; size_t num_fields () const { return fields.size (); } @@ -267,7 +267,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; size_t num_fields () const { return fields.size (); } @@ -332,7 +332,7 @@ public: BaseType *return_type () { return type; } - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; size_t num_params () const { return params.size (); } @@ -374,7 +374,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; size_t get_capacity () const { return capacity; } @@ -404,7 +404,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; }; @@ -434,7 +434,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; IntKind get_kind () const { return int_kind; } @@ -469,7 +469,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; UintKind get_kind () const { return uint_kind; } @@ -502,7 +502,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; FloatKind get_kind () const { return float_kind; } @@ -527,7 +527,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; }; @@ -547,7 +547,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; }; @@ -568,7 +568,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; }; @@ -594,7 +594,7 @@ public: std::string as_string () const override; - BaseType *combine (BaseType *other) override; + BaseType *unify (BaseType *other) override; BaseType *clone () final override; |