Skip to content

Commit

Permalink
50053
Browse files Browse the repository at this point in the history
15564 Association key:value:
	https://pharo.fogbugz.com/f/cases/15564

15549 "References an abstract class" should check method
	https://pharo.fogbugz.com/f/cases/15549

15566 Direct dependency from CompiledMethod to the bytecode set
	https://pharo.fogbugz.com/f/cases/15566

15523 Code Cruft Rule Only Matches One-Liners
	https://pharo.fogbugz.com/f/cases/15523

http://files.pharo.org/image/50/50053.zip
  • Loading branch information
Jenkins Build Server authored and ci committed May 20, 2015
1 parent d024c98 commit 2e7d6b2
Show file tree
Hide file tree
Showing 43 changed files with 209 additions and 87 deletions.
@@ -1,5 +1,5 @@
separateKeywords
"#'foo:zork:' separateKeywords -> 'foo: zork:'"
"#'foo:zork:' separateKeywords -> 'foo: zork:'"

self isKeyword
ifFalse: [ ^ self ].
Expand Down
Expand Up @@ -2,4 +2,4 @@ key: newKey value: newValue
"Answer an instance of me with the arguments as the key and value of
the association."

^(super key: newKey) value: newValue
^self basicNew key: newKey value: newValue

This file was deleted.

@@ -0,0 +1,27 @@
markerOrNilFor: compiledMethod
"What is a marker method? It is method with body like
'self subclassResponsibility' or '^ self subclassResponsibility'
used to indicate ('mark') a special property.
Marker methods compile to bytecode like:
9 <70> self
10 <D0> send: <literal 1>
11 <87> pop
12 <78> returnSelf
for the first form, or
9 <70> self
10 <D0> send: <literal 1>
11 <7C> returnTop
for the second form."

| e |
((e := compiledMethod endPC) = 19 or: [e = 20]) ifFalse: [^ nil].
(compiledMethod numLiterals = 3) ifFalse:[^ nil].
(compiledMethod at: 17) = 76 ifFalse:[^ nil]. "push self"
(compiledMethod at: 18) = 128 ifFalse:[^ nil]. "send <literal 1>"
"If we reach this point, we have a marker method that sends self <literal 1>"
^ compiledMethod literalAt: 1
@@ -0,0 +1,2 @@
prepareMethod: compiledMethod forSimulationWith: numArgs
self shouldBeImplemented
@@ -0,0 +1,6 @@
sendsToSuperFor: compiledMethod
"Answer whether the receiver sends any message to super."
| scanner |
scanner := InstructionStream on: compiledMethod.
^ scanner scanFor:
[:instr | instr = 235 ]

This file was deleted.

@@ -0,0 +1,27 @@
markerOrNilFor: compiledMethod
"What is a marker method? It is method with body like
'self subclassResponsibility' or '^ self subclassResponsibility'
used to indicate ('mark') a special property.
Marker methods compile to bytecode like:
9 <70> self
10 <D0> send: <literal 1>
11 <87> pop
12 <78> returnSelf
for the first form, or
9 <70> self
10 <D0> send: <literal 1>
11 <7C> returnTop
for the second form."

| e |
((e := compiledMethod endPC) = 19 or: [e = 20]) ifFalse: [^ nil].
(compiledMethod numLiterals = 3) ifFalse:[^ nil].
(compiledMethod at: 17) = 16r70 ifFalse:[^ nil]. "push self"
(compiledMethod at: 18) = 16rD0 ifFalse:[^ nil]. "send <literal 1>"
"If we reach this point, we have a marker method that sends self <literal 1>"
^ compiledMethod literalAt: 1
@@ -0,0 +1,8 @@
prepareMethod: compiledMethod forSimulationWith: numArgs
| xpc |
xpc := compiledMethod initialPC.
"long store temp"
(compiledMethod at: xpc) = 129
ifTrue: [
compiledMethod at: xpc + 1 put: (16r40 + numArgs).
compiledMethod at: xpc + 3 put: (16r10 + numArgs)]
@@ -0,0 +1,7 @@
sendsToSuperFor: compiledMethod
"Answer whether the receiver sends any message to super."
| scanner |
scanner := InstructionStream on: compiledMethod.
^ scanner scanFor:
[:instr | instr = 16r85 or: [instr = 16r84
and: [scanner followingByte between: 16r20 and: 16r3F]]]
@@ -1,16 +1,11 @@
prepareForSimulationWith: numArgs
"This method changes the argument count of a CompiledMethod header to numArgs, its temporary count to numArgs + 1 and change the code handling primitive error to store the error code in the unique temporary of the method"

| newHeader xpc |
| newHeader |
newHeader := (((self header bitAnd: 2r01110000000000111111111111111111)
bitOr: (numArgs bitShift: 24))
bitOr: (numArgs + 1 bitShift: 18)).
newHeader := newHeader + (self class headerFlagForEncoder: self encoderClass).
self objectAt: 1 put: newHeader.

