Changeset 3e5dd913 for src/AST/Type.cpp


Ignore:
Timestamp:
Dec 16, 2020, 2:43:12 PM (4 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
53449a4
Parents:
13fece5
Message:

reimplement function type and eliminate deep copy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Type.cpp

    r13fece5 r3e5dd913  
    2121
    2222#include "Decl.hpp"
    23 #include "ForallSubstitutor.hpp" // for substituteForall
    2423#include "Init.hpp"
    2524#include "Common/utility.h"      // for copy, move
     
    9291// GENERATED END
    9392
    94 // --- ParameterizedType
    95 
    96 void FunctionType::initWithSub(
    97         const FunctionType & o, Pass< ForallSubstitutor > & sub
    98 ) {
    99         forall = sub.core( o.forall );
    100 }
    101 
    10293// --- FunctionType
    103 
    104 
    105 FunctionType::FunctionType( const FunctionType & o )
    106 : Type( o.qualifiers, copy( o.attributes ) ), returns(), params(),
    107   isVarArgs( o.isVarArgs ) {
    108         Pass< ForallSubstitutor > sub;
    109         initWithSub( o, sub );           // initialize substitution map
    110         returns = sub.core( o.returns ); // apply to return and parameter types
    111         params = sub.core( o.params );
    112 }
    113 
    11494namespace {
    11595        bool containsTtype( const std::vector<ptr<Type>> & l ) {
     
    199179                // TODO: once TypeInstType representation is updated, it should properly check
    200180                // if the context id is filled. this is a temporary hack for now
    201                 return isUnboundType(typeInst->name);
    202         }
    203         return false;
    204 }
    205 
    206 bool isUnboundType(const std::string & tname) {
    207         // xxx - look for a type name produced by renameTyVars.
    208 
    209         // TODO: once TypeInstType representation is updated, it should properly check
    210         // if the context id is filled. this is a temporary hack for now
    211         if (std::count(tname.begin(), tname.end(), '_') >= 3) {
    212                 return true;
     181                return typeInst->formal_usage > 0;
    213182        }
    214183        return false;
Note: See TracChangeset for help on using the changeset viewer.