Changeset 1583

Show
Ignore:
Timestamp:
08/18/08 12:28:50 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Code cleanup.

Location:
cobra/trunk/Source
Files:
12 modified

Legend:

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

    r1573 r1583  
    6565                                sw.write(sep) 
    6666                                if arg inherits AssignExpr 
    67                                         sw.write(Utils.capped((arg.left to dynamic).name)) 
     67                                        sw.write(((arg.left to dynamic).name to String).capped) # CC: wouldn't need this if extension methods were registered with dynamic binder 
    6868                                        sw.write('=') 
    6969                                        arg = arg.right 
  • cobra/trunk/Source/BinaryOpExpr.cobra

    r1577 r1583  
    356356                                        _left.left.writeSharpDef(sw, false) 
    357357                                        sw.write(', ') 
    358                                         sw.write(Utils.sharpStringLiteralFor(Utils.capped((_left.right to MemberExpr).name))) 
     358                                        sw.write(Utils.sharpStringLiteralFor((_left.right to MemberExpr).name.capped)) 
    359359                                        sw.write(', ') 
    360360                                        _right.writeSharpDef(sw) 
     
    10181018                                _left.writeSharpDef(sw, not _left inherits DotExpr) 
    10191019                                sw.write(', ') 
    1020                                 sw.write(Utils.sharpStringLiteralFor(Utils.capped(_right.name))) 
     1020                                sw.write(Utils.sharpStringLiteralFor(_right.name.capped)) 
    10211021                                sw.write(')') 
    10221022                        else if _right inherits CallExpr 
     
    10251025                                _left.writeSharpDef(sw, not _left inherits DotExpr) 
    10261026                                sw.write(', ') 
    1027                                 sw.write(Utils.sharpStringLiteralFor(Utils.capped(_right.name))) 
     1027                                sw.write(Utils.sharpStringLiteralFor(_right.name.capped)) 
    10281028                                for arg in _right.args 
    10291029                                        sw.write(', ') 
  • cobra/trunk/Source/Boxes.cobra

    r1573 r1583  
    22252225                                        decl.recordError('Extensions can only contain methods, not initializers.') 
    22262226                                else 
    2227                                         decl.sharedMethodBacking = '[sharpName].[Utils.capped(decl.name)]' 
     2227                                        decl.sharedMethodBacking = '[sharpName].[decl.name.capped]' 
    22282228                                        decl.isNames.remove('virtual') 
    22292229                                        decl.isNames.add('nonvirtual') 
  • cobra/trunk/Source/CobraParser.cobra

    r1582 r1583  
    10431043                        if decl inherits Box 
    10441044                                if not (decl inherits Class or decl inherits Struct) 
    1045                                         .throwError(decl.token, '[Utils.capped(decl.englishName)] cannot be "partial".') 
     1045                                        .throwError(decl.token, '[decl.englishName.capped] cannot be "partial".') 
    10461046                                checkForDups = false 
    10471047                                otherDecl = ns.unifiedNameSpace.declForName(decl.name) 
     
    10611061                                        return otherDecl 
    10621062                        else 
    1063                                 .throwError(decl.token, '[Utils.capped(decl.englishName)] cannot be "partial".') 
     1063                                .throwError(decl.token, '[decl.englishName.capped] cannot be "partial".') 
    10641064                if checkForDups 
    10651065                        if ns.declForName(decl.name) 
     
    12081208                name = opener.value to String 
    12091209                curBox = .curBox 
    1210                 if name == curBox.name or Utils.capped(name) == curBox.name 
     1210                if name == curBox.name or name.capped == curBox.name 
    12111211                        .throwError('Method names cannot be the same as their enclosing [curBox.englishName]. Use `def init` for creating an initializer/constructor or choose another name.')  # TODO list the enclosing types location 
    12121212                overload = _overloadIfNeeded(curBox, name)  # also checks for various errors 
  • cobra/trunk/Source/Compiler.cobra

    r1574 r1583  
    15491549                # *sigh* 
    15501550                if fileName.length>=2 and fileName[1]==c':' 
    1551                         fileName = Utils.capped(fileName) 
     1551                        fileName = fileName.capped 
    15521552 
    15531553                # TODO: handle relative paths like ..\foo.cobra which C# spells out as absolute paths 
  • cobra/trunk/Source/Enums.cobra

    r1573 r1583  
    109109 
    110110        get sharpInit as String is override 
    111                 return .sharpRef + '.' + Utils.capped(_declsInOrder[0].name) 
     111                return .sharpRef + '.' + _declsInOrder[0].name.capped 
    112112 
    113113        def writeSharpDef(sw as SharpWriter) is override 
     
    126126                for em as EnumMember in .declsInOrder 
    127127                        sw.write(sep) 
    128                         sw.write(Utils.capped(em.name)) 
     128                        sw.write(em.name.capped) 
    129129                        if em.value 
    130130                                sw.write(' = [em.value]') 
  • cobra/trunk/Source/Expr.cobra

    r1582 r1583  
    729729                        name = (_definition to BoxMember).binaryName to ! 
    730730                else 
    731                         name = Utils.capped(name) 
     731                        name = name.capped 
    732732                sw.write('[name]') 
    733733                if _genericArgTypes and _genericArgTypes.count 
     
    16101610                        name = _definition.binaryName 
    16111611                if name is nil 
    1612                         name = Utils.capped(_name) 
     1612                        name = _name.capped 
    16131613                sw.write(name) 
    16141614                if _definition and (_definition.isMethod or _name=='toString') and not _isReference  # TODO: axe the 'toString' check 
     
    24352435 
    24362436        def writeSharpDef(sw as SharpWriter, parens as bool) is override 
    2437                 sw.write('CobraImp.[Utils.capped(.opName)](') 
     2437                sw.write('CobraImp.[.opName.capped](') 
    24382438                .expr.writeSharpDefInContext(sw) 
    24392439                sw.write(')') 
  • cobra/trunk/Source/Members.cobra

    r1582 r1583  
    440440 
    441441        get sharpName as String is override 
    442                 return Utils.capped(.name) 
     442                return .name.capped 
    443443 
    444444        def writeSharpDef(sw as SharpWriter) is override 
     
    595595                name = .name 
    596596                if not name.startsWith('_') 
    597                         name = Utils.capped(name) 
     597                        name = name.capped 
    598598                return name 
    599599 
     
    14741474                                 
    14751475        get sharpName as String is override 
    1476                 return Utils.capped(.name) 
     1476                return .name.capped 
    14771477 
    14781478 
     
    17911791                        member.name.length 
    17921792                body 
    1793                         base.init(token, member.box, 'test_'+Utils.capped(member.name), List<of Param>(), .getCompiler.voidType, nil, ['shared'], AttributeList(), '') 
     1793                        base.init(token, member.box, 'test_'+member.name.capped, List<of Param>(), .getCompiler.voidType, nil, ['shared'], AttributeList(), '') 
    17941794                        _forMember = member 
    17951795 
     
    17981798                        box.name.length 
    17991799                body 
    1800                         base.init(token, box, 'test_class_'+Utils.capped(box.name), List<of Param>(), .getCompiler.voidType, nil, ['shared'], AttributeList(), '') 
     1800                        base.init(token, box, 'test_class_'+box.name.capped, List<of Param>(), .getCompiler.voidType, nil, ['shared'], AttributeList(), '') 
    18011801                        _forBox = box 
    18021802 
     
    18201820        get sharpName as String is override 
    18211821                if _forMember 
    1822                         name = 'test_'+Utils.capped(_forMember.name) 
     1822                        name = 'test_' + _forMember.name.capped 
    18231823                        if .overloadId <> -1 
    18241824                                name += '_ol_[.overloadId]' 
  • cobra/trunk/Source/Property.cobra

    r1369 r1583  
    3434                .writeSharpAttribs(sw) 
    3535                .writeSharpIsNames(sw) 
    36                 sw.write(' [_returnType.sharpRef] [Utils.capped(.name)]') 
     36                sw.write(' [_returnType.sharpRef] [.name.capped]') 
    3737                .writeSharpBody(sw) 
    3838                getPart = .getPart 
  • cobra/trunk/Source/Statements.cobra

    r1582 r1583  
    12971297        def writeSharpDef(sw as SharpWriter) 
    12981298                base.writeSharpDef(sw) 
    1299                 name = Utils.capped(.name) 
     1299                name = .name.capped 
    13001300                localName = '_lh_event_[.serialNum]' 
    13011301                sw.writeLine('// raise [.name] ...') 
  • cobra/trunk/Source/Types.cobra

    r1523 r1583  
    20852085                        sugg = '' 
    20862086                        if not Utils.isCapped(_name) 
    2087                                 sugg = Utils.capped(_name) 
     2087                                sugg = _name.capped 
    20882088                                other = .compiler.symbolForName(sugg, true, false) 
    20892089                                sugg = if(other, ' Try "[sugg]".', '') 
  • cobra/trunk/Source/Utils.cobra

    r1541 r1583  
    55 
    66use System.Reflection 
     7 
     8 
     9extend String 
     10 
     11        def capped as String 
     12                return Utils.capped(this) 
    713 
    814