xpc := self initialPC.
"long store temp"
(self at: xpc) = 129
ifTrue: [
self at: xpc + 1 put: (16r40 + numArgs).
self at: xpc + 3 put: (16r10 + numArgs)]
self encoderClass prepareMethod: self forSimulationWith: numArgs
@@ -1,30 +1,2 @@
markerOrNil
"If I am a marker method, answer the symbol used to mark me. Otherwise
answer nil.
What is a marker method? It is method with body like
'self subclassResponsibility' or '^ self subclassResponsibility'
used to indicate ('mark') a special property.
Marker methods compile to bytecode like:
9 <70> self
10 <D0> send: <literal 1>
11 <87> pop
12 <78> returnSelf
for the first form, or
9 <70> self
10 <D0> send: <literal 1>
11 <7C> returnTop
for the second form."

| e |
((e := self endPC) = 19 or: [e = 20]) ifFalse: [^ nil].
(self numLiterals = 3) ifFalse:[^ nil].
(self at: 17) = 16r70 ifFalse:[^ nil]. "push self"
(self at: 18) = 16rD0 ifFalse:[^ nil]. "send <literal 1>"
"If we reach this point, we have a marker method that sends self <literal 1>"
^ self literalAt: 1
^ self encoderClass markerOrNilFor: self
@@ -1,7 +1,2 @@
sendsToSuper
"Answer whether the receiver sends any message to super."
| scanner |
scanner := InstructionStream on: self.
^ scanner scanFor:
[:instr | instr = 16r85 or: [instr = 16r84
and: [scanner followingByte between: 16r20 and: 16r3F]]]
^ self encoderClass sendsToSuperFor: self
4 changes: 4 additions & 0 deletions Kernel.package/Object.class/instance/halting/halt.st
@@ -0,0 +1,4 @@
halt
"This is the typical message to use for inserting breakpoints during debugging."
<debuggerCompleteToSender>
Halt now
@@ -0,0 +1,3 @@
haltIfShiftPressed
<debuggerCompleteToSender>
Halt ifShiftPressed.
3 changes: 3 additions & 0 deletions Kernel.package/Object.class/instance/halting/haltIf_.st
@@ -0,0 +1,3 @@
haltIf: condition
<debuggerCompleteToSender>
Halt if: condition.
3 changes: 3 additions & 0 deletions Kernel.package/Object.class/instance/halting/haltOnCount_.st
@@ -0,0 +1,3 @@
haltOnCount: anInteger
<debuggerCompleteToSender>
Halt onCount: anInteger.
3 changes: 3 additions & 0 deletions Kernel.package/Object.class/instance/halting/haltOnce.st
@@ -0,0 +1,3 @@
haltOnce
<debuggerCompleteToSender>
Halt once.
3 changes: 3 additions & 0 deletions Kernel.package/Object.class/instance/halting/halt_.st
@@ -0,0 +1,3 @@
halt: aString
<debuggerCompleteToSender>
Halt now: aString

This file was deleted.

@@ -0,0 +1,3 @@
severity

^ #information

This file was deleted.

This file was deleted.

