LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-tyty-call.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 40.0 % 35 14
Test Date: 2024-04-20 14:03:02 Functions: 8.7 % 23 2
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2024 Free Software Foundation, Inc.
       2                 :             : 
       3                 :             : // This file is part of GCC.
       4                 :             : 
       5                 :             : // GCC is free software; you can redistribute it and/or modify it under
       6                 :             : // the terms of the GNU General Public License as published by the Free
       7                 :             : // Software Foundation; either version 3, or (at your option) any later
       8                 :             : // version.
       9                 :             : 
      10                 :             : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11                 :             : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12                 :             : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13                 :             : // for more details.
      14                 :             : 
      15                 :             : // You should have received a copy of the GNU General Public License
      16                 :             : // along with GCC; see the file COPYING3.  If not see
      17                 :             : // <http://www.gnu.org/licenses/>.
      18                 :             : 
      19                 :             : #ifndef RUST_TYTY_CALL
      20                 :             : #define RUST_TYTY_CALL
      21                 :             : 
      22                 :             : #include "rust-diagnostics.h"
      23                 :             : #include "rust-hir-full.h"
      24                 :             : #include "rust-tyty-visitor.h"
      25                 :             : #include "rust-tyty.h"
      26                 :             : #include "rust-hir-type-check.h"
      27                 :             : 
      28                 :             : namespace Rust {
      29                 :             : namespace TyTy {
      30                 :             : 
      31                 :             : class TypeCheckCallExpr : private TyVisitor
      32                 :             : {
      33                 :             : public:
      34                 :        6702 :   static BaseType *go (BaseType *ref, HIR::CallExpr &call,
      35                 :             :                        TyTy::VariantDef &variant,
      36                 :             :                        Resolver::TypeCheckContext *context)
      37                 :             :   {
      38                 :        6702 :     TypeCheckCallExpr checker (call, variant, context);
      39                 :        6702 :     ref->accept_vis (checker);
      40                 :        6702 :     return checker.resolved;
      41                 :             :   }
      42                 :             : 
      43                 :           0 :   void visit (InferType &) override { rust_unreachable (); }
      44                 :           0 :   void visit (TupleType &) override { rust_unreachable (); }
      45                 :           0 :   void visit (ArrayType &) override { rust_unreachable (); }
      46                 :           0 :   void visit (SliceType &) override { rust_unreachable (); }
      47                 :           0 :   void visit (BoolType &) override { rust_unreachable (); }
      48                 :           0 :   void visit (IntType &) override { rust_unreachable (); }
      49                 :           0 :   void visit (UintType &) override { rust_unreachable (); }
      50                 :           0 :   void visit (FloatType &) override { rust_unreachable (); }
      51                 :           0 :   void visit (USizeType &) override { rust_unreachable (); }
      52                 :           0 :   void visit (ISizeType &) override { rust_unreachable (); }
      53                 :           0 :   void visit (ErrorType &) override { rust_unreachable (); }
      54                 :           0 :   void visit (CharType &) override { rust_unreachable (); }
      55                 :           0 :   void visit (ReferenceType &) override { rust_unreachable (); }
      56                 :           0 :   void visit (PointerType &) override { rust_unreachable (); }
      57                 :           0 :   void visit (ParamType &) override { rust_unreachable (); }
      58                 :           0 :   void visit (StrType &) override { rust_unreachable (); }
      59                 :           0 :   void visit (NeverType &) override { rust_unreachable (); }
      60                 :           0 :   void visit (PlaceholderType &) override { rust_unreachable (); }
      61                 :           0 :   void visit (ProjectionType &) override { rust_unreachable (); }
      62                 :           0 :   void visit (DynamicObjectType &) override { rust_unreachable (); }
      63                 :           0 :   void visit (ClosureType &type) override { rust_unreachable (); }
      64                 :             : 
      65                 :             :   // tuple-structs
      66                 :             :   void visit (ADTType &type) override;
      67                 :             : 
      68                 :             :   // call fns
      69                 :             :   void visit (FnType &type) override;
      70                 :             :   void visit (FnPtr &type) override;
      71                 :             : 
      72                 :             : private:
      73                 :        6702 :   TypeCheckCallExpr (HIR::CallExpr &c, TyTy::VariantDef &variant,
      74                 :             :                      Resolver::TypeCheckContext *context)
      75                 :        6702 :     : resolved (new TyTy::ErrorType (c.get_mappings ().get_hirid ())), call (c),
      76                 :        6702 :       variant (variant), context (context),
      77                 :       13404 :       mappings (Analysis::Mappings::get ())
      78                 :        6702 :   {}
      79                 :             : 
      80                 :             :   BaseType *resolved;
      81                 :             :   HIR::CallExpr &call;
      82                 :             :   TyTy::VariantDef &variant;
      83                 :             :   Resolver::TypeCheckContext *context;
      84                 :             :   Analysis::Mappings *mappings;
      85                 :             : };
      86                 :             : 
      87                 :             : class Argument
      88                 :             : {
      89                 :             : public:
      90                 :         517 :   Argument (Analysis::NodeMapping mapping, BaseType *argument_type,
      91                 :             :             location_t locus)
      92                 :         517 :     : mapping (mapping), argument_type (argument_type), locus (locus)
      93                 :             :   {}
      94                 :             : 
      95                 :         517 :   location_t get_locus () const { return locus; }
      96                 :             : 
      97                 :         517 :   BaseType *get_argument_type () { return argument_type; }
      98                 :             : 
      99                 :         517 :   Analysis::NodeMapping get_mappings () const { return mapping; }
     100                 :             : 
     101                 :             : private:
     102                 :             :   Analysis::NodeMapping mapping;
     103                 :             :   BaseType *argument_type;
     104                 :             :   location_t locus;
     105                 :             : };
     106                 :             : 
     107                 :             : class TypeCheckMethodCallExpr
     108                 :             : {
     109                 :             : public:
     110                 :             :   static BaseType *go (FnType *ref, HIR::MethodCallExpr &call,
     111                 :             :                        TyTy::BaseType *adjusted_self,
     112                 :             :                        Resolver::TypeCheckContext *context);
     113                 :             : 
     114                 :             :   static BaseType *go (FnType *ref, Analysis::NodeMapping call_mappings,
     115                 :             :                        std::vector<Argument> &args, location_t call_locus,
     116                 :             :                        location_t receiver_locus, TyTy::BaseType *adjusted_self,
     117                 :             :                        Resolver::TypeCheckContext *context);
     118                 :             : 
     119                 :             : protected:
     120                 :             :   BaseType *check (FnType &type);
     121                 :             : 
     122                 :             :   TypeCheckMethodCallExpr (Analysis::NodeMapping call_mappings,
     123                 :             :                            std::vector<Argument> &args, location_t call_locus,
     124                 :             :                            location_t receiver_locus,
     125                 :             :                            TyTy::BaseType *adjusted_self,
     126                 :             :                            Resolver::TypeCheckContext *context);
     127                 :             : 
     128                 :             :   Analysis::NodeMapping call_mappings;
     129                 :             :   std::vector<Argument> &arguments;
     130                 :             :   location_t call_locus;
     131                 :             :   location_t receiver_locus;
     132                 :             :   TyTy::BaseType *adjusted_self;
     133                 :             :   Resolver::TypeCheckContext *context;
     134                 :             :   Analysis::Mappings *mappings;
     135                 :             : };
     136                 :             : 
     137                 :             : } // namespace TyTy
     138                 :             : } // namespace Rust
     139                 :             : 
     140                 :             : #endif // RUST_TYTY_CALL
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.