Wiki
Show
Ignore:
Timestamp:
03/10/10 08:30:47 (2 years ago)
Author:
Chuck.Esterbrook
Message:

Code cleanup.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Boxes.cobra

    r2305 r2307  
    285285        body 
    286286            if .genericDef is box, return this 
    287             for bt in .allBaseTypes 
    288                 if bt.genericDef is box 
    289                     return bt 
     287            for bt in .allBaseTypes, if bt.genericDef is box, return bt 
    290288            return nil 
    291289 
     
    495493        if this is .compiler.stringType  # TODO: hacky. solution is to look at the specific type of .current property of enumerator. make a test case that shows that 
    496494            return .compiler.charType 
    497 # can a for loop go through an IEnumerator<of>? 
     495# TODO: can a for loop go through an IEnumerator<of>? 
    498496#       if .isConstructed and .genericDef is .compiler.enumeratorOfType 
    499497#           return .genericParams[0] 
     
    831829        return _genericDef is not nil 
    832830 
    833     def isConstructionOf(box as Box) as bool 
    834         """ 
    835         Returns true if this type is a construction of the given generic type def, even going more than level deep through `genericDef`. 
    836         """ 
    837         # TODO: can this implementation be replaced by: 
    838         # return .constructedTypeOf(box) is not nil 
    839         if .genericDef is nil 
    840             return false 
    841         if .genericDef is box 
    842             return true 
    843         if .genericDef.genericDef 
    844             return .genericDef.isConstructionOf(box) # TODO: would iteration be more efficient here? 
    845         return false 
     831    def isDirectConstructionOf(box as Box) as bool 
     832        """ 
     833        Returns true if this type was directly constructed from the given box. 
     834        """ 
     835        require 
     836            .didBindInh 
     837            box.isGenericDef 
     838        body 
     839            return .genericDef is box 
     840 
     841    def isIndirectConstructionOf(box as Box) as bool 
     842        """ 
     843        Returns true if this type or any of its ancestor types 
     844        is a construction of the given generic type def. 
     845        """ 
     846        require 
     847            .didBindInh 
     848            box.isGenericDef 
     849        body 
     850            return .constructedTypeOf(box) is not nil 
    846851 
    847852    get isGenericDef as bool