Changeset 1712

Show
Ignore:
Timestamp:
10/28/08 00:26:04 (2 months ago)
Author:
Chuck.Esterbrook
Message:

Code cleanup.

Files:
1 modified

Legend:

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

    r1711 r1712  
    663663                        return base.replaceChild(find, replace) 
    664664 
    665         def _bindInt is override 
    666                 base._bindInt 
    667                 # TODO: cleanup. try pushing this to .bindInt 
     665        def bindInt as INode 
    668666                .compiler.codeMemberStack.push(this) 
    669667                try 
    670                         assert .parentBox.didUnNilReturnTypes 
    671                         for param in _params 
    672                                 param.bindInt 
    673                         if _returnType is nil 
    674                                 if _returnTypeNode 
    675                                         _returnType = _returnTypeNode.realType 
    676                                 else 
    677                                         _returnType = .compiler.voidType 
    678                                 assert _returnType, _returnTypeNode 
    679                         if _requirePart is nil and .willRequire 
    680                                 _requirePart = RequirePart(this) 
    681                         if _requirePart 
    682                                 _requirePart.bindInt 
    683                         if _ensurePart is nil and .willEnsure 
    684                                 _ensurePart = EnsurePart(this) 
    685                         if _ensurePart 
    686                                 _ensurePart.bindInt 
     668                        return base.bindInt 
    687669                finally 
    688670                        .compiler.codeMemberStack.pop 
    689  
    690         def _bindImp is override 
    691                 base._bindImp 
     671                 
     672        def _bindInt is override 
     673                assert .compiler.codeMemberStack.peek is this 
     674                base._bindInt 
     675                assert .parentBox.didUnNilReturnTypes 
     676                for param in _params, param.bindInt 
     677                if _returnType is nil 
     678                        if _returnTypeNode, _returnType = _returnTypeNode.realType 
     679                        else, _returnType = .compiler.voidType 
     680                        assert _returnType, _returnTypeNode 
     681                if _requirePart is nil and .willRequire, _requirePart = RequirePart(this) 
     682                if _requirePart, _requirePart.bindInt 
     683                if _ensurePart is nil and .willEnsure, _ensurePart = EnsurePart(this) 
     684                if _ensurePart, _ensurePart.bindInt 
     685 
     686        def bindImp as dynamic 
    692687                .compiler.codeMemberStack.push(this) 
    693688                try 
    694                         .computeMatchingBaseMember  # cannot currently go in .bindInt because it uses .memberForName which triggers other things like generic construction completion 
    695                         if .matchingBaseMember and 'override' in .isNames and 'private' in .matchingBaseMember.isNames 
    696                                 .recordError('Cannot override the base member which is declared "private".') 
    697                         for param in _params 
    698                                 param.bindImp 
    699                         for local in _locals 
    700                                 local.bindImp 
    701                         if _requirePart 
    702                                 _requirePart.bindImp 
    703                         if _ensurePart and _returnType and _returnType is not .compiler.voidType 
    704                                 _sharpResultVarName = '_lh_result' 
    705                         else 
    706                                 _sharpResultVarName = '' 
    707                         _curStmtIndex = 0 
    708                         for stmt in _stmts.toArray 
    709                                 try 
    710                                         stmt.bindImp 
    711                                         stmt.afterStatementBindImp  # to let expressions know when they are used as statements 
    712                                 catch ne as NodeException 
    713                                         .compiler.recordError(ne) 
    714                                 _curStmtIndex += 1 
    715                         for param in _params 
    716                                 assert param.ifInheritsStack.count == 0 
    717                         if _ensurePart 
    718                                 _ensurePart.bindImp 
    719                         if _requirePart 
    720                                 _requirePart.checkConnectToken 
    721                         if _ensurePart 
    722                                 _ensurePart.checkConnectToken 
    723                         .checkForUnmarkedOverrideOrNew  # have to do this after statements bindImp since using base can add `override` 
    724                         .checkForUnusedVariables 
     689                        return base.bindImp 
    725690                finally 
    726691                        .compiler.codeMemberStack.pop 
     692                 
     693        def _bindImp is override 
     694                assert .compiler.codeMemberStack.peek is this 
     695                base._bindImp 
     696                .computeMatchingBaseMember  # cannot currently go in .bindInt because it uses .memberForName which triggers other things like generic construction completion 
     697                if .matchingBaseMember and 'override' in .isNames and 'private' in .matchingBaseMember.isNames 
     698                        .recordError('Cannot override the base member which is declared "private".') 
     699                for param in _params 
     700                        param.bindImp 
     701                for local in _locals 
     702                        local.bindImp 
     703                if _requirePart 
     704                        _requirePart.bindImp 
     705                if _ensurePart and _returnType and _returnType is not .compiler.voidType 
     706                        _sharpResultVarName = '_lh_result' 
     707                else 
     708                        _sharpResultVarName = '' 
     709                _curStmtIndex = 0 
     710                for stmt in _stmts.toArray 
     711                        try 
     712                                stmt.bindImp 
     713                                stmt.afterStatementBindImp  # to let expressions know when they are used as statements 
     714                        catch ne as NodeException 
     715                                .compiler.recordError(ne) 
     716                        _curStmtIndex += 1 
     717                for param in _params 
     718                        assert param.ifInheritsStack.count == 0 
     719                if _ensurePart 
     720                        _ensurePart.bindImp 
     721                if _requirePart 
     722                        _requirePart.checkConnectToken 
     723                if _ensurePart 
     724                        _ensurePart.checkConnectToken 
     725                .checkForUnmarkedOverrideOrNew  # have to do this after statements bindImp since using base can add `override` 
     726                .checkForUnusedVariables 
    727727 
    728728        var _didComputeMatchingBaseMember = true 
     
    10141014 
    10151015        def _bindInt is override 
    1016                 .compiler.codeMemberStack.push(this) 
    1017                 try 
    1018                         assert .compiler.codeMemberStack.peek is this 
    1019                         for param in _genericParams 
    1020                                 param.bindInt 
    1021                         base._bindInt 
    1022                         if .name == '__init__' 
    1023                                 .compiler.warning(this, 'Initializers are named "init" with no surrounding underscores.') 
    1024                 finally 
    1025                         .compiler.codeMemberStack.pop 
     1016                assert .compiler.codeMemberStack.peek is this 
     1017                for param in _genericParams, param.bindInt 
     1018                base._bindInt 
     1019                if .name == '__init__', .compiler.warning(this, 'Initializers are named "init" with no surrounding underscores.') 
    10261020 
    10271021        def _bindImp is override