diff --git a/Smalltalk/Block.som b/Smalltalk/Block.som index a166eedc..497eed1f 100644 --- a/Smalltalk/Block.som +++ b/Smalltalk/Block.som @@ -27,7 +27,23 @@ Block = ( "For the creation of Block instances, see Universe_new_block()." "Evaluation" - value = primitive + value = ( + ^self valueWithArguments: (Array new: 1) + ) + + value: arg = ( + ^self valueWithArguments: (Array with: arg) + ) + + value: arg1 with: arg2 = ( + ^self valueWithArguments: (Array with: arg1 with: arg2) + ) + + value: arg1 with: arg2 with: arg3 = ( + ^self valueWithArguments: (Array with: arg1 with: arg2 with: arg3) + ) + + valueWithArguments: args = primitive "Looping" whileFalse: block = ( @@ -50,6 +66,14 @@ Block = ( ifTrue: [self value] ifFalse: [self value: anArg] ) + + ensure: aBlock = ( + "Implemented for FileSystem support. It still does not comply with ensure behavior when the block fails" + | returnValue | + returnValue := self value. + aBlock value. + ^returnValue + ) " Petit Parser" asParser = (^ PPPluggableParser on: self) diff --git a/Smalltalk/Block1.som b/Smalltalk/Block1.som deleted file mode 100644 index 0290b6ce..00000000 --- a/Smalltalk/Block1.som +++ /dev/null @@ -1,39 +0,0 @@ -" - -$Id: Block1.som 27 2009-07-31 11:17:53Z michael.haupt $ - -Copyright (c) 2001-2013 see AUTHORS file - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the 'Software'), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -" - -Block1 = Block ( - - "For the creation of Block instances, see Universe_new_block()." - "Evaluating" - value = primitive - ensure: aBlock = ( - "Implemented for FileSystem support. It still does not comply with ensure behavior when the block fails" - | returnValue | - returnValue := self value. - aBlock value. - ^returnValue - ) - numArgs = (^0) -) diff --git a/Smalltalk/Block2.som b/Smalltalk/Block2.som deleted file mode 100644 index 8fcfb264..00000000 --- a/Smalltalk/Block2.som +++ /dev/null @@ -1,46 +0,0 @@ -" - -$Id: Block2.som 27 2009-07-31 11:17:53Z michael.haupt $ - -Copyright (c) 2001-2013 see AUTHORS file - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the 'Software'), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -" - -Block2 = Block ( - - "For the creation of Block instances, see Universe_new_block()." - - "Evaluating" - value = ( self value: nil ) - value: argument = primitive - - "The if encapsulates a workaround for using blocks with more than 4 arguments. They are all sent inside an array. - See PPSmalltalkParser>>methodSequence (SOM vs. Pharo)" - valueWithArguments: args = ( - ^(args length = 1) ifTrue: [ - self value: (args at: 1) - ] ifFalse: [ - self value: args - ] - ) - - numArgs = (^1) - -) diff --git a/Smalltalk/Block3.som b/Smalltalk/Block3.som deleted file mode 100644 index 7841926b..00000000 --- a/Smalltalk/Block3.som +++ /dev/null @@ -1,39 +0,0 @@ -" - -$Id: Block3.som 27 2009-07-31 11:17:53Z michael.haupt $ - -Copyright (c) 2001-2013 see AUTHORS file - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the 'Software'), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -" - -Block3 = Block ( - - "For the creation of Block instances, see Universe_new_block()." - - "Evaluating" - value = ( self value: nil with: nil ) - value: arg = ( self value: arg with: nil ) - value: arg1 with: arg2 = primitive - - "Pharo Compatibility" - value: arg1 value: arg2 = (^self value: arg1 with: arg2) - valueWithArguments: args = (^self value: (args at: 1) with: (args at: 2)) - numArgs = (^2) -) diff --git a/Smalltalk/Block4.som b/Smalltalk/Block4.som deleted file mode 100644 index b2b20fc9..00000000 --- a/Smalltalk/Block4.som +++ /dev/null @@ -1,42 +0,0 @@ -" - -$Id: Block3.som 27 2009-07-31 11:17:53Z michael.haupt $ - -Copyright (c) 2001-2013 see AUTHORS file - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the 'Software'), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -" - -Block4 = Block ( - - "For the creation of Block instances, see Universe_new_block()." - - "Evaluating" - value = ( self value: nil with: nil value: nil) - value: arg = ( self value: arg with: nil value: nil) - value: arg1 with: arg2 = ( self value: arg1 with: arg2 value: nil) - - value: arg1 with: arg2 with: arg3 = primitive - - "Pharo Compatibility" - value: arg1 value: arg2 value: arg3 = (^self value: arg1 with: arg2 with: arg3) - valueWithArguments: args = (^self value: (args at: 1) with: (args at: 2) with: (args at: 3)) - numArgs = (^3) - -) diff --git a/TestSuite/BasicInterpreterTests/Blocks.som b/TestSuite/BasicInterpreterTests/Blocks.som index d8ea900f..116f9f51 100644 --- a/TestSuite/BasicInterpreterTests/Blocks.som +++ b/TestSuite/BasicInterpreterTests/Blocks.som @@ -23,6 +23,7 @@ THE SOFTWARE. Blocks = ( ---- + argWithArguments = ( ^ [:a | a] valueWithArguments: (Array with: 1 with: 2) ) arg1 = ( ^ [:a | a - 1] value: 43 )