Changeset 1853 for cobra/trunk/Source/Boxes.cobra
- Timestamp:
- 12/30/08 09:14:09 (3 years ago)
- Files:
-
- 1 modified
-
cobra/trunk/Source/Boxes.cobra (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/Boxes.cobra
r1852 r1853 46 46 _attribs = attribs 47 47 _genericParams = paramList 48 for i = 0 .._genericParams.count48 for i in _genericParams.count 49 49 p = _genericParams[i] 50 if p inherits GenericParam 51 p.index = i 50 if p inherits GenericParam, p.index = i 52 51 _extensions = List<of Extension>() 53 52 _baseInterfaceProxies = baseInterfaceNodes … … 128 127 129 128 get extensions from var 129 130 get allExtensions as Extension* 131 """ Return all extensions including inheritance through all base classes and interfaces. """ 132 require .didBindInh and .didBindInt 133 for ext in .extensions, yield ext 134 if _baseClass, for ext in _baseClass.allExtensions, yield ext 135 for bi in _baseInterfaces, for ext in bi.allExtensions, yield ext 130 136 131 137 get hasExtensions as bool … … 819 825 t._nativeType = nil # The constructed type is really sourced from the generic def. Don't foster confusion with a reference to the original generic def's clr type (if there is one). 820 826 t.cloneCollections 827 821 828 # set the contructed type args immediately or its ancestors will get the original generic args during _bindInt: 822 829 for i in typeArgs.count 823 830 t._genericParams[i] = typeArgs[i] 824 831 assert t._constructedTypes is nil or t._constructedTypes.count == 0 832 825 833 if .didBindInt 826 834 t._completeConstruction(typeArgs) … … 828 836 t._needsConstruction(typeArgs) 829 837 assert t._constructedTypes is nil or t._constructedTypes.count == 0 838 830 839 return t 831 840 … … 871 880 gpToType = TypeUtil.dictionaryOf(_genericDef.genericParams, typeArgs) 872 881 873 _baseClass = _baseClass.secondaryConstructedTypeFor(this, gpToType) to Class882 if _baseClass, _baseClass = _baseClass.secondaryConstructedTypeFor(this, gpToType) to Class 874 883 875 884 assert _baseInterfaceProxies.count == 0 or _baseInterfaceProxies.count == _baseInterfaces.count 876 for i = 0 .._baseInterfaces.count885 for i in _baseInterfaces.count 877 886 _baseInterfaces[i] = _baseInterfaces[i].secondaryConstructedTypeFor(this, gpToType) to Interface 878 887 … … 912 921 _declsByName[decl.name] = decl 913 922 _declsByNameCI[decl.name.toLower] = decl 923 for i in _extensions.count 924 ext = _extensions[i] = _extensions[i].constructedTypeFor(typeArgs) to Extension 925 ext.completeMemberConstructionIfNeeded 914 926 # TODO: can this next statement can be axed since there is a separate "bind inheritance" phase? 915 927 _finishOverloads … … 945 957 _baseInterfaces = List<of Interface>(_baseInterfaces) 946 958 # _overloads = List<of MemberOverload>(_overloads) # these will be recreated 959 _extensions = List<of Extension>(_extensions) 947 960 948 961 def typeForGenericParam(gp as GenericParam) as IType # TODO: is this needed for NilableType? … … 1449 1462 """ 1450 1463 1451 var _extendedBoxProxy as ITypeProxy 1464 var _extendedBoxProxy as ITypeProxy? 1452 1465 var _extendedBox as Box? 1453 1466 … … 1487 1500 if box.isDescendantOf(_extendedBox to !) 1488 1501 return .declForName(name) 1502 else if box.genericDef and (box.genericDef.isDescendantOf(_extendedBox to !) _ 1503 or (_extendedBox.genericDef and box.isDescendantOf(_extendedBox.genericDef.constructedTypeFor(box.genericParams)))) 1504 for ext in box.allExtensions 1505 if ext.genericDef is this 1506 return ext.declForName(name) 1507 throw FallThroughException() 1489 1508 else 1490 1509 return nil … … 1506 1525 1507 1526 if _extendedBox is nil 1527 if _extendedBoxProxy inherits GenericTypeIdentifier 1528 # this will error on the generic params unless we set them up to be found 1529 for tn in _extendedBoxProxy.typeNodes 1530 if tn inherits TypeIdentifier 1531 _genericParams.add(GenericParam(tn.name)) 1532 else 1533 .throwError('Invalid generic param "[tn]".') 1534 1508 1535 realType = _extendedBoxProxy.realType 1509 1536 if realType inherits Box … … 1511 1538 else 1512 1539 .throwError('Cannot extend a [realType.name]. You can extend classes, structs and interfaces.') 1540 1513 1541 _name = '[_extendedBox.name].extension.[.serialNum]' 1514 1542 … … 1519 1547 1520 1548 # connect up 1521 _extendedBox.extensions.add(this) 1549 if _extendedBox.genericDef 1550 _genericParams = List<of IType>(_extendedBox.genericParams) 1551 _extendedBox.genericDef.extensions.add(this) 1552 else 1553 _extendedBox.extensions.add(this) 1522 1554 1523 1555 def _bindInt … … 1548 1580 else 1549 1581 throw FallThroughException([this, decl]) 1550 decl.overloadGroup = nil # Could be in a group from the extension itself. And .addMember below do n't like that.1582 decl.overloadGroup = nil # Could be in a group from the extension itself. And .addMember below doesn't like that. 1551 1583 overload.addMember(decl) 1552 1584 if newOverload, newOverload.bindInt # an overload that never .bindInt will get cranky later



