Wiki
Show
Ignore:
Timestamp:
03/08/10 06:19:46 (2 years ago)
Author:
Chuck.Esterbrook
Message:

Code cleanup. In CobraType?.memberForName, assert that the type .didBindInh and .didBindInt. Also, create all nilable types through .typeProvider.nilableType(t) and cache.

Files:
1 modified

Legend:

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

    r2277 r2304  
    483483    var _unspecifiedType as UnspecifiedType? 
    484484    var _voidType as VoidType? 
     485    var _nilableTypes as Dictionary<of INode, NilableType>? 
    485486    var _variTypes as Dictionary<of INode, VariType>? 
    486487    var _nilableDynamicType as NilableType? 
     
    597598        return _voidType to ! 
    598599 
     600    def nilableType(type as IType) as NilableType 
     601        if type inherits NilableType, return type 
     602        if _nilableTypes is nil 
     603            _nilableTypes = Dictionary<of INode, NilableType>() 
     604        if _nilableTypes.containsKey(type) 
     605            return _nilableTypes[type] 
     606        else 
     607            _nilableTypes[type] = nt = NilableType(type) 
     608            nt.bindInh 
     609            nt.bindInt 
     610            return nt 
     611 
    599612    def variType(type as IType) as VariType 
    600613        if _variTypes is nil 
     
    615628 
    616629    ## More type stuff 
    617  
    618     def nilableType(t as IType) as NilableType 
    619         """ 
    620         Returns a NilableType wrapper for t, unless t is already a NilableType in which case 
    621         it is returned directly. 
    622         """ 
    623         if t inherits NilableType 
    624             return t 
    625         else 
    626             return NilableType(t).bindAll to NilableType  # CC: axe cast after "as this" 
    627630 
    628631    def readSystemTypes