@@ -0,0 +1,8 @@
checkMethod: aMethod
aMethod referencedClasses
detect: [ :class |
class methods anySatisfy: #isAbstract ]
ifFound: [ :class |
result
addMethod: aMethod;
addSearchString: class name ]
@@ -1,4 +1,3 @@
initialize
super initialize.
#('`@object clearHaltOnce' '`@object doOnlyOnce: `@object1' '`@object halt' '`@object halt: `@object1 onCount: `@object2' '`@object haltOnCount: `@object1' '`@object haltOnce' '`@object haltIf: `@object1' '`@object inspectOnCount: `@object1' '`@object inspectOnce' '`@object inspectUntilCount: `@object1' '`@object rearmOneShot' '`@object setHaltOnce' '`@object flag: `@object1' '`@object isThisEverCalled' '`@object isThisEverCalled: `@object1' '`@object logEntry' '`@object logExecution' '`@object logExit' '`@object needsWork' 'Transcript `@message: `@object1')
do: [ :matchingString | self rewriteRule replace: matchingString with: '' ]
self patterns do: [ :halt | self addRuleRemoving: halt ]
@@ -0,0 +1,11 @@
addRuleRemoving: patternString
"When you are completely removing statement(s), you can not just match the relevant node. You must match the whole method and then replace it minus the part to be removed"

| findString replaceString methodTemplate |
methodTemplate := '| `@Temps |
``@.Statements1.
{1}.
``@.Statements2'.
findString := methodTemplate format: { patternString }.
replaceString := methodTemplate format: { '' }.
self rewriteRule replace: findString with: replaceString
@@ -0,0 +1,4 @@
debuggingPatterns
| result |
result := self debuggingSelectors collect: [ :e | self patternFor: e ].
^ result, { 'Transcript `@message: `@arg' }
@@ -0,0 +1,4 @@
debuggingSelectors

^ (Object allSelectorsInProtocol: 'flagging'),
(Object allSelectorsInProtocol: 'debugging')
@@ -0,0 +1,4 @@
haltPatterns
| result |
result := self haltSelectors collect: [ :e | self patternFor: e ].
^ result, { 'Halt `@message: `@arg' }
@@ -0,0 +1,5 @@
haltSelectors
| objectConvenience miscellaneous |
objectConvenience := Object allSelectorsInProtocol: #halting.
miscellaneous := #(clearHaltOnce inspectOnce setHaltOnce).
^ objectConvenience, miscellaneous
@@ -0,0 +1,14 @@
patternForKeywordSelector: selector
| index |
^ String streamContents: [ :str |
str nextPutAll: '`@object '.
index := 1.
selector keywords
do: [ :keyword |
str
nextPutAll: keyword;
nextPutAll: ' `@arg';
print: index ]
separatedBy: [
index := index + 1.
str space ] ]
@@ -0,0 +1,4 @@
patternFor: selector
selector isUnary ifTrue: [ ^ '`@object ', selector ].
selector isBinary ifTrue: [ ^ '`@object ', selector, ' `@arg' ].
^ self patternForKeywordSelector: selector
@@ -0,0 +1,2 @@
patterns
^ self debuggingPatterns, self haltPatterns
@@ -1,2 +1,2 @@
testCodeCruftLeftInMethods
self ruleFor: self currentSelector
self ruleFor: self currentSelector plusSelectors: #(haltClassMentioned flagged transcriptMentioned debbuggingMessageSent)
@@ -1,2 +1,8 @@
codeCruftLeftInMethods
self halt
| a b c |
a := b := c := 2.
self halt.
^ a > 0
ifTrue: [ b ]
ifFalse: [ c ]

@@ -0,0 +1,2 @@
debbuggingMessageSent
self rearmOneShot
@@ -0,0 +1,2 @@
flagged
self flag: 'to do'.
@@ -0,0 +1,2 @@
haltClassMentioned
Halt now
@@ -0,0 +1,2 @@
transcriptMentioned
Transcript show: 'message'
@@ -1,4 +1,4 @@
script50052
script50053

^ 'AST-Core-TheIntegrator.294.mcz
AST-Tests-Core-TheIntegrator.68.mcz
Expand Down Expand Up @@ -30,12 +30,12 @@ Collections-Native-TheIntegrator.11.mcz
Collections-Sequenceable-TheIntegrator.200.mcz
Collections-Stack-MarcusDenker.7.mcz
Collections-Streams-TheIntegrator.172.mcz
Collections-Strings-TheIntegrator.354.mcz
Collections-Support-TheIntegrator.59.mcz
Collections-Strings-TheIntegrator.356.mcz
Collections-Support-TheIntegrator.60.mcz
Collections-Unordered-TheIntegrator.207.mcz
Collections-Weak-TheIntegrator.88.mcz
CollectionsTests-TheIntegrator.694.mcz
Compiler-TheIntegrator.591.mcz
Compiler-TheIntegrator.593.mcz
Compression-TheIntegrator.151.mcz
CompressionTests-TheIntegrator.29.mcz
ConfigurationCommandLineHandler-Core-TheIntegrator.27.mcz
Expand Down Expand Up @@ -114,7 +114,7 @@ HudsonBuildTools20-TheIntegrator.65.mcz
IssueTracking-TheIntegrator.6.mcz
IssueTracking-Tests-TheIntegrator.3.mcz
Jobs-EstebanLorenzano.4.mcz
Kernel-TheIntegrator.2028.mcz
Kernel-TheIntegrator.2030.mcz
KernelTests-TheIntegrator.774.mcz
Keymapping-Core-EstebanLorenzano.195.mcz
Keymapping-KeyCombinations-TheIntegrator.48.mcz
Expand Down Expand Up @@ -218,11 +218,11 @@ RPackage-Tests-StephaneDucasse.169.mcz
RecentSubmissions-StephaneDucasse.233.mcz
Refactoring-Changes-TheIntegrator.65.mcz
Refactoring-Core-TheIntegrator.270.mcz
Refactoring-Critics-TheIntegrator.171.mcz
Refactoring-Critics-TheIntegrator.173.mcz
Refactoring-Environment-TheIntegrator.52.mcz
Refactoring-Tests-Changes-MarcusDenker.38.mcz
Refactoring-Tests-Core-TheIntegrator.123.mcz
Refactoring-Tests-Critics-TheIntegrator.28.mcz
Refactoring-Tests-Critics-TheIntegrator.31.mcz
Refactoring-Tests-Environment-StephaneDucasse.11.mcz
Reflectivity-TheIntegrator.35.mcz
Reflectivity-Tests-TheIntegrator.26.mcz
Expand Down

0 comments on commit 2e7d6b2

Please sign in to comment.