From ee550c513b99f6255680319c77cff02792869ba2 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 21 Nov 2016 10:52:01 +0100 Subject: [PATCH 01/63] Only build 64bit vms for now --- .travis.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b52a748..0b33a9a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,22 +21,22 @@ env: - LIBRARY_PATH=$LIBRARY_PATH:$HOME/SDL2/lib - C_INCLUDE_PATH=$C_INCLUDE_PATH:$HOME/SDL2/include matrix: - - BUILD_ARCH=32bit TEST_TYPE=default - - BUILD_ARCH=32bit - - BUILD_ARCH=32bit TEST_TYPE=coverage + # - BUILD_ARCH=32bit TEST_TYPE=default + # - BUILD_ARCH=32bit + # - BUILD_ARCH=32bit TEST_TYPE=coverage # - BUILD_ARCH=lldebug - - BUILD_ARCH=64bit TEST_TYPE=default + # - BUILD_ARCH=64bit TEST_TYPE=default - BUILD_ARCH=64bit - - BUILD_ARCH=armv6 - - BUILD_ARCH=armv7-a - - BUILD_ARCH=armv8-a - - BUILD_ARCH=64bit PLUGINS=database_plugin - - BUILD_ARCH=64bit PLUGINS=ruby_plugin + # - BUILD_ARCH=armv6 + # - BUILD_ARCH=armv7-a + # - BUILD_ARCH=armv8-a + # - BUILD_ARCH=64bit PLUGINS=database_plugin + # - BUILD_ARCH=64bit PLUGINS=ruby_plugin matrix: include: - - os: osx - osx_image: xcode7.3 - env: BUILD_ARCH=64bit TEST_TYPE=default + # - os: osx + # osx_image: xcode7.3 + # env: BUILD_ARCH=64bit TEST_TYPE=default - os: osx osx_image: xcode7.3 env: BUILD_ARCH=64bit From 75f23a5c56315f094526fac169eb9349ce38b90d Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 21 Nov 2016 10:55:12 +0100 Subject: [PATCH 02/63] Add first version of immutable objects with support for immutable pointer objects --- repository/ImmutableObjects.package/.filetree | 4 ++ .../instance/immutableNew.st | 3 ++ .../instance/newWith.and..st | 9 ++++ .../Behavior.extension/methodProperties.json | 6 +++ .../Behavior.extension/properties.json | 2 + .../ImmutableObjectPrototype.class/README.md | 0 .../class/for..st | 3 ++ .../instance/argumentList..st | 4 ++ .../instance/argumentList.st | 4 ++ .../instance/commit.st | 3 ++ .../instance/doesNotUnderstand..st | 4 ++ .../instance/initialize.st | 4 ++ .../instance/selectorList..st | 4 ++ .../instance/selectorList.st | 4 ++ .../instance/targetClass..st | 4 ++ .../instance/targetClass.st | 4 ++ .../methodProperties.json | 13 ++++++ .../properties.json | 16 +++++++ .../ImmutableObjectTest.class/README.md | 0 .../instance/testImmutabilityCollector.st | 15 +++++++ .../instance/testImmutableObject.st | 14 ++++++ .../instance/testImmutableObjectDNU.st | 5 +++ .../instance/testImmutableObjectFromLists.st | 12 ++++++ .../instance/testImmutableObjectVMSupport.st | 5 +++ .../methodProperties.json | 9 ++++ .../ImmutableObjectTest.class/properties.json | 14 ++++++ .../MyTestClass.class/README.md | 0 .../MyTestClass.class/instance/aField..st | 4 ++ .../MyTestClass.class/instance/aField.st | 4 ++ .../instance/anotherField..st | 4 ++ .../instance/anotherField.st | 4 ++ .../instance/someVar.someOtherVar..st | 4 ++ .../MyTestClass.class/instance/someVar1.st | 4 ++ .../MyTestClass.class/instance/someVar2.st | 4 ++ .../MyTestClass.class/methodProperties.json | 11 +++++ .../MyTestClass.class/properties.json | 17 ++++++++ .../Object.extension/instance/isImmutable.st | 4 ++ .../Object.extension/methodProperties.json | 5 +++ .../Object.extension/properties.json | 2 + .../monticello.meta/categories.st | 1 + .../monticello.meta/initializers.st | 0 .../monticello.meta/package | 1 + .../monticello.meta/version | 1 + .../ImmutableObjects.package/properties.json | 2 + rsqueakvm/model/base.py | 9 +++- rsqueakvm/model/pointers.py | 3 ++ rsqueakvm/plugins/immutability_plugin.py | 43 +++++++++++++++++++ rsqueakvm/storage_contexts.py | 1 + 48 files changed, 292 insertions(+), 1 deletion(-) create mode 100644 repository/ImmutableObjects.package/.filetree create mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st create mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st create mode 100644 repository/ImmutableObjects.package/Behavior.extension/methodProperties.json create mode 100644 repository/ImmutableObjects.package/Behavior.extension/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/README.md create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/aField.st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField.st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/someVar1.st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/instance/someVar2.st create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/MyTestClass.class/properties.json create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st create mode 100644 repository/ImmutableObjects.package/Object.extension/methodProperties.json create mode 100644 repository/ImmutableObjects.package/Object.extension/properties.json create mode 100644 repository/ImmutableObjects.package/monticello.meta/categories.st create mode 100644 repository/ImmutableObjects.package/monticello.meta/initializers.st create mode 100644 repository/ImmutableObjects.package/monticello.meta/package create mode 100644 repository/ImmutableObjects.package/monticello.meta/version create mode 100644 repository/ImmutableObjects.package/properties.json create mode 100644 rsqueakvm/plugins/immutability_plugin.py diff --git a/repository/ImmutableObjects.package/.filetree b/repository/ImmutableObjects.package/.filetree new file mode 100644 index 00000000..8998102c --- /dev/null +++ b/repository/ImmutableObjects.package/.filetree @@ -0,0 +1,4 @@ +{ + "noMethodMetaData" : true, + "separateMethodMetaAndSource" : false, + "useCypressPropertiesFile" : true } diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st new file mode 100644 index 00000000..3f7f5023 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st @@ -0,0 +1,3 @@ +*ImmutableObjects +immutableNew + ^ ImmutableObjectPrototype for: self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st b/repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st new file mode 100644 index 00000000..57123f88 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st @@ -0,0 +1,9 @@ +*ImmutableObjects +newWith: selectorArray and: argumentArray + + | obj | + obj := self basicNew. + selectorArray doWithIndex: [ :selector :argsIdx | | args | + args := argumentArray at: argsIdx. + obj perform: selector withArguments: args ]. + ^ obj \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json new file mode 100644 index 00000000..c90745c8 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json @@ -0,0 +1,6 @@ +{ + "class" : { + }, + "instance" : { + "immutableNew" : "fn 11/20/2016 20:12", + "newWith:and:" : "fn 11/20/2016 22:30" } } diff --git a/repository/ImmutableObjects.package/Behavior.extension/properties.json b/repository/ImmutableObjects.package/Behavior.extension/properties.json new file mode 100644 index 00000000..37061187 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "Behavior" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/README.md b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st new file mode 100644 index 00000000..07234907 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st @@ -0,0 +1,3 @@ +as yet unclassified +for: aClass + ^ self new targetClass: aClass; yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st new file mode 100644 index 00000000..5a14868b --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st @@ -0,0 +1,4 @@ +accessing +argumentList: anObject + + argumentList := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st new file mode 100644 index 00000000..c1c1cbc2 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st @@ -0,0 +1,4 @@ +accessing +argumentList + + ^ argumentList \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st new file mode 100644 index 00000000..74d6fc51 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st @@ -0,0 +1,3 @@ +private +commit + ^ self targetClass newWith: self selectorList asArray and: self argumentList asArray \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st new file mode 100644 index 00000000..71ea4523 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st @@ -0,0 +1,4 @@ +private +doesNotUnderstand: aMessage + self selectorList add: aMessage selector. + self argumentList add: aMessage arguments \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st new file mode 100644 index 00000000..2903916e --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st @@ -0,0 +1,4 @@ +initialize-release +initialize + self selectorList: OrderedCollection new. + self argumentList: OrderedCollection new \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st new file mode 100644 index 00000000..d647bc1a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st @@ -0,0 +1,4 @@ +accessing +selectorList: anObject + + selectorList := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st new file mode 100644 index 00000000..f8672e59 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st @@ -0,0 +1,4 @@ +accessing +selectorList + + ^ selectorList \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st new file mode 100644 index 00000000..94f8ab86 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st @@ -0,0 +1,4 @@ +accessing +targetClass: anObject + + targetClass := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st new file mode 100644 index 00000000..17883bef --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st @@ -0,0 +1,4 @@ +accessing +targetClass + + ^ targetClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json new file mode 100644 index 00000000..0f4c4108 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json @@ -0,0 +1,13 @@ +{ + "class" : { + "for:" : "fn 11/14/2016 18:27" }, + "instance" : { + "argumentList" : "fn 11/20/2016 20:31", + "argumentList:" : "fn 11/20/2016 20:31", + "commit" : "fn 11/20/2016 22:19", + "doesNotUnderstand:" : "fn 11/20/2016 20:32", + "initialize" : "fn 11/20/2016 20:31", + "selectorList" : "fn 11/20/2016 20:31", + "selectorList:" : "fn 11/20/2016 20:31", + "targetClass" : "fn 11/14/2016 18:26", + "targetClass:" : "fn 11/14/2016 18:26" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json new file mode 100644 index 00000000..0f1e7090 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json @@ -0,0 +1,16 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "targetClass", + "selectorList", + "argumentList" ], + "name" : "ImmutableObjectPrototype", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st new file mode 100644 index 00000000..29b9cfbd --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st @@ -0,0 +1,15 @@ +testing +testImmutabilityCollector + | obj | + obj := Object immutableNew. + self assert: Object equals: obj targetClass. + self assert: 0 equals: obj selectorList size. + + obj foo: 'x'. + self assert: 1 equals: obj selectorList size. + + obj foo: 'y'. + self assert: 2 equals: obj selectorList size. + + obj bar: 'x'. + self assert: 3 equals: obj selectorList size \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st new file mode 100644 index 00000000..730b5b05 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st @@ -0,0 +1,14 @@ +testing +testImmutableObject + | obj | + + obj := MyTestClass immutableNew + aField: 'foo'; + anotherField: #(2); + someVar: 'bar' someOtherVar: true; + commit. + + self assert: 'foo' equals: obj aField. + self assert: #(2) equals: obj anotherField. + self assert: 'bar' equals: obj someVar1. + self assert: obj someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st new file mode 100644 index 00000000..ba798dc3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st @@ -0,0 +1,5 @@ +testing +testImmutableObjectDNU + | obj | + obj := MyTestClass immutableNew unkownField: 'foo'. + self should: [ obj commit ] raise: MessageNotUnderstood \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st new file mode 100644 index 00000000..1f92778f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st @@ -0,0 +1,12 @@ +testing +testImmutableObjectFromLists + | obj | + + obj := MyTestClass + newWith: #(#aField: #anotherField: #someVar:someOtherVar:) + and: #(#('foo') #(2) #('bar' true)). + + self assert: 'foo' equals: obj aField. + self assert: 2 equals: obj anotherField. + self assert: 'bar' equals: obj someVar1. + self assert: obj someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st new file mode 100644 index 00000000..c8ebd5d8 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st @@ -0,0 +1,5 @@ +testing +testImmutableObjectVMSupport + self + assert: (Object immutableNew commit) isImmutable + description: 'Immutable objects not supported by VM' \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json new file mode 100644 index 00000000..4e18ea86 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -0,0 +1,9 @@ +{ + "class" : { + }, + "instance" : { + "testImmutabilityCollector" : "fn 11/20/2016 20:36", + "testImmutableObject" : "fn 11/21/2016 10:53", + "testImmutableObjectDNU" : "fn 11/14/2016 19:09", + "testImmutableObjectFromLists" : "fn 11/21/2016 10:53", + "testImmutableObjectVMSupport" : "fn 11/21/2016 09:51" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json new file mode 100644 index 00000000..2f9b4cb3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableObjectTest", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/MyTestClass.class/README.md b/repository/ImmutableObjects.package/MyTestClass.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st b/repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st new file mode 100644 index 00000000..1aa8db77 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st @@ -0,0 +1,4 @@ +accessing +aField: anObject + + aField := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/aField.st b/repository/ImmutableObjects.package/MyTestClass.class/instance/aField.st new file mode 100644 index 00000000..f0fbcc22 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/aField.st @@ -0,0 +1,4 @@ +accessing +aField + + ^ aField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st b/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st new file mode 100644 index 00000000..ec340273 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st @@ -0,0 +1,4 @@ +accessing +anotherField: anObject + + anotherField := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField.st b/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField.st new file mode 100644 index 00000000..543c3da7 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField.st @@ -0,0 +1,4 @@ +accessing +anotherField + + ^ anotherField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st b/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st new file mode 100644 index 00000000..631467a6 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st @@ -0,0 +1,4 @@ +accessing +someVar: aValue someOtherVar: anotherValue + someVar1 := aValue. + someVar2 := anotherValue \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar1.st b/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar1.st new file mode 100644 index 00000000..36d3922a --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar1.st @@ -0,0 +1,4 @@ +accessing +someVar1 + + ^ someVar1 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar2.st b/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar2.st new file mode 100644 index 00000000..614acfaf --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar2.st @@ -0,0 +1,4 @@ +accessing +someVar2 + + ^ someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json b/repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json new file mode 100644 index 00000000..adb12676 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json @@ -0,0 +1,11 @@ +{ + "class" : { + }, + "instance" : { + "aField" : "fn 11/14/2016 17:42", + "aField:" : "fn 11/14/2016 17:42", + "anotherField" : "fn 11/14/2016 17:42", + "anotherField:" : "fn 11/14/2016 17:42", + "someVar1" : "fn 11/14/2016 18:44", + "someVar2" : "fn 11/14/2016 18:44", + "someVar:someOtherVar:" : "fn 11/14/2016 18:46" } } diff --git a/repository/ImmutableObjects.package/MyTestClass.class/properties.json b/repository/ImmutableObjects.package/MyTestClass.class/properties.json new file mode 100644 index 00000000..43d78d96 --- /dev/null +++ b/repository/ImmutableObjects.package/MyTestClass.class/properties.json @@ -0,0 +1,17 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "aField", + "anotherField", + "someVar1", + "someVar2" ], + "name" : "MyTestClass", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st b/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st new file mode 100644 index 00000000..d4619fe0 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st @@ -0,0 +1,4 @@ +*ImmutableObjects +isImmutable + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json new file mode 100644 index 00000000..930b8eec --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + "isImmutable" : "fn 11/20/2016 21:22" } } diff --git a/repository/ImmutableObjects.package/Object.extension/properties.json b/repository/ImmutableObjects.package/Object.extension/properties.json new file mode 100644 index 00000000..3d3b9ec4 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "Object" } diff --git a/repository/ImmutableObjects.package/monticello.meta/categories.st b/repository/ImmutableObjects.package/monticello.meta/categories.st new file mode 100644 index 00000000..8d8b9e78 --- /dev/null +++ b/repository/ImmutableObjects.package/monticello.meta/categories.st @@ -0,0 +1 @@ +SystemOrganization addCategory: #ImmutableObjects! diff --git a/repository/ImmutableObjects.package/monticello.meta/initializers.st b/repository/ImmutableObjects.package/monticello.meta/initializers.st new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/monticello.meta/package b/repository/ImmutableObjects.package/monticello.meta/package new file mode 100644 index 00000000..cb0284ac --- /dev/null +++ b/repository/ImmutableObjects.package/monticello.meta/package @@ -0,0 +1 @@ +(name 'ImmutableObjects') \ No newline at end of file diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version new file mode 100644 index 00000000..17cb311a --- /dev/null +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -0,0 +1 @@ +(name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/properties.json b/repository/ImmutableObjects.package/properties.json new file mode 100644 index 00000000..f037444a --- /dev/null +++ b/repository/ImmutableObjects.package/properties.json @@ -0,0 +1,2 @@ +{ + } diff --git a/rsqueakvm/model/base.py b/rsqueakvm/model/base.py index e104ecab..862670af 100644 --- a/rsqueakvm/model/base.py +++ b/rsqueakvm/model/base.py @@ -8,10 +8,11 @@ class W_Object(object): """Root of Squeak model, abstract.""" - _attrs_ = [] # no RPython-level instance variables allowed in W_Object + _attrs_ = ['immutable'] # no RPython-level instance variables allowed in W_Object _settled_ = True repr_classname = "W_Object" bytes_per_slot = constants.BYTES_PER_WORD + immutable = False def size(self): """Return the number of "slots" or "items" in the receiver object. @@ -40,6 +41,12 @@ def bytesize(self): space, as memory representation varies depending on PyPy translation.""" return self.size() * self.bytes_per_slot + def set_immutable(self, boolean): + self.immutable = boolean + + def is_immutable(self): + return self.immutable + def getclass(self, space): """Return Squeak class.""" raise NotImplementedError() diff --git a/rsqueakvm/model/pointers.py b/rsqueakvm/model/pointers.py index b310953d..0f73a731 100644 --- a/rsqueakvm/model/pointers.py +++ b/rsqueakvm/model/pointers.py @@ -171,6 +171,9 @@ def fetch(self, space, n0): return self._get_strategy().fetch(self, n0) def store(self, space, n0, w_value): + if self.is_immutable(): + print "Immutable: %s, %s, %s" % (self, n0, w_value) + return return self._get_strategy().store(self, n0, w_value) def size(self): diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py new file mode 100644 index 00000000..0e2b254b --- /dev/null +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -0,0 +1,43 @@ +from rsqueakvm.plugins.plugin import Plugin +from rsqueakvm.error import PrimitiveFailedError +from rsqueakvm.primitives import assert_pointers + +ImmutabilityPlugin = Plugin() + + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, list, list], + clean_stack=False) +def newImmutableObject(interp, s_frame, w_cls, w_selector_list, w_args_list): + from rsqueakvm.interpreter import LocalReturn + s_frame.pop_n(2) # removing our arguments + w_cls = assert_pointers(w_cls) + s_class = w_cls.as_class_get_shadow(interp.space) + try: + new_obj = s_class.new() + except MemoryError: + raise PrimitiveFailedError + # Fill immutable object + selector_iter = iter(w_selector_list) + args_iter = iter(w_args_list) + # import pdb; pdb.set_trace() + while True: + try: + w_selector = next(selector_iter) + w_arguments = interp.space.unwrap_array(next(args_iter)) + except StopIteration: + break + try: + s_frame._sendSelector( + w_selector, len(w_arguments), interp, new_obj, + new_obj.class_shadow(interp.space), w_arguments=w_arguments) + except LocalReturn as lr: + s_frame.push(lr.value(interp.space)) + new_obj.set_immutable(True) + return new_obj + + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) +def isImmutable(interp, s_frame, w_recv): + if w_recv.is_immutable(): + return interp.space.w_true + return interp.space.w_false diff --git a/rsqueakvm/storage_contexts.py b/rsqueakvm/storage_contexts.py index d310ddb1..01e76632 100644 --- a/rsqueakvm/storage_contexts.py +++ b/rsqueakvm/storage_contexts.py @@ -586,6 +586,7 @@ def print_padded_stack(self, method): return padding + ' ', '%s\n%s%s' % (ret_str, padding, desc) def exitFromHeadlessExecution(self, selector="", w_message=None): + return # TODO(@fniephaus): disabled for immutable objects development if not objectmodel.we_are_translated(): if getattr(self.space, "testing", False): return # During Testing From b641bbdeebf72599c9ac8bcd6e75fa98327ce5fa Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 21 Nov 2016 13:30:34 +0100 Subject: [PATCH 03/63] Use interp.perform --- rsqueakvm/plugins/immutability_plugin.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 0e2b254b..54a9b572 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -5,17 +5,18 @@ ImmutabilityPlugin = Plugin() -@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, list, list], - clean_stack=False) +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, list, list]) def newImmutableObject(interp, s_frame, w_cls, w_selector_list, w_args_list): - from rsqueakvm.interpreter import LocalReturn - s_frame.pop_n(2) # removing our arguments w_cls = assert_pointers(w_cls) s_class = w_cls.as_class_get_shadow(interp.space) try: new_obj = s_class.new() except MemoryError: raise PrimitiveFailedError + return _fill(interp, new_obj, w_selector_list, w_args_list) + + +def _fill(interp, new_obj, w_selector_list, w_args_list): # Fill immutable object selector_iter = iter(w_selector_list) args_iter = iter(w_args_list) @@ -26,12 +27,7 @@ def newImmutableObject(interp, s_frame, w_cls, w_selector_list, w_args_list): w_arguments = interp.space.unwrap_array(next(args_iter)) except StopIteration: break - try: - s_frame._sendSelector( - w_selector, len(w_arguments), interp, new_obj, - new_obj.class_shadow(interp.space), w_arguments=w_arguments) - except LocalReturn as lr: - s_frame.push(lr.value(interp.space)) + interp.perform(new_obj, w_selector=w_selector, w_arguments=w_arguments) new_obj.set_immutable(True) return new_obj From a33dbd1cb1098ff723254d966ef5ffda14482dc9 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 22 Nov 2016 09:42:20 +0100 Subject: [PATCH 04/63] Disable jittest for immutable objects branch --- .travis/build-linux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/build-linux.sh b/.travis/build-linux.sh index c0142c03..34d91436 100755 --- a/.travis/build-linux.sh +++ b/.travis/build-linux.sh @@ -18,14 +18,14 @@ case "$BUILD_ARCH" in python .build/build.py --batch --32bit -- $plugins exitcode=$? cp rsqueak rsqueak-x86-${UNAME}$plugins_suffix-jit-$TRAVIS_COMMIT || true - python .build/jittests.py --32bit + # python .build/jittests.py --32bit $EX rm -rf .build/pypy/rpython/_cache ;; 64bit) python .build/build.py --batch --64bit -- $plugins exitcode=$? cp rsqueak rsqueak-x86_64-${UNAME}$plugins_suffix-jit-$TRAVIS_COMMIT || true - python .build/jittests.py --64bit + # python .build/jittests.py --64bit $EX rm -rf .build/pypy/rpython/_cache ;; lldebug) From 4da0be6ee71d5bc395af86803cf442efd0109d48 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 00:59:35 +0100 Subject: [PATCH 05/63] Revert changes to base.py except is_immutable() --- rsqueakvm/model/base.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rsqueakvm/model/base.py b/rsqueakvm/model/base.py index 1f658b5c..1c6de717 100644 --- a/rsqueakvm/model/base.py +++ b/rsqueakvm/model/base.py @@ -8,11 +8,10 @@ class W_Object(object): """Root of Squeak model, abstract.""" - _attrs_ = ['immutable'] # no RPython-level instance variables allowed in W_Object + _attrs_ = [] # no RPython-level instance variables allowed in W_Object _settled_ = True repr_classname = "W_Object" bytes_per_slot = constants.BYTES_PER_WORD - immutable = False def size(self): """Return the number of "slots" or "items" in the receiver object. @@ -41,11 +40,8 @@ def bytesize(self): space, as memory representation varies depending on PyPy translation.""" return self.size() * self.bytes_per_slot - def set_immutable(self, boolean): - self.immutable = boolean - def is_immutable(self): - return self.immutable + return False def getclass(self, space): """Return Squeak class.""" From 1b799f906ef6259cf7477835e70c78228700f1ba Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 01:02:39 +0100 Subject: [PATCH 06/63] Implement immutability via immutableCopy --- rsqueakvm/model/pointers.py | 9 +++-- rsqueakvm/plugins/immutability_plugin.py | 49 ++++++++++++------------ rsqueakvm/util/model.py | 22 +++++++++++ 3 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 rsqueakvm/util/model.py diff --git a/rsqueakvm/model/pointers.py b/rsqueakvm/model/pointers.py index 7d04300c..cfc7cfb7 100644 --- a/rsqueakvm/model/pointers.py +++ b/rsqueakvm/model/pointers.py @@ -1,11 +1,13 @@ from rsqueakvm import constants, error from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash from rsqueakvm.model.numeric import W_SmallInteger +from rsqueakvm.util.model import has_immutable_subclass, no_immutable_access from rpython.rlib import objectmodel, jit from rpython.rlib.rstrategies import rstrategies as rstrat +@has_immutable_subclass class W_PointersObject(W_AbstractObjectWithIdentityHash): """Common object.""" _attrs_ = ['strategy', '_storage'] @@ -162,6 +164,7 @@ def at0(self, space, index0): # To test, at0 = in varsize part return self.fetch(space, index0 + self.instsize()) + @no_immutable_access def atput0(self, space, index0, w_value): # To test, at0 = in varsize part self.store(space, index0 + self.instsize(), w_value) @@ -169,10 +172,8 @@ def atput0(self, space, index0, w_value): def fetch(self, space, n0): return self._get_strategy().fetch(self, n0) + @no_immutable_access def store(self, space, n0, w_value): - if self.is_immutable(): - print "Immutable: %s, %s, %s" % (self, n0, w_value) - return return self._get_strategy().store(self, n0, w_value) def size(self): @@ -226,6 +227,7 @@ def has_space(self): # The space is accessed through the strategy. return self.has_strategy() + @no_immutable_access def _become(self, w_other): assert isinstance(w_other, W_PointersObject) # Make sure our class shadow is initialized, we will need it @@ -244,6 +246,7 @@ def _become(self, w_other): self._storage, w_other._storage = w_other._storage, self._storage W_AbstractObjectWithIdentityHash._become(self, w_other) + @no_immutable_access def pointers_become_one_way(self, space, from_w, to_w): ptrs = self.fetch_all(space) ptridx = 0 diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 54a9b572..dc3f808c 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -1,35 +1,36 @@ +from rsqueakvm.model import * from rsqueakvm.plugins.plugin import Plugin from rsqueakvm.error import PrimitiveFailedError -from rsqueakvm.primitives import assert_pointers ImmutabilityPlugin = Plugin() -@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, list, list]) -def newImmutableObject(interp, s_frame, w_cls, w_selector_list, w_args_list): - w_cls = assert_pointers(w_cls) - s_class = w_cls.as_class_get_shadow(interp.space) +def _patch_w_object(): + from rsqueakvm.model.base import W_Object + + def freeze(self): + pass + W_Object.freeze = freeze + +_patch_w_object() + + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) +def immutableCopy(interp, s_frame, w_recv): try: - new_obj = s_class.new() - except MemoryError: + immutable_class = w_recv.__class__.immutable_class + except AttributeError: raise PrimitiveFailedError - return _fill(interp, new_obj, w_selector_list, w_args_list) - - -def _fill(interp, new_obj, w_selector_list, w_args_list): - # Fill immutable object - selector_iter = iter(w_selector_list) - args_iter = iter(w_args_list) - # import pdb; pdb.set_trace() - while True: - try: - w_selector = next(selector_iter) - w_arguments = interp.space.unwrap_array(next(args_iter)) - except StopIteration: - break - interp.perform(new_obj, w_selector=w_selector, w_arguments=w_arguments) - new_obj.set_immutable(True) - return new_obj + + if isinstance(w_recv, W_PointersObject): + pointers = w_recv.fetch_all(interp.space) + w_result = immutable_class(interp.space, w_recv.getclass(interp.space), + len(pointers)) + w_result.store_all(interp.space, pointers) + w_result.freeze() + return w_result + + raise PrimitiveFailedError @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) diff --git a/rsqueakvm/util/model.py b/rsqueakvm/util/model.py new file mode 100644 index 00000000..1b67cf2a --- /dev/null +++ b/rsqueakvm/util/model.py @@ -0,0 +1,22 @@ +def has_immutable_subclass(cls): + class ImmutableSubclass(cls): + _attrs_ = ['_frozen'] + _frozen = False + + def freeze(self): + self._frozen = True + + def is_immutable(self): + return self._frozen + + ImmutableSubclass.__name__ = '%s_Immutable' % cls.__name__ + + cls.immutable_class = ImmutableSubclass + return cls + + +def no_immutable_access(fn): + def decorator(self, *args): + if not self.is_immutable(): + fn(self, *args) + return decorator From 6c5591ecc41779b8f22c33205203dc615325932b Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 01:02:54 +0100 Subject: [PATCH 07/63] Use new immutableCopy primitive --- .../Behavior.extension/instance/immutableNew.st | 3 --- .../Behavior.extension/instance/newWith.and..st | 9 --------- .../Behavior.extension/methodProperties.json | 6 ------ .../Behavior.extension/properties.json | 2 -- .../ImmutableObjectPrototype.class/README.md | 0 .../ImmutableObjectPrototype.class/class/for..st | 3 --- .../instance/argumentList..st | 4 ---- .../instance/argumentList.st | 4 ---- .../instance/commit.st | 3 --- .../instance/doesNotUnderstand..st | 4 ---- .../instance/initialize.st | 4 ---- .../instance/selectorList..st | 4 ---- .../instance/selectorList.st | 4 ---- .../instance/targetClass..st | 4 ---- .../instance/targetClass.st | 4 ---- .../methodProperties.json | 13 ------------- .../properties.json | 16 ---------------- .../instance/testImmutabilityCollector.st | 15 --------------- .../instance/testImmutableObject.st | 4 ++-- .../instance/testImmutableObjectDNU.st | 5 ----- .../instance/testImmutableObjectFromLists.st | 12 ------------ .../instance/testImmutableObjectVMSupport.st | 2 +- .../methodProperties.json | 7 ++----- .../Object.extension/instance/immutableCopy.st | 4 ++++ .../Object.extension/methodProperties.json | 1 + .../monticello.meta/version | 2 +- 26 files changed, 11 insertions(+), 128 deletions(-) delete mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st delete mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st delete mode 100644 repository/ImmutableObjects.package/Behavior.extension/methodProperties.json delete mode 100644 repository/ImmutableObjects.package/Behavior.extension/properties.json delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/README.md delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st delete mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st deleted file mode 100644 index 3f7f5023..00000000 --- a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableNew.st +++ /dev/null @@ -1,3 +0,0 @@ -*ImmutableObjects -immutableNew - ^ ImmutableObjectPrototype for: self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st b/repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st deleted file mode 100644 index 57123f88..00000000 --- a/repository/ImmutableObjects.package/Behavior.extension/instance/newWith.and..st +++ /dev/null @@ -1,9 +0,0 @@ -*ImmutableObjects -newWith: selectorArray and: argumentArray - - | obj | - obj := self basicNew. - selectorArray doWithIndex: [ :selector :argsIdx | | args | - args := argumentArray at: argsIdx. - obj perform: selector withArguments: args ]. - ^ obj \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json deleted file mode 100644 index c90745c8..00000000 --- a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "class" : { - }, - "instance" : { - "immutableNew" : "fn 11/20/2016 20:12", - "newWith:and:" : "fn 11/20/2016 22:30" } } diff --git a/repository/ImmutableObjects.package/Behavior.extension/properties.json b/repository/ImmutableObjects.package/Behavior.extension/properties.json deleted file mode 100644 index 37061187..00000000 --- a/repository/ImmutableObjects.package/Behavior.extension/properties.json +++ /dev/null @@ -1,2 +0,0 @@ -{ - "name" : "Behavior" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/README.md b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/README.md deleted file mode 100644 index e69de29b..00000000 diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st deleted file mode 100644 index 07234907..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/class/for..st +++ /dev/null @@ -1,3 +0,0 @@ -as yet unclassified -for: aClass - ^ self new targetClass: aClass; yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st deleted file mode 100644 index 5a14868b..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList..st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -argumentList: anObject - - argumentList := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st deleted file mode 100644 index c1c1cbc2..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/argumentList.st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -argumentList - - ^ argumentList \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st deleted file mode 100644 index 74d6fc51..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/commit.st +++ /dev/null @@ -1,3 +0,0 @@ -private -commit - ^ self targetClass newWith: self selectorList asArray and: self argumentList asArray \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st deleted file mode 100644 index 71ea4523..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/doesNotUnderstand..st +++ /dev/null @@ -1,4 +0,0 @@ -private -doesNotUnderstand: aMessage - self selectorList add: aMessage selector. - self argumentList add: aMessage arguments \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st deleted file mode 100644 index 2903916e..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/initialize.st +++ /dev/null @@ -1,4 +0,0 @@ -initialize-release -initialize - self selectorList: OrderedCollection new. - self argumentList: OrderedCollection new \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st deleted file mode 100644 index d647bc1a..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList..st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -selectorList: anObject - - selectorList := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st deleted file mode 100644 index f8672e59..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/selectorList.st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -selectorList - - ^ selectorList \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st deleted file mode 100644 index 94f8ab86..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass..st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -targetClass: anObject - - targetClass := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st deleted file mode 100644 index 17883bef..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/instance/targetClass.st +++ /dev/null @@ -1,4 +0,0 @@ -accessing -targetClass - - ^ targetClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json deleted file mode 100644 index 0f4c4108..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/methodProperties.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "class" : { - "for:" : "fn 11/14/2016 18:27" }, - "instance" : { - "argumentList" : "fn 11/20/2016 20:31", - "argumentList:" : "fn 11/20/2016 20:31", - "commit" : "fn 11/20/2016 22:19", - "doesNotUnderstand:" : "fn 11/20/2016 20:32", - "initialize" : "fn 11/20/2016 20:31", - "selectorList" : "fn 11/20/2016 20:31", - "selectorList:" : "fn 11/20/2016 20:31", - "targetClass" : "fn 11/14/2016 18:26", - "targetClass:" : "fn 11/14/2016 18:26" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json deleted file mode 100644 index 0f1e7090..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectPrototype.class/properties.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "category" : "ImmutableObjects", - "classinstvars" : [ - ], - "classvars" : [ - ], - "commentStamp" : "", - "instvars" : [ - "targetClass", - "selectorList", - "argumentList" ], - "name" : "ImmutableObjectPrototype", - "pools" : [ - ], - "super" : "Object", - "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st deleted file mode 100644 index 29b9cfbd..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutabilityCollector.st +++ /dev/null @@ -1,15 +0,0 @@ -testing -testImmutabilityCollector - | obj | - obj := Object immutableNew. - self assert: Object equals: obj targetClass. - self assert: 0 equals: obj selectorList size. - - obj foo: 'x'. - self assert: 1 equals: obj selectorList size. - - obj foo: 'y'. - self assert: 2 equals: obj selectorList size. - - obj bar: 'x'. - self assert: 3 equals: obj selectorList size \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st index 730b5b05..1a4b2187 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st @@ -2,11 +2,11 @@ testing testImmutableObject | obj | - obj := MyTestClass immutableNew + obj := MyTestClass new aField: 'foo'; anotherField: #(2); someVar: 'bar' someOtherVar: true; - commit. + immutableCopy. self assert: 'foo' equals: obj aField. self assert: #(2) equals: obj anotherField. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st deleted file mode 100644 index ba798dc3..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectDNU.st +++ /dev/null @@ -1,5 +0,0 @@ -testing -testImmutableObjectDNU - | obj | - obj := MyTestClass immutableNew unkownField: 'foo'. - self should: [ obj commit ] raise: MessageNotUnderstood \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st deleted file mode 100644 index 1f92778f..00000000 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectFromLists.st +++ /dev/null @@ -1,12 +0,0 @@ -testing -testImmutableObjectFromLists - | obj | - - obj := MyTestClass - newWith: #(#aField: #anotherField: #someVar:someOtherVar:) - and: #(#('foo') #(2) #('bar' true)). - - self assert: 'foo' equals: obj aField. - self assert: 2 equals: obj anotherField. - self assert: 'bar' equals: obj someVar1. - self assert: obj someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st index c8ebd5d8..6ba45516 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st @@ -1,5 +1,5 @@ testing testImmutableObjectVMSupport self - assert: (Object immutableNew commit) isImmutable + assert: (Object new immutableCopy) isImmutable description: 'Immutable objects not supported by VM' \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json index 4e18ea86..b896c043 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -2,8 +2,5 @@ "class" : { }, "instance" : { - "testImmutabilityCollector" : "fn 11/20/2016 20:36", - "testImmutableObject" : "fn 11/21/2016 10:53", - "testImmutableObjectDNU" : "fn 11/14/2016 19:09", - "testImmutableObjectFromLists" : "fn 11/21/2016 10:53", - "testImmutableObjectVMSupport" : "fn 11/21/2016 09:51" } } + "testImmutableObject" : "fn 11/28/2016 00:55", + "testImmutableObjectVMSupport" : "fn 11/28/2016 00:56" } } diff --git a/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st new file mode 100644 index 00000000..2903fda3 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st @@ -0,0 +1,4 @@ +*ImmutableObjects +immutableCopy + + self primitiveFail \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json index 930b8eec..f203997f 100644 --- a/repository/ImmutableObjects.package/Object.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -2,4 +2,5 @@ "class" : { }, "instance" : { + "immutableCopy" : "fn 11/27/2016 23:34", "isImmutable" : "fn 11/20/2016 21:22" } } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 17cb311a..7d5a0857 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 59f28db34d3ccea66cb4b8e4e0c8d0e9336c95b7 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 01:47:07 +0100 Subject: [PATCH 08/63] Add Behavior>>allImmutableInstances --- .../Behavior.extension/instance/allImmutableInstances.st | 3 +++ .../Behavior.extension/methodProperties.json | 5 +++++ .../Behavior.extension/properties.json | 2 ++ repository/ImmutableObjects.package/monticello.meta/version | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st create mode 100644 repository/ImmutableObjects.package/Behavior.extension/methodProperties.json create mode 100644 repository/ImmutableObjects.package/Behavior.extension/properties.json diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st b/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st new file mode 100644 index 00000000..844d423d --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st @@ -0,0 +1,3 @@ +*ImmutableObjects +allImmutableInstances + ^ self allInstances select: [ :ea | ea isImmutable ] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json new file mode 100644 index 00000000..e298d47a --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + "allImmutableInstances" : "fn 11/28/2016 01:45" } } diff --git a/repository/ImmutableObjects.package/Behavior.extension/properties.json b/repository/ImmutableObjects.package/Behavior.extension/properties.json new file mode 100644 index 00000000..37061187 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "Behavior" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 7d5a0857..b3225104 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 1f4559171c60e126616c2b1d65862359d0f6b396 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 01:53:32 +0100 Subject: [PATCH 09/63] Remove TODO [ci skip] --- rsqueakvm/storage_contexts.py | 1 - 1 file changed, 1 deletion(-) diff --git a/rsqueakvm/storage_contexts.py b/rsqueakvm/storage_contexts.py index 93bb8eb0..06fdd2fb 100644 --- a/rsqueakvm/storage_contexts.py +++ b/rsqueakvm/storage_contexts.py @@ -585,7 +585,6 @@ def print_padded_stack(self, method): return padding + ' ', '%s\n%s%s' % (ret_str, padding, desc) def exitFromHeadlessExecution(self, selector="", w_message=None): - return # TODO(@fniephaus): disabled for immutable objects development if not objectmodel.we_are_translated(): if getattr(self.space, "testing", False): return # During Testing From f070ff7724d86979eb6a4bac0c0fe9cfbd6b587f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 11:47:23 +0100 Subject: [PATCH 10/63] Implementation for Object>>asImmutable: Also move entire immutable object implementation into ImmutabilityPlugin --- .../Object.extension/instance/asImmutable..st | 5 ++ .../instance/immutableCopy.st | 3 +- .../Object.extension/methodProperties.json | 3 +- .../monticello.meta/version | 2 +- rsqueakvm/model/base.py | 3 -- rsqueakvm/model/pointers.py | 6 --- rsqueakvm/plugins/immutability_plugin.py | 49 ++++++++++++++++--- rsqueakvm/util/model.py | 22 --------- 8 files changed, 52 insertions(+), 41 deletions(-) create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st delete mode 100644 rsqueakvm/util/model.py diff --git a/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st new file mode 100644 index 00000000..810721b6 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st @@ -0,0 +1,5 @@ +*ImmutableObjects +asImmutable: aClass + + self primitiveFail + \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st index 2903fda3..79ea4fd0 100644 --- a/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st +++ b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st @@ -1,4 +1,3 @@ *ImmutableObjects immutableCopy - - self primitiveFail \ No newline at end of file + ^ self asImmutable: self class \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json index f203997f..261b1443 100644 --- a/repository/ImmutableObjects.package/Object.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -2,5 +2,6 @@ "class" : { }, "instance" : { - "immutableCopy" : "fn 11/27/2016 23:34", + "asImmutable:" : "fn 11/28/2016 10:28", + "immutableCopy" : "fn 11/28/2016 11:17", "isImmutable" : "fn 11/20/2016 21:22" } } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index b3225104..8fa5a131 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/rsqueakvm/model/base.py b/rsqueakvm/model/base.py index 9b44ddd2..1a41bdaa 100644 --- a/rsqueakvm/model/base.py +++ b/rsqueakvm/model/base.py @@ -40,9 +40,6 @@ def bytesize(self): space, as memory representation varies depending on PyPy translation.""" return self.size() * self.bytes_per_slot - def is_immutable(self): - return False - def getclass(self, space): """Return Squeak class.""" raise NotImplementedError() diff --git a/rsqueakvm/model/pointers.py b/rsqueakvm/model/pointers.py index d45b20fe..4d8b0638 100644 --- a/rsqueakvm/model/pointers.py +++ b/rsqueakvm/model/pointers.py @@ -1,13 +1,11 @@ from rsqueakvm import constants, error from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash from rsqueakvm.model.numeric import W_SmallInteger -from rsqueakvm.util.model import has_immutable_subclass, no_immutable_access from rpython.rlib import objectmodel, jit from rpython.rlib.rstrategies import rstrategies as rstrat -@has_immutable_subclass class W_PointersObject(W_AbstractObjectWithIdentityHash): """Common object.""" _attrs_ = ['strategy', '_storage'] @@ -164,7 +162,6 @@ def at0(self, space, index0): # To test, at0 = in varsize part return self.fetch(space, index0 + self.instsize()) - @no_immutable_access def atput0(self, space, index0, w_value): # To test, at0 = in varsize part self.store(space, index0 + self.instsize(), w_value) @@ -172,7 +169,6 @@ def atput0(self, space, index0, w_value): def fetch(self, space, n0): return self._get_strategy().fetch(self, n0) - @no_immutable_access def store(self, space, n0, w_value): return self._get_strategy().store(self, n0, w_value) @@ -227,7 +223,6 @@ def has_space(self): # The space is accessed through the strategy. return self.has_strategy() - @no_immutable_access def _become(self, w_other): if not isinstance(w_other, W_PointersObject): raise error.PrimitiveFailedError @@ -247,7 +242,6 @@ def _become(self, w_other): self._storage, w_other._storage = w_other._storage, self._storage W_AbstractObjectWithIdentityHash._become(self, w_other) - @no_immutable_access def pointers_become_one_way(self, space, from_w, to_w): ptrs = self.fetch_all(space) ptridx = 0 diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index dc3f808c..ed8281ec 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -5,18 +5,55 @@ ImmutabilityPlugin = Plugin() -def _patch_w_object(): +def _add_immutable_subclass(cls, blacklist): + class ImmutableSubclass(cls): + _attrs_ = ['_frozen'] + _frozen = False + + def freeze(self): + self._frozen = True + + def is_immutable(self): + return self._frozen + + # Decorate blacklisted methods with immutability check + def restrict_access(fn): + def decorator(self, *args): + if not self.is_immutable(): + fn(self, *args) + return decorator + for method_name in blacklist: + method = getattr(ImmutableSubclass, method_name) + if hasattr(ImmutableSubclass, method_name): + setattr(ImmutableSubclass, method_name, restrict_access(method)) + + ImmutableSubclass.__name__ = '%s_Immutable' % cls.__name__ + ImmutableSubclass.repr_classname = '%s_Immutable' % cls.repr_classname + + cls.immutable_class = ImmutableSubclass + + +def _patch_w_objects(): from rsqueakvm.model.base import W_Object + from rsqueakvm.model.pointers import W_PointersObject + + def is_immutable(self): + return False + W_Object.is_immutable = is_immutable def freeze(self): pass W_Object.freeze = freeze -_patch_w_object() + _add_immutable_subclass(W_PointersObject, + ['atput0', 'store', 'store_all', '_become']) +_patch_w_objects() -@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) -def immutableCopy(interp, s_frame, w_recv): + +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) +def asImmutable(interp, s_frame, w_recv, w_cls): + # import pdb; pdb.set_trace() try: immutable_class = w_recv.__class__.immutable_class except AttributeError: @@ -24,8 +61,7 @@ def immutableCopy(interp, s_frame, w_recv): if isinstance(w_recv, W_PointersObject): pointers = w_recv.fetch_all(interp.space) - w_result = immutable_class(interp.space, w_recv.getclass(interp.space), - len(pointers)) + w_result = immutable_class(interp.space, w_cls, len(pointers)) w_result.store_all(interp.space, pointers) w_result.freeze() return w_result @@ -35,6 +71,7 @@ def immutableCopy(interp, s_frame, w_recv): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) def isImmutable(interp, s_frame, w_recv): + # import pdb; pdb.set_trace() if w_recv.is_immutable(): return interp.space.w_true return interp.space.w_false diff --git a/rsqueakvm/util/model.py b/rsqueakvm/util/model.py deleted file mode 100644 index 1b67cf2a..00000000 --- a/rsqueakvm/util/model.py +++ /dev/null @@ -1,22 +0,0 @@ -def has_immutable_subclass(cls): - class ImmutableSubclass(cls): - _attrs_ = ['_frozen'] - _frozen = False - - def freeze(self): - self._frozen = True - - def is_immutable(self): - return self._frozen - - ImmutableSubclass.__name__ = '%s_Immutable' % cls.__name__ - - cls.immutable_class = ImmutableSubclass - return cls - - -def no_immutable_access(fn): - def decorator(self, *args): - if not self.is_immutable(): - fn(self, *args) - return decorator From 8e58100cb1a694ef054538c60d98dd5c7e8b2033 Mon Sep 17 00:00:00 2001 From: jchromik Date: Mon, 28 Nov 2016 13:21:23 +0100 Subject: [PATCH 11/63] introduce Behavior>>immutableFrom: --- .../instance/immutableFrom..st | 4 +++ .../Behavior.extension/methodProperties.json | 3 +- .../instance/testAsImmutable.st | 13 ++++++++ ...mmutableObject.st => testImmutableCopy.st} | 2 +- .../instance/testImmutableFrom.st | 14 +++++++++ .../methodProperties.json | 4 ++- .../Object.extension/instance/asImmutable..st | 3 +- .../Object.extension/methodProperties.json | 2 +- .../monticello.meta/version | 2 +- rsqueakvm/plugins/immutability_plugin.py | 30 +++++++++---------- rsqueakvm/util/shell.py | 3 +- 11 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st rename repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/{testImmutableObject.st => testImmutableCopy.st} (93%) create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st new file mode 100644 index 00000000..2d87ec5a --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st @@ -0,0 +1,4 @@ +*ImmutableObjects +immutableFrom: anObject + + self primitiveFailed \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json index e298d47a..fbdb623d 100644 --- a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json @@ -2,4 +2,5 @@ "class" : { }, "instance" : { - "allImmutableInstances" : "fn 11/28/2016 01:45" } } + "allImmutableInstances" : "fn 11/28/2016 01:45", + "immutableFrom:" : "jc 11/28/2016 12:40" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st new file mode 100644 index 00000000..1effa5b1 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st @@ -0,0 +1,13 @@ +testing +testAsImmutable + | obj | + + obj := (MyTestClass new + aField: 'foo'; + anotherField: #(2); + someVar: 'bar' someOtherVar: true) asImmutable: MyTestClass. + + self assert: 'foo' equals: obj aField. + self assert: #(2) equals: obj anotherField. + self assert: 'bar' equals: obj someVar1. + self assert: obj someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st similarity index 93% rename from repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st rename to repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st index 1a4b2187..7b7460d0 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObject.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st @@ -1,5 +1,5 @@ testing -testImmutableObject +testImmutableCopy | obj | obj := MyTestClass new diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st new file mode 100644 index 00000000..939e3781 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st @@ -0,0 +1,14 @@ +testing +testImmutableFrom + | obj | + + obj := MyTestClass immutableFrom: ( + MyTestClass new + aField: 'foo'; + anotherField: #(2); + someVar: 'bar' someOtherVar: true). + + self assert: 'foo' equals: obj aField. + self assert: #(2) equals: obj anotherField. + self assert: 'bar' equals: obj someVar1. + self assert: obj someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json index b896c043..16f56c8d 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -2,5 +2,7 @@ "class" : { }, "instance" : { - "testImmutableObject" : "fn 11/28/2016 00:55", + "testAsImmutable" : "jc 11/28/2016 12:55", + "testImmutableCopy" : "jc 11/28/2016 12:53", + "testImmutableFrom" : "jc 11/28/2016 12:54", "testImmutableObjectVMSupport" : "fn 11/28/2016 00:56" } } diff --git a/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st index 810721b6..f11f8365 100644 --- a/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st +++ b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st @@ -1,5 +1,4 @@ *ImmutableObjects asImmutable: aClass - - self primitiveFail + ^ aClass immutableFrom: self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json index 261b1443..762dd36e 100644 --- a/repository/ImmutableObjects.package/Object.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -2,6 +2,6 @@ "class" : { }, "instance" : { - "asImmutable:" : "fn 11/28/2016 10:28", + "asImmutable:" : "jc 11/28/2016 12:51", "immutableCopy" : "fn 11/28/2016 11:17", "isImmutable" : "fn 11/20/2016 21:22" } } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 8fa5a131..7ea452fc 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index ed8281ec..59aec4b7 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -7,14 +7,18 @@ def _add_immutable_subclass(cls, blacklist): class ImmutableSubclass(cls): - _attrs_ = ['_frozen'] - _frozen = False + _attrs_ = ['_immutable_storage'] + _immutable_fields_ = ['_immutable_storage[*]'] - def freeze(self): - self._frozen = True + def __init__(self, space, w_cls, pointers): + cls.__init__(self, space, w_cls, len(pointers)) + self._immutable_storage = pointers + + def fetch(self, space, n0): + return self._immutable_storage[n0]; def is_immutable(self): - return self._frozen + return True # Decorate blacklisted methods with immutability check def restrict_access(fn): @@ -41,10 +45,6 @@ def is_immutable(self): return False W_Object.is_immutable = is_immutable - def freeze(self): - pass - W_Object.freeze = freeze - _add_immutable_subclass(W_PointersObject, ['atput0', 'store', 'store_all', '_become']) @@ -52,18 +52,16 @@ def freeze(self): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) -def asImmutable(interp, s_frame, w_recv, w_cls): +def immutableFrom(interp, s_frame, w_cls, w_obj): # import pdb; pdb.set_trace() try: - immutable_class = w_recv.__class__.immutable_class + immutable_subclass = w_cls.__class__.immutable_class except AttributeError: raise PrimitiveFailedError - if isinstance(w_recv, W_PointersObject): - pointers = w_recv.fetch_all(interp.space) - w_result = immutable_class(interp.space, w_cls, len(pointers)) - w_result.store_all(interp.space, pointers) - w_result.freeze() + if isinstance(w_cls, W_PointersObject): + pointers = w_obj.fetch_all(interp.space) + w_result = immutable_subclass(interp.space, w_cls, pointers) return w_result raise PrimitiveFailedError diff --git a/rsqueakvm/util/shell.py b/rsqueakvm/util/shell.py index ea0d9b74..60d80568 100644 --- a/rsqueakvm/util/shell.py +++ b/rsqueakvm/util/shell.py @@ -227,7 +227,8 @@ def run(self): try: w_result = self._execute_code(code) except: - print "Error: ", sys.exc_info()[0] + error = sys.exc_info() + print "Error: ", error[0] import pdb; pdb.set_trace() if w_result: print w_result.as_repr_string().replace('\r', '\n') From 818c9b78d91d497aae1a17cae657756125e480a1 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 13:51:29 +0100 Subject: [PATCH 12/63] Improve error handling in shell mode --- rsqueakvm/util/shell.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rsqueakvm/util/shell.py b/rsqueakvm/util/shell.py index 60d80568..99ad1a72 100644 --- a/rsqueakvm/util/shell.py +++ b/rsqueakvm/util/shell.py @@ -227,9 +227,15 @@ def run(self): try: w_result = self._execute_code(code) except: - error = sys.exc_info() - print "Error: ", error[0] - import pdb; pdb.set_trace() + if hasattr(sys, 'ps1') or not sys.stderr.isatty(): + # we are in interactive mode or we don't have a tty-like + # device, so we call the default hook + sys.__excepthook__(type, value, tb) + else: + import pdb, traceback + _type, value, tb = sys.exc_info() + traceback.print_exception(_type, value, tb) + pdb.post_mortem(tb) if w_result: print w_result.as_repr_string().replace('\r', '\n') From 1a846a485313af7c244f5198513f6dd80e8e337f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 14:09:44 +0100 Subject: [PATCH 13/63] =?UTF-8?q?Don=E2=80=99t=20init=20strategy=20and=20r?= =?UTF-8?q?emember=20w=5Fclass/instsize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rsqueakvm/plugins/immutability_plugin.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 59aec4b7..652b555c 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -7,15 +7,26 @@ def _add_immutable_subclass(cls, blacklist): class ImmutableSubclass(cls): - _attrs_ = ['_immutable_storage'] - _immutable_fields_ = ['_immutable_storage[*]'] + _attrs_ = ['_immutable_storage', 'w_class', '_instsize'] + _immutable_fields_ = ['_immutable_storage[*]', '_instsize'] def __init__(self, space, w_cls, pointers): - cls.__init__(self, space, w_cls, len(pointers)) + W_AbstractObjectWithIdentityHash.__init__(self) + self.w_class = w_cls self._immutable_storage = pointers + self._instsize = self.w_class.as_class_get_shadow(space).instsize() + + def getclass(self, space): + return self.w_class + + def size(self): + return len(self._immutable_storage) - self.instsize() + + def instsize(self): + return self._instsize def fetch(self, space, n0): - return self._immutable_storage[n0]; + return self._immutable_storage[n0] def is_immutable(self): return True From 39437702c4d97e1145713df162659ae02530ea9d Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Mon, 28 Nov 2016 15:43:56 +0100 Subject: [PATCH 14/63] [consistency] naming, coding style, and idioms --- .../instance/allImmutableInstances.st | 3 ++- .../instance/immutableFrom..st | 4 ++-- .../instance/primImmutableFrom..st | 5 +++++ .../Behavior.extension/methodProperties.json | 5 +++-- .../README.md | 0 .../instance/aField..st | 2 +- .../instance/aField.st | 0 .../instance/anotherField..st | 2 +- .../instance/anotherField.st | 0 .../instance/someVar.someOtherVar..st | 3 ++- .../instance/someVar1.st | 0 .../instance/someVar2.st | 0 .../methodProperties.json | 6 +++--- .../properties.json | 2 +- .../instance/testAsImmutable.st | 17 +++++++++-------- .../instance/testImmutableCopy.st | 14 +++++++------- .../instance/testImmutableFrom.st | 16 ++++++++-------- .../instance/testImmutableObjectVMSupport.st | 1 + .../methodProperties.json | 8 ++++---- .../Object.extension/instance/asImmutable..st | 4 ++-- .../Object.extension/instance/immutableCopy.st | 1 + .../Object.extension/instance/isImmutable.st | 4 ++-- .../instance/primIsImmutable.st | 5 +++++ .../Object.extension/methodProperties.json | 7 ++++--- .../monticello.meta/version | 2 +- rsqueakvm/plugins/immutability_plugin.py | 18 ++++++++---------- 26 files changed, 72 insertions(+), 57 deletions(-) create mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/README.md (100%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/aField..st (58%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/aField.st (100%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/anotherField..st (56%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/anotherField.st (100%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/someVar.someOtherVar..st (73%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/someVar1.st (100%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/instance/someVar2.st (100%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/methodProperties.json (57%) rename repository/ImmutableObjects.package/{MyTestClass.class => ImmJustFixedPointersClass.class}/properties.json (86%) create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st b/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st index 844d423d..07fe9f41 100644 --- a/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/allImmutableInstances.st @@ -1,3 +1,4 @@ *ImmutableObjects allImmutableInstances - ^ self allInstances select: [ :ea | ea isImmutable ] \ No newline at end of file + + ^ self allInstances select: [:ea | ea isImmutable] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st index 2d87ec5a..96859b12 100644 --- a/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/immutableFrom..st @@ -1,4 +1,4 @@ *ImmutableObjects immutableFrom: anObject - - self primitiveFailed \ No newline at end of file + + ^ self primImmutableFrom: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st new file mode 100644 index 00000000..4df5f230 --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFrom..st @@ -0,0 +1,5 @@ +*ImmutableObjects +primImmutableFrom: anObject + + + self primitiveFailed \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json index fbdb623d..feec8284 100644 --- a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json @@ -2,5 +2,6 @@ "class" : { }, "instance" : { - "allImmutableInstances" : "fn 11/28/2016 01:45", - "immutableFrom:" : "jc 11/28/2016 12:40" } } + "allImmutableInstances" : "topa 11/28/2016 15:23", + "immutableFrom:" : "topa 11/28/2016 15:23", + "primImmutableFrom:" : "topa 11/28/2016 15:23" } } diff --git a/repository/ImmutableObjects.package/MyTestClass.class/README.md b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/README.md similarity index 100% rename from repository/ImmutableObjects.package/MyTestClass.class/README.md rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/README.md diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField..st similarity index 58% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField..st index 1aa8db77..3c1514ba 100644 --- a/repository/ImmutableObjects.package/MyTestClass.class/instance/aField..st +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField..st @@ -1,4 +1,4 @@ accessing aField: anObject - aField := anObject \ No newline at end of file + aField := anObject. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/aField.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField.st similarity index 100% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/aField.st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/aField.st diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField..st similarity index 56% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField..st index ec340273..bc823466 100644 --- a/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField..st +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField..st @@ -1,4 +1,4 @@ accessing anotherField: anObject - anotherField := anObject \ No newline at end of file + anotherField := anObject. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField.st similarity index 100% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/anotherField.st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/anotherField.st diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar.someOtherVar..st similarity index 73% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar.someOtherVar..st index 631467a6..3519c0c9 100644 --- a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar.someOtherVar..st +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar.someOtherVar..st @@ -1,4 +1,5 @@ accessing someVar: aValue someOtherVar: anotherValue + someVar1 := aValue. - someVar2 := anotherValue \ No newline at end of file + someVar2 := anotherValue. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar1.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar1.st similarity index 100% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/someVar1.st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar1.st diff --git a/repository/ImmutableObjects.package/MyTestClass.class/instance/someVar2.st b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar2.st similarity index 100% rename from repository/ImmutableObjects.package/MyTestClass.class/instance/someVar2.st rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/instance/someVar2.st diff --git a/repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/methodProperties.json similarity index 57% rename from repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/methodProperties.json index adb12676..1afd06ee 100644 --- a/repository/ImmutableObjects.package/MyTestClass.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/methodProperties.json @@ -3,9 +3,9 @@ }, "instance" : { "aField" : "fn 11/14/2016 17:42", - "aField:" : "fn 11/14/2016 17:42", + "aField:" : "topa 11/28/2016 15:31", "anotherField" : "fn 11/14/2016 17:42", - "anotherField:" : "fn 11/14/2016 17:42", + "anotherField:" : "topa 11/28/2016 15:31", "someVar1" : "fn 11/14/2016 18:44", "someVar2" : "fn 11/14/2016 18:44", - "someVar:someOtherVar:" : "fn 11/14/2016 18:46" } } + "someVar:someOtherVar:" : "topa 11/28/2016 15:31" } } diff --git a/repository/ImmutableObjects.package/MyTestClass.class/properties.json b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json similarity index 86% rename from repository/ImmutableObjects.package/MyTestClass.class/properties.json rename to repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json index 43d78d96..3a3dce9e 100644 --- a/repository/ImmutableObjects.package/MyTestClass.class/properties.json +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json @@ -10,7 +10,7 @@ "anotherField", "someVar1", "someVar2" ], - "name" : "MyTestClass", + "name" : "ImmJustFixedPointersClass", "pools" : [ ], "super" : "Object", diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st index 1effa5b1..2ab7aea0 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st @@ -1,13 +1,14 @@ testing testAsImmutable - | obj | - - obj := (MyTestClass new + + | objectUnderTest | + objectUnderTest := (ImmJustFixedPointersClass new aField: 'foo'; anotherField: #(2); - someVar: 'bar' someOtherVar: true) asImmutable: MyTestClass. + someVar: 'bar' someOtherVar: true) + asImmutable: ImmJustFixedPointersClass. - self assert: 'foo' equals: obj aField. - self assert: #(2) equals: obj anotherField. - self assert: 'bar' equals: obj someVar1. - self assert: obj someVar2 \ No newline at end of file + self assert: 'foo' equals: objectUnderTest aField. + self assert: #(2) equals: objectUnderTest anotherField. + self assert: 'bar' equals: objectUnderTest someVar1. + self assert: true equals: objectUnderTest someVar2. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st index 7b7460d0..00a37318 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st @@ -1,14 +1,14 @@ testing testImmutableCopy - | obj | - - obj := MyTestClass new + + | objectUnderTest | + objectUnderTest := ImmJustFixedPointersClass new aField: 'foo'; anotherField: #(2); someVar: 'bar' someOtherVar: true; immutableCopy. - self assert: 'foo' equals: obj aField. - self assert: #(2) equals: obj anotherField. - self assert: 'bar' equals: obj someVar1. - self assert: obj someVar2 \ No newline at end of file + self assert: 'foo' equals: objectUnderTest aField. + self assert: #(2) equals: objectUnderTest anotherField. + self assert: 'bar' equals: objectUnderTest someVar1. + self assert: true equals: objectUnderTest someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st index 939e3781..2c855739 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st @@ -1,14 +1,14 @@ testing testImmutableFrom - | obj | - - obj := MyTestClass immutableFrom: ( - MyTestClass new + + | objectUnderTest | + objectUnderTest := ImmJustFixedPointersClass immutableFrom: ( + ImmJustFixedPointersClass new aField: 'foo'; anotherField: #(2); someVar: 'bar' someOtherVar: true). - self assert: 'foo' equals: obj aField. - self assert: #(2) equals: obj anotherField. - self assert: 'bar' equals: obj someVar1. - self assert: obj someVar2 \ No newline at end of file + self assert: 'foo' equals: objectUnderTest aField. + self assert: #(2) equals: objectUnderTest anotherField. + self assert: 'bar' equals: objectUnderTest someVar1. + self assert: true equals: objectUnderTest someVar2 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st index 6ba45516..65cec62c 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st @@ -1,5 +1,6 @@ testing testImmutableObjectVMSupport + self assert: (Object new immutableCopy) isImmutable description: 'Immutable objects not supported by VM' \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json index 16f56c8d..e3830484 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -2,7 +2,7 @@ "class" : { }, "instance" : { - "testAsImmutable" : "jc 11/28/2016 12:55", - "testImmutableCopy" : "jc 11/28/2016 12:53", - "testImmutableFrom" : "jc 11/28/2016 12:54", - "testImmutableObjectVMSupport" : "fn 11/28/2016 00:56" } } + "testAsImmutable" : "topa 11/28/2016 15:31", + "testImmutableCopy" : "topa 11/28/2016 15:30", + "testImmutableFrom" : "topa 11/28/2016 15:30", + "testImmutableObjectVMSupport" : "topa 11/28/2016 15:30" } } diff --git a/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st index f11f8365..447670de 100644 --- a/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st +++ b/repository/ImmutableObjects.package/Object.extension/instance/asImmutable..st @@ -1,4 +1,4 @@ *ImmutableObjects asImmutable: aClass - ^ aClass immutableFrom: self - \ No newline at end of file + + ^ aClass immutableFrom: self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st index 79ea4fd0..24ae3d76 100644 --- a/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st +++ b/repository/ImmutableObjects.package/Object.extension/instance/immutableCopy.st @@ -1,3 +1,4 @@ *ImmutableObjects immutableCopy + ^ self asImmutable: self class \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st b/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st index d4619fe0..79557939 100644 --- a/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st +++ b/repository/ImmutableObjects.package/Object.extension/instance/isImmutable.st @@ -1,4 +1,4 @@ *ImmutableObjects isImmutable - - ^ false \ No newline at end of file + + ^ self primIsImmutable \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st b/repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st new file mode 100644 index 00000000..65009fd8 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/primIsImmutable.st @@ -0,0 +1,5 @@ +*ImmutableObjects +primIsImmutable + + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json index 762dd36e..8d13bc71 100644 --- a/repository/ImmutableObjects.package/Object.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -2,6 +2,7 @@ "class" : { }, "instance" : { - "asImmutable:" : "jc 11/28/2016 12:51", - "immutableCopy" : "fn 11/28/2016 11:17", - "isImmutable" : "fn 11/20/2016 21:22" } } + "asImmutable:" : "topa 11/28/2016 15:23", + "immutableCopy" : "topa 11/28/2016 15:24", + "isImmutable" : "topa 11/28/2016 15:23", + "primIsImmutable" : "topa 11/28/2016 15:23" } } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 7ea452fc..afdaeb81 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 652b555c..1666d89f 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -7,26 +7,26 @@ def _add_immutable_subclass(cls, blacklist): class ImmutableSubclass(cls): - _attrs_ = ['_immutable_storage', 'w_class', '_instsize'] - _immutable_fields_ = ['_immutable_storage[*]', '_instsize'] + _attrs_ = ['storage', 'w_class', '_instsize'] + _immutable_fields_ = ['storage[*]', '_instsize'] - def __init__(self, space, w_cls, pointers): + def __init__(self, space, w_cls, pointers_w): W_AbstractObjectWithIdentityHash.__init__(self) self.w_class = w_cls - self._immutable_storage = pointers + self.storage = pointers_w self._instsize = self.w_class.as_class_get_shadow(space).instsize() def getclass(self, space): return self.w_class def size(self): - return len(self._immutable_storage) - self.instsize() + return len(self.storage) - self.instsize() def instsize(self): return self._instsize def fetch(self, space, n0): - return self._immutable_storage[n0] + return self.storage[n0] def is_immutable(self): return True @@ -63,8 +63,7 @@ def is_immutable(self): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) -def immutableFrom(interp, s_frame, w_cls, w_obj): - # import pdb; pdb.set_trace() +def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): try: immutable_subclass = w_cls.__class__.immutable_class except AttributeError: @@ -79,8 +78,7 @@ def immutableFrom(interp, s_frame, w_cls, w_obj): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) -def isImmutable(interp, s_frame, w_recv): - # import pdb; pdb.set_trace() +def primitiveIsImmutable(interp, s_frame, w_recv): if w_recv.is_immutable(): return interp.space.w_true return interp.space.w_false From 8eeba327ddb5dcced1f9cac4b470cd595efdc092 Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Mon, 28 Nov 2016 16:22:34 +0100 Subject: [PATCH 15/63] Extend tests a little --- .../ImmJustVariablePointersClass.class/README.md | 0 .../methodProperties.json | 5 +++++ .../properties.json | 14 ++++++++++++++ .../ImmVMTest.class/README.md | 0 .../instance/testImmutableObjectVMSupport.st | 0 .../ImmVMTest.class/methodProperties.json | 5 +++++ .../ImmVMTest.class/properties.json | 14 ++++++++++++++ .../ImmutabilityTestCase.class/README.md | 0 .../class/allTestSelectors.st | 7 +++++++ .../class/immutabilityAvailable.st | 4 ++++ .../ImmutabilityTestCase.class/class/isAbstract.st | 4 ++++ .../class/primSomeImmutablePrimitive.st | 6 ++++++ .../class/testSelectors.st | 7 +++++++ .../methodProperties.json | 9 +++++++++ .../ImmutabilityTestCase.class/properties.json | 14 ++++++++++++++ .../ImmutableFixedObjectTest.class/README.md | 0 .../instance/assertPropertiesOf..st | 7 +++++++ .../instance/classUnderTest.st | 4 ++++ .../instance/objectUnderTest.st | 7 +++++++ .../methodProperties.json | 7 +++++++ .../ImmutableFixedObjectTest.class/properties.json | 14 ++++++++++++++ .../ImmutableObjectTest.class/class/isAbstract.st | 4 ++++ .../instance/assertPropertiesOf..st | 4 ++++ .../instance/classUnderTest.st | 4 ++++ .../instance/objectUnderTest.st | 4 ++++ .../instance/testAsImmutable.st | 12 ++---------- .../instance/testImmutableCopy.st | 14 +++----------- .../instance/testImmutableFrom.st | 12 ++---------- .../methodProperties.json | 12 +++++++----- .../ImmutableObjectTest.class/properties.json | 2 +- .../ImmutableVariableObjectTest.class/README.md | 0 .../instance/assertPropertiesOf..st | 7 +++++++ .../instance/classUnderTest.st | 4 ++++ .../instance/objectUnderTest.st | 7 +++++++ .../methodProperties.json | 7 +++++++ .../properties.json | 14 ++++++++++++++ .../monticello.meta/version | 2 +- 37 files changed, 199 insertions(+), 38 deletions(-) create mode 100644 repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmVMTest.class/README.md rename repository/ImmutableObjects.package/{ImmutableObjectTest.class => ImmVMTest.class}/instance/testImmutableObjectVMSupport.st (100%) create mode 100644 repository/ImmutableObjects.package/ImmVMTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmVMTest.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st create mode 100644 repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/README.md b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json new file mode 100644 index 00000000..0e4a6622 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + } } diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json new file mode 100644 index 00000000..126cc137 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmJustVariablePointersClass", + "pools" : [ + ], + "super" : "Object", + "type" : "variable" } diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/README.md b/repository/ImmutableObjects.package/ImmVMTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st b/repository/ImmutableObjects.package/ImmVMTest.class/instance/testImmutableObjectVMSupport.st similarity index 100% rename from repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableObjectVMSupport.st rename to repository/ImmutableObjects.package/ImmVMTest.class/instance/testImmutableObjectVMSupport.st diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmVMTest.class/methodProperties.json new file mode 100644 index 00000000..45c3f0ab --- /dev/null +++ b/repository/ImmutableObjects.package/ImmVMTest.class/methodProperties.json @@ -0,0 +1,5 @@ +{ + "class" : { + }, + "instance" : { + "testImmutableObjectVMSupport" : "topa 11/28/2016 16:20" } } diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/properties.json b/repository/ImmutableObjects.package/ImmVMTest.class/properties.json new file mode 100644 index 00000000..8ce19f44 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmVMTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmVMTest", + "pools" : [ + ], + "super" : "ImmutabilityTestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/README.md b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st new file mode 100644 index 00000000..737934e3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/allTestSelectors.st @@ -0,0 +1,7 @@ +accessing +allTestSelectors + " Ensure those tests are not run on a 'normal' VM " + + ^ self immutabilityAvailable + ifFalse: [#()] + ifTrue: [super allTestSelectors] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st new file mode 100644 index 00000000..4737f967 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/immutabilityAvailable.st @@ -0,0 +1,4 @@ +primimitive support +immutabilityAvailable + + ^ self primSomeImmutablePrimitive notNil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st new file mode 100644 index 00000000..18e11899 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/isAbstract.st @@ -0,0 +1,4 @@ +testing +isAbstract + + ^ self name == #ImmutabilityTestCase \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st new file mode 100644 index 00000000..e86f8583 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/primSomeImmutablePrimitive.st @@ -0,0 +1,6 @@ +primimitive support +primSomeImmutablePrimitive + " returns nil on failure on purpose " + + + ^ nil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st new file mode 100644 index 00000000..6253e2bf --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/class/testSelectors.st @@ -0,0 +1,7 @@ +accessing +testSelectors + " Ensure those tests are not run on a 'normal' VM " + + ^ self immutabilityAvailable + ifFalse: [#()] + ifTrue: [super testSelectors] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json new file mode 100644 index 00000000..2cfbc5f6 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/methodProperties.json @@ -0,0 +1,9 @@ +{ + "class" : { + "allTestSelectors" : "topa 11/28/2016 16:04", + "immutabilityAvailable" : "topa 11/28/2016 16:02", + "isAbstract" : "topa 11/28/2016 16:05", + "primSomeImmutablePrimitive" : "topa 11/28/2016 16:02", + "testSelectors" : "topa 11/28/2016 16:03" }, + "instance" : { + } } diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json new file mode 100644 index 00000000..3d61168a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutabilityTestCase", + "pools" : [ + ], + "super" : "TestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..c47e2fb3 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,7 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: 'foo' equals: anImmutableObject aField. + self assert: #(2) equals: anImmutableObject anotherField. + self assert: 'bar' equals: anImmutableObject someVar1. + self assert: true equals: anImmutableObject someVar2. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..74182401 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ImmJustFixedPointersClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..4429f167 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,7 @@ +test objects +objectUnderTest + + ^ self classUnderTest new + aField: 'foo'; + anotherField: #(2); + someVar: 'bar' someOtherVar: true \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json new file mode 100644 index 00000000..8c39e5d1 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "topa 11/28/2016 16:13", + "classUnderTest" : "topa 11/28/2016 16:11", + "objectUnderTest" : "topa 11/28/2016 16:12" } } diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json new file mode 100644 index 00000000..d6fdf8f2 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableFixedObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st new file mode 100644 index 00000000..6b49fe5f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/class/isAbstract.st @@ -0,0 +1,4 @@ +testing +isAbstract + + ^ self name == #ImmutableObjectTest \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..b581b5fd --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,4 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: false. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..124fd29e --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ self subclassResponsibility \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..186e2952 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,4 @@ +test objects +objectUnderTest + + ^ self subclassResponsibility \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st index 2ab7aea0..f5ad8fef 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st @@ -2,13 +2,5 @@ testing testAsImmutable | objectUnderTest | - objectUnderTest := (ImmJustFixedPointersClass new - aField: 'foo'; - anotherField: #(2); - someVar: 'bar' someOtherVar: true) - asImmutable: ImmJustFixedPointersClass. - - self assert: 'foo' equals: objectUnderTest aField. - self assert: #(2) equals: objectUnderTest anotherField. - self assert: 'bar' equals: objectUnderTest someVar1. - self assert: true equals: objectUnderTest someVar2. + objectUnderTest := self objectUnderTest asImmutable: self classUnderTest. + self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st index 00a37318..ee622a63 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableCopy.st @@ -1,14 +1,6 @@ testing testImmutableCopy - | objectUnderTest | - objectUnderTest := ImmJustFixedPointersClass new - aField: 'foo'; - anotherField: #(2); - someVar: 'bar' someOtherVar: true; - immutableCopy. - - self assert: 'foo' equals: objectUnderTest aField. - self assert: #(2) equals: objectUnderTest anotherField. - self assert: 'bar' equals: objectUnderTest someVar1. - self assert: true equals: objectUnderTest someVar2 \ No newline at end of file + | objectUnderTest | + objectUnderTest := self objectUnderTest immutableCopy. + self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st index 2c855739..8463188f 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testImmutableFrom.st @@ -2,13 +2,5 @@ testing testImmutableFrom | objectUnderTest | - objectUnderTest := ImmJustFixedPointersClass immutableFrom: ( - ImmJustFixedPointersClass new - aField: 'foo'; - anotherField: #(2); - someVar: 'bar' someOtherVar: true). - - self assert: 'foo' equals: objectUnderTest aField. - self assert: #(2) equals: objectUnderTest anotherField. - self assert: 'bar' equals: objectUnderTest someVar1. - self assert: true equals: objectUnderTest someVar2 \ No newline at end of file + objectUnderTest := self classUnderTest immutableFrom: self objectUnderTest. + self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json index e3830484..699247a8 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -1,8 +1,10 @@ { "class" : { - }, + "isAbstract" : "topa 11/28/2016 16:18" }, "instance" : { - "testAsImmutable" : "topa 11/28/2016 15:31", - "testImmutableCopy" : "topa 11/28/2016 15:30", - "testImmutableFrom" : "topa 11/28/2016 15:30", - "testImmutableObjectVMSupport" : "topa 11/28/2016 15:30" } } + "assertPropertiesOf:" : "topa 11/28/2016 16:12", + "classUnderTest" : "topa 11/28/2016 16:12", + "objectUnderTest" : "topa 11/28/2016 16:12", + "testAsImmutable" : "topa 11/28/2016 16:09", + "testImmutableCopy" : "topa 11/28/2016 16:09", + "testImmutableFrom" : "topa 11/28/2016 16:10" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json index 2f9b4cb3..119ad0a4 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json @@ -10,5 +10,5 @@ "name" : "ImmutableObjectTest", "pools" : [ ], - "super" : "TestCase", + "super" : "ImmutabilityTestCase", "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..1fdf4b20 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,7 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: 'foo' equals: anImmutableObject first. + self assert: #(2) equals: anImmutableObject second. + self assert: true equals: anImmutableObject third. + self assert: nil equals: anImmutableObject last. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..39b90c01 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ImmJustVariablePointersClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..c206562a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,7 @@ +test objects +objectUnderTest + + ^ (self classUnderTest new: 4) + at: 1 put: 'foo'; + at: 2 put: #(2); + at: 3 put: true \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json new file mode 100644 index 00000000..9b28c1e4 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "topa 11/28/2016 16:17", + "classUnderTest" : "topa 11/28/2016 16:16", + "objectUnderTest" : "topa 11/28/2016 16:17" } } diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json new file mode 100644 index 00000000..17d2794a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableVariableObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index afdaeb81..6f075d7f 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From a28a980eb46ff718bf272a5cd5001bf790e0721e Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Mon, 28 Nov 2016 16:29:43 +0100 Subject: [PATCH 16/63] test immutable object creation from not-same-class objects --- .../ImmutableForeignObjectTest.class/README.md | 0 .../instance/testForeignFixedAsImmutable.st | 9 +++++++++ .../instance/testForeignVariableAsImmutable.st | 11 +++++++++++ .../methodProperties.json | 6 ++++++ .../properties.json | 14 ++++++++++++++ .../monticello.meta/version | 2 +- 6 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st create mode 100644 repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st create mode 100644 repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st new file mode 100644 index 00000000..21951469 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st @@ -0,0 +1,9 @@ +as yet unclassified +testForeignFixedAsImmutable + + | objectUnderTest | + objectUnderTest := #( 'foo' (2) 'bar' true ) asImmutable: ImmJustFixedPointersClass. + self assert: 'foo' equals: objectUnderTest aField. + self assert: #(2) equals: objectUnderTest anotherField. + self assert: 'bar' equals: objectUnderTest someVar1. + self assert: true equals: objectUnderTest someVar2. diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st new file mode 100644 index 00000000..38bcbac1 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st @@ -0,0 +1,11 @@ +as yet unclassified +testForeignVariableAsImmutable + + | objectUnderTest | + objectUnderTest := #( 'foo' (2) 'bar' nil ) asImmutable: ImmJustVariablePointersClass. + self assert: 4 equals: objectUnderTest size. + self assert: 'foo' equals: objectUnderTest first. + self assert: #(2) equals: objectUnderTest second. + self assert: 'bar' equals: objectUnderTest third. + self assert: true equals: objectUnderTest last. + diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json new file mode 100644 index 00000000..3060ef4d --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json @@ -0,0 +1,6 @@ +{ + "class" : { + }, + "instance" : { + "testForeignFixedAsImmutable" : "topa 11/28/2016 16:27", + "testForeignVariableAsImmutable" : "topa 11/28/2016 16:28" } } diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json new file mode 100644 index 00000000..ed7cdca8 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableForeignObjectTest", + "pools" : [ + ], + "super" : "ImmutabilityTestCase", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 6f075d7f..83194641 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 5e7c8b197ab7e213c969629be890c23f05b48920 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 20:42:30 +0100 Subject: [PATCH 17/63] Add support for immutable byte and word objects --- rsqueakvm/model/variable.py | 35 ++++--- rsqueakvm/plugins/immutability_plugin.py | 114 ++++++++++++++++------- 2 files changed, 102 insertions(+), 47 deletions(-) diff --git a/rsqueakvm/model/variable.py b/rsqueakvm/model/variable.py index 4a248b40..02b9b44e 100644 --- a/rsqueakvm/model/variable.py +++ b/rsqueakvm/model/variable.py @@ -38,7 +38,7 @@ def atput0(self, space, index0, w_value): raise error.PrimitiveFailedError def getchar(self, n0): - return self.bytes[n0] + return self._bytes()[n0] def setchar(self, n0, character): assert isinstance(character, str) @@ -66,7 +66,13 @@ def short_atput0(self, space, index0, w_value): self.setchar(byte_index0 + 1, chr(byte1)) def size(self): - return len(self.bytes) + return len(self._bytes()) + + def _bytes(self): + return self.bytes + + def _version(self): + return self.version def str_content(self): if self.getclass(None).has_space(): @@ -77,14 +83,14 @@ def str_content(self): (self.unwrap_string(None).replace('\r', '\n'))]) def unwrap_string(self, space): - return self._pure_as_string(self.version) + return self._pure_as_string(self._version()) @jit.elidable def _pure_as_string(self, version): - return "".join(self.bytes) + return "".join(self._bytes()) def getbytes(self): - return self.bytes + return self._bytes() @jit.dont_look_inside def setbytes(self, lst): @@ -142,7 +148,7 @@ def unwrap_long_untranslated(self, space): @elidable_for_version_iff(0, cond=lambda self: jit.isconstant(self)) def getrbigint(self): from rpython.rlib.rbigint import rbigint - return rbigint.frombytes(self.getbytes(), 'little', False) + return rbigint.frombytes(self._bytes(), 'little', False) def selector_string(self): return "#" + self.unwrap_string(None) @@ -150,7 +156,7 @@ def selector_string(self): def invariant(self): if not W_AbstractObjectWithClassReference.invariant(self): return False - for c in self.bytes: + for c in self._bytes(): if not isinstance(c, str) or len(c) != 1: return False return True @@ -158,7 +164,7 @@ def invariant(self): def clone(self, space): size = self.size() w_result = W_BytesObject(space, self.getclass(space), size) - w_result.bytes = list(self.bytes) + w_result.bytes = list(self._bytes()) return w_result def is_array_object(self): @@ -196,7 +202,7 @@ def atput0(self, space, index0, w_value): def getword(self, n): assert self.size() > n >= 0 - return self.words[n] + return self._words()[n] def setword(self, n, word): self.words[n] = r_uint(word) @@ -246,13 +252,16 @@ def setwords(self, lst): self.words = lst def size(self): - return len(self.words) + return len(self._words()) + + def _words(self): + return self.words @jit.look_inside_iff(lambda self, space: jit.isconstant(self.size())) def unwrap_string(self, space): # OH GOD! TODO: Make this sane! res = [] - for word in self.words: + for word in self._words(): res += [chr((word & r_uint(0x000000ff)) >> 0), chr((word & r_uint(0x0000ff00)) >> 8), chr((word & r_uint(0x00ff0000)) >> 16), @@ -261,12 +270,12 @@ def unwrap_string(self, space): def invariant(self): return (W_AbstractObjectWithClassReference.invariant(self) and - isinstance(self.words, list)) + isinstance(self._words(), list)) def clone(self, space): size = self.size() w_result = W_WordsObject(space, self.getclass(space), size) - w_result.words = list(self.words) + w_result.words = list(self._words()) return w_result def is_array_object(self): diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 1666d89f..0bbee7ac 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -1,14 +1,42 @@ +from rsqueakvm.error import PrimitiveFailedError from rsqueakvm.model import * from rsqueakvm.plugins.plugin import Plugin -from rsqueakvm.error import PrimitiveFailedError +from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS +from rsqueakvm.util.version import Version ImmutabilityPlugin = Plugin() +WRITE_OPERATIONS_W_OBJECT = [ + # W_Object + 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', + 'fillin_weak', 'fillin_finalize', + # W_PointersObject + 'pointers_become_one_way', + # W_BytesObject / W_WordsObject + 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', + 'setbytes', 'mutate' +] + + +def immutable_class(cls): + def is_immutable(self): + return True + cls.is_immutable = is_immutable + + for method_name in WRITE_OPERATIONS_W_OBJECT: + if hasattr(cls, method_name): + def noop(self, *args): + pass + setattr(cls, method_name, noop) + return cls -def _add_immutable_subclass(cls, blacklist): - class ImmutableSubclass(cls): + +def _add_immutable_w_pointersobject_subclass(): + @immutable_class + class W_PointersObject_Immutable(W_PointersObject): _attrs_ = ['storage', 'w_class', '_instsize'] _immutable_fields_ = ['storage[*]', '_instsize'] + repr_classname = '%s_Immutable' % W_PointersObject.repr_classname def __init__(self, space, w_cls, pointers_w): W_AbstractObjectWithIdentityHash.__init__(self) @@ -28,51 +56,69 @@ def instsize(self): def fetch(self, space, n0): return self.storage[n0] - def is_immutable(self): - return True + W_PointersObject.immutable_subclass = W_PointersObject_Immutable + - # Decorate blacklisted methods with immutability check - def restrict_access(fn): - def decorator(self, *args): - if not self.is_immutable(): - fn(self, *args) - return decorator - for method_name in blacklist: - method = getattr(ImmutableSubclass, method_name) - if hasattr(ImmutableSubclass, method_name): - setattr(ImmutableSubclass, method_name, restrict_access(method)) +def _add_immutable_w_bytesobject_subclass(): + @immutable_class + class W_BytesObject_Immutable(W_BytesObject): + _attrs_ = ['storage'] + _immutable_fields_ = ['storage'] + repr_classname = '%s_Immutable' % W_BytesObject.repr_classname - ImmutableSubclass.__name__ = '%s_Immutable' % cls.__name__ - ImmutableSubclass.repr_classname = '%s_Immutable' % cls.repr_classname + def __init__(self, space, w_cls, bytes_w): + W_AbstractObjectWithClassReference.__init__(self, space, w_cls) + self.storage = bytes_w - cls.immutable_class = ImmutableSubclass + def _bytes(self): + return self.storage + def _version(self): + return None -def _patch_w_objects(): - from rsqueakvm.model.base import W_Object - from rsqueakvm.model.pointers import W_PointersObject + W_BytesObject.immutable_subclass = W_BytesObject_Immutable + +def _add_immutable_w_wordsobject_subclass(): + @immutable_class + class W_WordsObject_Immutable(W_WordsObject): + _attrs_ = ['storage'] + _immutable_fields_ = ['storage'] + repr_classname = '%s_Immutable' % W_WordsObject.repr_classname + + def __init__(self, space, w_cls, words_w): + W_AbstractObjectWithClassReference.__init__(self, space, w_cls) + self.storage = words_w + + def _words(self): + return self.storage + + W_WordsObject.immutable_subclass = W_WordsObject_Immutable + + +def _patch_w_object(): def is_immutable(self): return False W_Object.is_immutable = is_immutable - _add_immutable_subclass(W_PointersObject, - ['atput0', 'store', 'store_all', '_become']) - -_patch_w_objects() +_patch_w_object() +_add_immutable_w_pointersobject_subclass() +_add_immutable_w_bytesobject_subclass() +_add_immutable_w_wordsobject_subclass() @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): - try: - immutable_subclass = w_cls.__class__.immutable_class - except AttributeError: - raise PrimitiveFailedError - - if isinstance(w_cls, W_PointersObject): - pointers = w_obj.fetch_all(interp.space) - w_result = immutable_subclass(interp.space, w_cls, pointers) - return w_result + space = interp.space + instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() + + if instance_kind == POINTERS: + pointers = w_obj.fetch_all(space) + return W_PointersObject.immutable_subclass(space, w_cls, pointers) + elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): + return W_BytesObject.immutable_subclass(space, w_cls, w_obj.bytes) + elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): + return W_WordsObject.immutable_subclass(space, w_cls, w_obj.words) raise PrimitiveFailedError From 6d2174cba4fe6f70055f225d5f5de26eb587dad7 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 20:43:05 +0100 Subject: [PATCH 18/63] Add tests [ci skip] +ImmutableBytesObjectTest +ImmutableWordsObjectTest Also fix existing tests --- .../README.md | 0 .../instance/assertPropertiesOf..st | 5 +++++ .../instance/attemptToModify..st | 4 ++++ .../instance/classUnderTest.st | 4 ++++ .../instance/objectUnderTest.st | 4 ++++ .../methodProperties.json | 8 ++++++++ .../ImmutableBytesObjectTest.class/properties.json | 14 ++++++++++++++ .../instance/objectUnderTest.st | 3 ++- .../methodProperties.json | 2 +- .../instance/testForeignFixedAsImmutable.st | 2 +- .../instance/testForeignVariableAsImmutable.st | 12 ++++++------ .../methodProperties.json | 2 +- .../instance/attemptToModify..st | 4 ++++ .../instance/testAsImmutable.st | 1 + .../methodProperties.json | 3 ++- .../ImmutableObjectsVMTest.class/README.md | 0 .../instance/testImmutableObjectVMSupport.st | 0 .../methodProperties.json | 0 .../properties.json | 2 +- .../instance/assertPropertiesOf..st | 8 ++++---- .../instance/objectUnderTest.st | 3 ++- .../methodProperties.json | 4 ++-- .../ImmutableWordsObjectTest.class/README.md | 0 .../instance/assertPropertiesOf..st | 5 +++++ .../instance/classUnderTest.st | 4 ++++ .../instance/objectUnderTest.st | 4 ++++ .../methodProperties.json | 7 +++++++ .../ImmutableWordsObjectTest.class/properties.json | 14 ++++++++++++++ .../monticello.meta/version | 2 +- 29 files changed, 101 insertions(+), 20 deletions(-) rename repository/ImmutableObjects.package/{ImmVMTest.class => ImmutableBytesObjectTest.class}/README.md (100%) create mode 100644 repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st create mode 100644 repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st create mode 100644 repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st create mode 100644 repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/README.md rename repository/ImmutableObjects.package/{ImmVMTest.class => ImmutableObjectsVMTest.class}/instance/testImmutableObjectVMSupport.st (100%) rename repository/ImmutableObjects.package/{ImmVMTest.class => ImmutableObjectsVMTest.class}/methodProperties.json (100%) rename repository/ImmutableObjects.package/{ImmVMTest.class => ImmutableObjectsVMTest.class}/properties.json (85%) create mode 100644 repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st create mode 100644 repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/README.md b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/README.md similarity index 100% rename from repository/ImmutableObjects.package/ImmVMTest.class/README.md rename to repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/README.md diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..e3e2e899 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,5 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: $T equals: anImmutableObject first. + self assert: 'This is a test string!' equals: anImmutableObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st new file mode 100644 index 00000000..41431772 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/attemptToModify..st @@ -0,0 +1,4 @@ +test objects +attemptToModify: anImmutableObject + + anImmutableObject at: 1 put: $x diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..80eddf2e --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ ByteString \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..ec49838a --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,4 @@ +test objects +objectUnderTest + + ^ 'This is a test string!' \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json new file mode 100644 index 00000000..04dd467f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/methodProperties.json @@ -0,0 +1,8 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:36", + "attemptToModify:" : "fn 11/28/2016 20:38", + "classUnderTest" : "fn 11/28/2016 20:35", + "objectUnderTest" : "fn 11/28/2016 20:35" } } diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json new file mode 100644 index 00000000..b61cc3e4 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableBytesObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st index 4429f167..51eb84aa 100644 --- a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/objectUnderTest.st @@ -4,4 +4,5 @@ objectUnderTest ^ self classUnderTest new aField: 'foo'; anotherField: #(2); - someVar: 'bar' someOtherVar: true \ No newline at end of file + someVar: 'bar' someOtherVar: true; + yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json index 8c39e5d1..9cd700d5 100644 --- a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json @@ -4,4 +4,4 @@ "instance" : { "assertPropertiesOf:" : "topa 11/28/2016 16:13", "classUnderTest" : "topa 11/28/2016 16:11", - "objectUnderTest" : "topa 11/28/2016 16:12" } } + "objectUnderTest" : "fn 11/28/2016 20:28" } } diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st index 21951469..f6ec36af 100644 --- a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignFixedAsImmutable.st @@ -1,4 +1,4 @@ -as yet unclassified +testing testForeignFixedAsImmutable | objectUnderTest | diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st index 38bcbac1..0362e0b3 100644 --- a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/instance/testForeignVariableAsImmutable.st @@ -1,11 +1,11 @@ -as yet unclassified +testing testForeignVariableAsImmutable | objectUnderTest | - objectUnderTest := #( 'foo' (2) 'bar' nil ) asImmutable: ImmJustVariablePointersClass. + objectUnderTest := #( 'foo' (2) 'bar' true ) asImmutable: ImmJustVariablePointersClass. self assert: 4 equals: objectUnderTest size. - self assert: 'foo' equals: objectUnderTest first. - self assert: #(2) equals: objectUnderTest second. - self assert: 'bar' equals: objectUnderTest third. - self assert: true equals: objectUnderTest last. + self assert: 'foo' equals: (objectUnderTest at: 1). + self assert: #(2) equals: (objectUnderTest at: 2). + self assert: 'bar' equals: (objectUnderTest at: 3). + self assert: true equals: (objectUnderTest at: 4). diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json index 3060ef4d..c2ccffac 100644 --- a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/methodProperties.json @@ -3,4 +3,4 @@ }, "instance" : { "testForeignFixedAsImmutable" : "topa 11/28/2016 16:27", - "testForeignVariableAsImmutable" : "topa 11/28/2016 16:28" } } + "testForeignVariableAsImmutable" : "fn 11/28/2016 20:26" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st new file mode 100644 index 00000000..4421d640 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/attemptToModify..st @@ -0,0 +1,4 @@ +test objects +attemptToModify: anImmutableObject + + anImmutableObject at: 1 put: 42 diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st index f5ad8fef..952446df 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/instance/testAsImmutable.st @@ -3,4 +3,5 @@ testAsImmutable | objectUnderTest | objectUnderTest := self objectUnderTest asImmutable: self classUnderTest. + self attemptToModify: objectUnderTest. self assertPropertiesOf: objectUnderTest. diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json index 699247a8..6ab30066 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/methodProperties.json @@ -3,8 +3,9 @@ "isAbstract" : "topa 11/28/2016 16:18" }, "instance" : { "assertPropertiesOf:" : "topa 11/28/2016 16:12", + "attemptToModify:" : "fn 11/28/2016 20:38", "classUnderTest" : "topa 11/28/2016 16:12", "objectUnderTest" : "topa 11/28/2016 16:12", - "testAsImmutable" : "topa 11/28/2016 16:09", + "testAsImmutable" : "fn 11/28/2016 20:37", "testImmutableCopy" : "topa 11/28/2016 16:09", "testImmutableFrom" : "topa 11/28/2016 16:10" } } diff --git a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/README.md b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/instance/testImmutableObjectVMSupport.st b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/instance/testImmutableObjectVMSupport.st similarity index 100% rename from repository/ImmutableObjects.package/ImmVMTest.class/instance/testImmutableObjectVMSupport.st rename to repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/instance/testImmutableObjectVMSupport.st diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/methodProperties.json similarity index 100% rename from repository/ImmutableObjects.package/ImmVMTest.class/methodProperties.json rename to repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/methodProperties.json diff --git a/repository/ImmutableObjects.package/ImmVMTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json similarity index 85% rename from repository/ImmutableObjects.package/ImmVMTest.class/properties.json rename to repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json index 8ce19f44..c2609f01 100644 --- a/repository/ImmutableObjects.package/ImmVMTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json @@ -7,7 +7,7 @@ "commentStamp" : "", "instvars" : [ ], - "name" : "ImmVMTest", + "name" : "ImmutableObjectsVMTest", "pools" : [ ], "super" : "ImmutabilityTestCase", diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st index 1fdf4b20..b6c1b4e1 100644 --- a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/assertPropertiesOf..st @@ -1,7 +1,7 @@ test objects assertPropertiesOf: anImmutableObject - self assert: 'foo' equals: anImmutableObject first. - self assert: #(2) equals: anImmutableObject second. - self assert: true equals: anImmutableObject third. - self assert: nil equals: anImmutableObject last. \ No newline at end of file + self assert: 'foo' equals: (anImmutableObject at: 1). + self assert: #(2) equals: (anImmutableObject at: 2). + self assert: true equals: (anImmutableObject at: 3). + self assert: nil equals: (anImmutableObject at: 4). \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st index c206562a..ad4939c8 100644 --- a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/instance/objectUnderTest.st @@ -4,4 +4,5 @@ objectUnderTest ^ (self classUnderTest new: 4) at: 1 put: 'foo'; at: 2 put: #(2); - at: 3 put: true \ No newline at end of file + at: 3 put: true; + yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json index 9b28c1e4..72266991 100644 --- a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/methodProperties.json @@ -2,6 +2,6 @@ "class" : { }, "instance" : { - "assertPropertiesOf:" : "topa 11/28/2016 16:17", + "assertPropertiesOf:" : "fn 11/28/2016 20:23", "classUnderTest" : "topa 11/28/2016 16:16", - "objectUnderTest" : "topa 11/28/2016 16:17" } } + "objectUnderTest" : "fn 11/28/2016 20:28" } } diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..a711a79f --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,5 @@ +test objects +assertPropertiesOf: anImmutableObject + + (1 to: 10) do: [:i | + self assert: (i * 2) equals: (anImmutableObject at: i)]. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..56eb7a55 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ Bitmap \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..3b55e438 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,4 @@ +test objects +objectUnderTest + + ^ self classUnderTest withAll: ((1 to: 10) collect: [:i | i * 2]) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json new file mode 100644 index 00000000..df5b03a8 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:41", + "classUnderTest" : "fn 11/28/2016 20:33", + "objectUnderTest" : "fn 11/28/2016 20:40" } } diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json new file mode 100644 index 00000000..b41d4545 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableWordsObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 83194641..2c0983b9 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 849b2d5dedb1406b83b3c2f06f10076735f2b0dc Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 20:58:09 +0100 Subject: [PATCH 19/63] Add ImmutableMixedObjectTest --- .../ImmMixedPointersClass.class/README.md | 0 .../instance/aField..st | 4 ++++ .../instance/aField.st | 4 ++++ .../instance/anotherField..st | 4 ++++ .../instance/anotherField.st | 4 ++++ .../methodProperties.json | 8 ++++++++ .../ImmMixedPointersClass.class/properties.json | 15 +++++++++++++++ .../ImmutableMixedObjectTest.class/README.md | 0 .../instance/assertPropertiesOf..st | 8 ++++++++ .../instance/classUnderTest.st | 4 ++++ .../instance/objectUnderTest.st | 10 ++++++++++ .../methodProperties.json | 7 +++++++ .../properties.json | 14 ++++++++++++++ .../monticello.meta/version | 2 +- 14 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json create mode 100644 repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/README.md create mode 100644 repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st create mode 100644 repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st create mode 100644 repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/README.md b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st new file mode 100644 index 00000000..1aa8db77 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField..st @@ -0,0 +1,4 @@ +accessing +aField: anObject + + aField := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st new file mode 100644 index 00000000..f0fbcc22 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/aField.st @@ -0,0 +1,4 @@ +accessing +aField + + ^ aField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st new file mode 100644 index 00000000..ec340273 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField..st @@ -0,0 +1,4 @@ +accessing +anotherField: anObject + + anotherField := anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st new file mode 100644 index 00000000..543c3da7 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/instance/anotherField.st @@ -0,0 +1,4 @@ +accessing +anotherField + + ^ anotherField \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json new file mode 100644 index 00000000..f3d0d1df --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/methodProperties.json @@ -0,0 +1,8 @@ +{ + "class" : { + }, + "instance" : { + "aField" : "fn 11/28/2016 20:48", + "aField:" : "fn 11/28/2016 20:48", + "anotherField" : "fn 11/28/2016 20:48", + "anotherField:" : "fn 11/28/2016 20:48" } } diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json new file mode 100644 index 00000000..e48fa45b --- /dev/null +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "aField", + "anotherField" ], + "name" : "ImmMixedPointersClass", + "pools" : [ + ], + "super" : "Object", + "type" : "variable" } diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/README.md b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st new file mode 100644 index 00000000..726a6943 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/assertPropertiesOf..st @@ -0,0 +1,8 @@ +test objects +assertPropertiesOf: anImmutableObject + + self assert: 'foo' equals: anImmutableObject aField. + self assert: #(2) equals: anImmutableObject anotherField. + self assert: true equals: (anImmutableObject at: 1). + self assert: {} equals: (anImmutableObject at: 2). + self assert: 'bar' equals: (anImmutableObject at: 3). \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st new file mode 100644 index 00000000..af1db842 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/classUnderTest.st @@ -0,0 +1,4 @@ +test objects +classUnderTest + + ^ ImmMixedPointersClass \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st new file mode 100644 index 00000000..40ee0562 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/instance/objectUnderTest.st @@ -0,0 +1,10 @@ +test objects +objectUnderTest + + ^ (self classUnderTest new: 3) + aField: 'foo'; + anotherField: #(2); + at: 1 put: true; + at: 2 put: {}; + at: 3 put: 'bar'; + yourself \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json new file mode 100644 index 00000000..39dae129 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/methodProperties.json @@ -0,0 +1,7 @@ +{ + "class" : { + }, + "instance" : { + "assertPropertiesOf:" : "fn 11/28/2016 20:51", + "classUnderTest" : "fn 11/28/2016 20:55", + "objectUnderTest" : "fn 11/28/2016 20:50" } } diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json new file mode 100644 index 00000000..d86d4d5d --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ImmutableMixedObjectTest", + "pools" : [ + ], + "super" : "ImmutableObjectTest", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 2c0983b9..612ef1a7 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 5d86824ad4b7694e81806dd0fd56459a8ede62f2 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Mon, 28 Nov 2016 20:59:04 +0100 Subject: [PATCH 20/63] Fix W_PointersObject_Immutable.size() --- rsqueakvm/plugins/immutability_plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 0bbee7ac..cad43d00 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -48,7 +48,7 @@ def getclass(self, space): return self.w_class def size(self): - return len(self.storage) - self.instsize() + return len(self.storage) def instsize(self): return self._instsize From 24ca1b7a805ba64bc383d4fcafe3564ed3e70c20 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 29 Nov 2016 09:43:47 +0100 Subject: [PATCH 21/63] Minor cleanup [ci skip] --- rsqueakvm/plugins/immutability_plugin.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index cad43d00..4efbee38 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -2,11 +2,10 @@ from rsqueakvm.model import * from rsqueakvm.plugins.plugin import Plugin from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS -from rsqueakvm.util.version import Version ImmutabilityPlugin = Plugin() -WRITE_OPERATIONS_W_OBJECT = [ +WRITE_OPERATIONS = [ # W_Object 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', 'fillin_weak', 'fillin_finalize', @@ -23,7 +22,7 @@ def is_immutable(self): return True cls.is_immutable = is_immutable - for method_name in WRITE_OPERATIONS_W_OBJECT: + for method_name in WRITE_OPERATIONS: if hasattr(cls, method_name): def noop(self, *args): pass From c455d9ca1e2c884f7407ef2bdb40943dfa3cabb7 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 29 Nov 2016 10:48:01 +0100 Subject: [PATCH 22/63] In @jit.elidable we trust and remove storage in bytes and words classes --- rsqueakvm/plugins/immutability_plugin.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 4efbee38..69353be5 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -3,6 +3,8 @@ from rsqueakvm.plugins.plugin import Plugin from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS +from rpython.rlib import jit + ImmutabilityPlugin = Plugin() WRITE_OPERATIONS = [ @@ -61,16 +63,15 @@ def fetch(self, space, n0): def _add_immutable_w_bytesobject_subclass(): @immutable_class class W_BytesObject_Immutable(W_BytesObject): - _attrs_ = ['storage'] - _immutable_fields_ = ['storage'] repr_classname = '%s_Immutable' % W_BytesObject.repr_classname def __init__(self, space, w_cls, bytes_w): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.storage = bytes_w + self.bytes = bytes_w + @jit.elidable def _bytes(self): - return self.storage + return W_BytesObject._bytes(self) def _version(self): return None @@ -81,16 +82,15 @@ def _version(self): def _add_immutable_w_wordsobject_subclass(): @immutable_class class W_WordsObject_Immutable(W_WordsObject): - _attrs_ = ['storage'] - _immutable_fields_ = ['storage'] repr_classname = '%s_Immutable' % W_WordsObject.repr_classname def __init__(self, space, w_cls, words_w): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.storage = words_w + self.words = words_w + @jit.elidable def _words(self): - return self.storage + return W_WordsObject._words(self) W_WordsObject.immutable_subclass = W_WordsObject_Immutable From aa123ca82e7046ed3f2e1e73793af4f3ac539a83 Mon Sep 17 00:00:00 2001 From: jchromik Date: Thu, 1 Dec 2016 10:31:13 +0100 Subject: [PATCH 23/63] fix ImmutableFixedObjectTest [ci skip] --- .../instance/attemptToModify..st | 4 ++++ .../ImmutableFixedObjectTest.class/methodProperties.json | 1 + repository/ImmutableObjects.package/monticello.meta/version | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st new file mode 100644 index 00000000..78e25e79 --- /dev/null +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/instance/attemptToModify..st @@ -0,0 +1,4 @@ +test objects +attemptToModify: anImmutableObject + + anImmutableObject aField: 42 diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json index 9cd700d5..dc39f0d8 100644 --- a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/methodProperties.json @@ -3,5 +3,6 @@ }, "instance" : { "assertPropertiesOf:" : "topa 11/28/2016 16:13", + "attemptToModify:" : "jc 12/1/2016 10:24", "classUnderTest" : "topa 11/28/2016 16:11", "objectUnderTest" : "fn 11/28/2016 20:28" } } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 612ef1a7..16f8d6f4 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 65c0816c5ee05bf81dac76db85a9edf425116167 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 1 Dec 2016 10:38:53 +0100 Subject: [PATCH 24/63] Add empty macOS section --- .build/environment.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.build/environment.py b/.build/environment.py index a0857ce3..6fcd1c74 100755 --- a/.build/environment.py +++ b/.build/environment.py @@ -30,6 +30,7 @@ def load_config(): cp.set("Windows", "VisualStudio9", "C:\\Program Files (x86)\\Microsoft Visual Studio 9.0") cp.set("Windows", "Graphviz", pathjoin(dirname(__file__), "Graphviz")) cp.set("Windows", "pypyextlibs", pathjoin(dirname(__file__), "pypyextlibs")) + cp.add_section("macOS") cp.write(f) print "I've just added a config file at %s. Please review the values and run `install_dependencies` (if needed)." % config else: From 9efd5ed6556ca47312d5d06460f9affe2dd81f46 Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Mon, 5 Dec 2016 17:48:38 +0100 Subject: [PATCH 25/63] Add Cons and Vector structures as example. need test uses [ci skip] --- .../instance/primImmutableFromArgs.st | 11 +++++ .../Behavior.extension/methodProperties.json | 3 +- .../Cons.class/README.md | 0 .../Cons.class/class/car.cdr..st | 10 ++++ .../Cons.class/class/new.st | 4 ++ .../Cons.class/instance/^comma.st | 4 ++ .../Cons.class/instance/^tilde.st | 4 ++ .../Cons.class/instance/append..st | 7 +++ .../Cons.class/instance/asCons.st | 4 ++ .../Cons.class/instance/car.st | 4 ++ .../Cons.class/instance/cdr.st | 4 ++ .../Cons.class/instance/collect..st | 4 ++ .../Cons.class/instance/do..st | 4 ++ .../Cons.class/instance/filter..st | 7 +++ .../Cons.class/instance/findf..st | 4 ++ .../Cons.class/instance/findf.ifNone..st | 7 +++ .../Cons.class/instance/foldl.withInit..st | 5 ++ .../Cons.class/instance/foldr.withInit..st | 7 +++ .../Cons.class/instance/forEach..st | 6 +++ .../Cons.class/instance/inject.into..st | 4 ++ .../Cons.class/instance/innerPrintListOn..st | 12 +++++ .../Cons.class/instance/isCons.st | 4 ++ .../Cons.class/instance/map..st | 7 +++ .../Cons.class/instance/printListOn..st | 6 +++ .../Cons.class/instance/printOn..st | 4 ++ .../Cons.class/instance/reduce..st | 5 ++ .../Cons.class/instance/reject..st | 4 ++ .../Cons.class/instance/reverse..st | 5 ++ .../Cons.class/instance/reverse.st | 4 ++ .../Cons.class/instance/select..st | 4 ++ .../Cons.class/methodProperties.json | 30 ++++++++++++ .../Cons.class/properties.json | 15 ++++++ .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../ImmutableObjectTest.class/properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../properties.json | 2 +- .../Object.extension/instance/^tilde.st | 5 ++ .../Object.extension/instance/asCons.st | 4 ++ .../Object.extension/instance/isCons.st | 4 ++ .../Object.extension/methodProperties.json | 5 +- .../instance/append..st | 4 ++ .../instance/filter..st | 4 ++ .../instance/findf.ifNone..st | 4 ++ .../instance/foldl.withInit..st | 4 ++ .../instance/foldr.withInit..st | 4 ++ .../instance/isCons.st | 4 ++ .../instance/map..st | 4 ++ .../instance/reverse..st | 4 ++ .../methodProperties.json | 12 +++++ .../UndefinedObject.extension/properties.json | 2 + .../Vector.class/README.md | 0 .../Vector.class/class/new..st | 4 ++ .../Vector.class/class/new.st | 5 ++ .../Vector.class/class/new.withAll..st | 4 ++ .../Vector.class/class/newFrom..st | 4 ++ .../Vector.class/class/newFromStream..st | 5 ++ .../Vector.class/class/primImmutableFrom..st | 8 ++++ .../Vector.class/class/with..st | 6 +++ .../Vector.class/class/with.with..st | 7 +++ .../Vector.class/class/with.with.with..st | 8 ++++ .../class/with.with.with.with..st | 8 ++++ .../class/with.with.with.with.with..st | 8 ++++ .../class/with.with.with.with.with.with..st | 7 +++ .../Vector.class/class/withAll..st | 6 +++ .../Vector.class/instance/^comma.st | 11 +++++ .../Vector.class/instance/at.incrementBy..st | 4 ++ .../Vector.class/instance/atAll.put..st | 4 ++ .../Vector.class/instance/atAll.putAll..st | 4 ++ .../Vector.class/instance/atAllPut..st | 4 ++ .../Vector.class/instance/atLast.put..st | 4 ++ .../Vector.class/instance/atWrap.put..st | 4 ++ .../Vector.class/instance/collect..st | 4 ++ .../Vector.class/instance/collect.from.to..st | 4 ++ .../Vector.class/instance/copyEmpty.st | 4 ++ .../Vector.class/instance/copyFrom.to..st | 12 +++++ .../instance/copyReplaceFrom.to.with..st | 19 ++++++++ .../Vector.class/instance/copyWith..st | 4 ++ .../Vector.class/instance/copyWithFirst..st | 4 ++ .../instance/copyWithoutIndex..st | 4 ++ .../Vector.class/instance/from.to.put..st | 4 ++ .../Vector.class/instance/grownBy..st | 4 ++ .../Vector.class/instance/integerAt.put..st | 4 ++ .../Vector.class/instance/pvtAt.put..st | 5 ++ .../Vector.class/instance/replace..st | 4 ++ .../Vector.class/instance/replaceAll.with..st | 4 ++ .../replaceFrom.to.with.startingAt..st | 9 ++++ .../Vector.class/instance/reversed.st | 6 +++ .../Vector.class/instance/select..st | 4 ++ .../Vector.class/instance/sort..st | 4 ++ .../Vector.class/instance/sort.st | 4 ++ .../Vector.class/instance/sorted..st | 4 ++ .../Vector.class/instance/sorted.st | 4 ++ .../Vector.class/instance/species.st | 4 ++ .../Vector.class/instance/swap.with..st | 4 ++ .../Vector.class/methodProperties.json | 46 +++++++++++++++++++ .../Vector.class/properties.json | 14 ++++++ .../monticello.meta/categories.st | 3 +- .../monticello.meta/version | 2 +- 106 files changed, 578 insertions(+), 16 deletions(-) create mode 100644 repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st create mode 100644 repository/ImmutableObjects.package/Cons.class/README.md create mode 100644 repository/ImmutableObjects.package/Cons.class/class/car.cdr..st create mode 100644 repository/ImmutableObjects.package/Cons.class/class/new.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/^comma.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/^tilde.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/append..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/asCons.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/car.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/cdr.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/collect..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/do..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/filter..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/findf..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/forEach..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/inject.into..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/isCons.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/map..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/printListOn..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/printOn..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/reduce..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/reject..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/reverse..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/reverse.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/select..st create mode 100644 repository/ImmutableObjects.package/Cons.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/Cons.class/properties.json create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/^tilde.st create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/asCons.st create mode 100644 repository/ImmutableObjects.package/Object.extension/instance/isCons.st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json create mode 100644 repository/ImmutableObjects.package/UndefinedObject.extension/properties.json create mode 100644 repository/ImmutableObjects.package/Vector.class/README.md create mode 100644 repository/ImmutableObjects.package/Vector.class/class/new..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/new.st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/new.withAll..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/newFrom..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/newFromStream..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/with.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/with.with.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/class/withAll..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/^comma.st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/collect..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/copyWith..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/grownBy..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/replace..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/reversed.st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/select..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/sort..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/sort.st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/sorted..st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/sorted.st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/species.st create mode 100644 repository/ImmutableObjects.package/Vector.class/instance/swap.with..st create mode 100644 repository/ImmutableObjects.package/Vector.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/Vector.class/properties.json diff --git a/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st new file mode 100644 index 00000000..d424253c --- /dev/null +++ b/repository/ImmutableObjects.package/Behavior.extension/instance/primImmutableFromArgs.st @@ -0,0 +1,11 @@ +*ImmutableObjects +primImmutableFromArgs + "Primitive. Answer an instance of the receiver (which is a class) with + all fields initialized to the arguments given. + This is a template. + Do not use directly. + Copy into your class with appropriate arguments! + See Object documentation whatIsAPrimitive." + + + self primitiveFailed \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json index feec8284..feb0db47 100644 --- a/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Behavior.extension/methodProperties.json @@ -4,4 +4,5 @@ "instance" : { "allImmutableInstances" : "topa 11/28/2016 15:23", "immutableFrom:" : "topa 11/28/2016 15:23", - "primImmutableFrom:" : "topa 11/28/2016 15:23" } } + "primImmutableFrom:" : "topa 11/28/2016 15:23", + "primImmutableFromArgs" : "topa 12/5/2016 09:16" } } diff --git a/repository/ImmutableObjects.package/Cons.class/README.md b/repository/ImmutableObjects.package/Cons.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st b/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st new file mode 100644 index 00000000..38bea290 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st @@ -0,0 +1,10 @@ +as yet unclassified +car: anObject cdr: anotherObject + + + " Fallback for non-immutable " + + ^ self basicNew + instVarNamed: 'car' put: anObject; + instVarNamed: 'cdr' put: anotherObject; + initialize \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/class/new.st b/repository/ImmutableObjects.package/Cons.class/class/new.st new file mode 100644 index 00000000..70e36bcd --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/class/new.st @@ -0,0 +1,4 @@ +as yet unclassified +new + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/^comma.st b/repository/ImmutableObjects.package/Cons.class/instance/^comma.st new file mode 100644 index 00000000..feffe2a6 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/^comma.st @@ -0,0 +1,4 @@ +collection api +, aCons + + ^ self append: aCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/^tilde.st b/repository/ImmutableObjects.package/Cons.class/instance/^tilde.st new file mode 100644 index 00000000..1d71a06c --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/^tilde.st @@ -0,0 +1,4 @@ +convenience +~ anObject + + ^ self append: anObject asCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/append..st b/repository/ImmutableObjects.package/Cons.class/instance/append..st new file mode 100644 index 00000000..589593f6 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/append..st @@ -0,0 +1,7 @@ +functional iteration +append: aCons + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ Cons + car: self car + cdr: (self cdr append: aCons) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/asCons.st b/repository/ImmutableObjects.package/Cons.class/instance/asCons.st new file mode 100644 index 00000000..dfeb4e3a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/asCons.st @@ -0,0 +1,4 @@ +converting +asCons + + ^ self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/car.st b/repository/ImmutableObjects.package/Cons.class/instance/car.st new file mode 100644 index 00000000..298d4982 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/car.st @@ -0,0 +1,4 @@ +accessing +car + + ^ car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/cdr.st b/repository/ImmutableObjects.package/Cons.class/instance/cdr.st new file mode 100644 index 00000000..abd0453a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/cdr.st @@ -0,0 +1,4 @@ +accessing +cdr + + ^ cdr \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/collect..st b/repository/ImmutableObjects.package/Cons.class/instance/collect..st new file mode 100644 index 00000000..fe526359 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/collect..st @@ -0,0 +1,4 @@ +collection api +collect: aBlock + + ^ self map: aBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/do..st b/repository/ImmutableObjects.package/Cons.class/instance/do..st new file mode 100644 index 00000000..44467e73 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/do..st @@ -0,0 +1,4 @@ +collection api +do: aBlock + + self forEach: aBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/filter..st b/repository/ImmutableObjects.package/Cons.class/instance/filter..st new file mode 100644 index 00000000..67f7e8e0 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/filter..st @@ -0,0 +1,7 @@ +functional iteration +filter: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ (aBlock value: self car) + ifTrue: [Cons car: self car cdr: (self cdr filter: aBlock)] + ifFalse: [self cdr filter: aBlock] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/findf..st b/repository/ImmutableObjects.package/Cons.class/instance/findf..st new file mode 100644 index 00000000..1758c25c --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/findf..st @@ -0,0 +1,4 @@ +functional iteration +findf: aBlock + + ^ self findf: aBlock ifNone: [false] diff --git a/repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st b/repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st new file mode 100644 index 00000000..b37aaf5a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/findf.ifNone..st @@ -0,0 +1,7 @@ +functional iteration +findf: aBlock ifNone: anotherBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ (aBlock value: self car) + ifTrue: [self car] + ifFalse: [self cdr findf: aBlock ifNone: anotherBlock] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st b/repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st new file mode 100644 index 00000000..a93542a7 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/foldl.withInit..st @@ -0,0 +1,5 @@ +functional iteration +foldl: aBlock withInit: anObject + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ self cdr foldl: aBlock withInit: (aBlock value: anObject value: self car) diff --git a/repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st b/repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st new file mode 100644 index 00000000..05da91f8 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/foldr.withInit..st @@ -0,0 +1,7 @@ +functional iteration +foldr: aBlock withInit: anObject + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ aBlock + value: (self cdr foldr: aBlock withInit: anObject) + value: self car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/forEach..st b/repository/ImmutableObjects.package/Cons.class/instance/forEach..st new file mode 100644 index 00000000..c53c3cc1 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/forEach..st @@ -0,0 +1,6 @@ +functional iteration +forEach: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + aBlock value: self car. + self cdr map: aBlock. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/inject.into..st b/repository/ImmutableObjects.package/Cons.class/instance/inject.into..st new file mode 100644 index 00000000..51e3f466 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/inject.into..st @@ -0,0 +1,4 @@ +collection api +inject: anObject into: aBlock + + ^ self foldl: aBlock withInit: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st b/repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st new file mode 100644 index 00000000..d74f7e04 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/innerPrintListOn..st @@ -0,0 +1,12 @@ +testing +innerPrintListOn: aStream + + self car printOn: aStream. + self cdr + ifNotNil: [:cont | cont isCons + ifFalse: [ + aStream nextPutAll: ' . '. + cont printOn: aStream] + ifTrue: [ + aStream space. + cont innerPrintListOn: aStream]] diff --git a/repository/ImmutableObjects.package/Cons.class/instance/isCons.st b/repository/ImmutableObjects.package/Cons.class/instance/isCons.st new file mode 100644 index 00000000..002442b7 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/isCons.st @@ -0,0 +1,4 @@ +testing +isCons + + ^ true \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/map..st b/repository/ImmutableObjects.package/Cons.class/instance/map..st new file mode 100644 index 00000000..811a0de5 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/map..st @@ -0,0 +1,7 @@ +functional iteration +map: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ Cons + car: (aBlock value: self car) + cdr: (self cdr map: aBlock) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/printListOn..st b/repository/ImmutableObjects.package/Cons.class/instance/printListOn..st new file mode 100644 index 00000000..48651a39 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/printListOn..st @@ -0,0 +1,6 @@ +printing +printListOn: aStream + + aStream nextPutAll: '''('. + self innerPrintListOn: aStream. + aStream nextPutAll: ')'. diff --git a/repository/ImmutableObjects.package/Cons.class/instance/printOn..st b/repository/ImmutableObjects.package/Cons.class/instance/printOn..st new file mode 100644 index 00000000..59185ce8 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/printOn..st @@ -0,0 +1,4 @@ +printing +printOn: aStream + + self printListOn: aStream. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reduce..st b/repository/ImmutableObjects.package/Cons.class/instance/reduce..st new file mode 100644 index 00000000..e958b8e9 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reduce..st @@ -0,0 +1,5 @@ +functional iteration +reduce: aBlock + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ self cdr foldl: aBlock withInit: self car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reject..st b/repository/ImmutableObjects.package/Cons.class/instance/reject..st new file mode 100644 index 00000000..8c305f70 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reject..st @@ -0,0 +1,4 @@ +collection api +reject: aBlock + + ^ self filter: [:each | (aBlock value: each) not] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reverse..st b/repository/ImmutableObjects.package/Cons.class/instance/reverse..st new file mode 100644 index 00000000..7e955300 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reverse..st @@ -0,0 +1,5 @@ +functional iteration +reverse: acc + + self cdr isCons ifFalse: [^ self error: 'Not a proper list']. + ^ self cdr reverse: (Cons car: self car cdr: acc) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/reverse.st b/repository/ImmutableObjects.package/Cons.class/instance/reverse.st new file mode 100644 index 00000000..cce8032e --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/reverse.st @@ -0,0 +1,4 @@ +functional iteration +reverse + + ^ self reverse: nil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/select..st b/repository/ImmutableObjects.package/Cons.class/instance/select..st new file mode 100644 index 00000000..d2a449fd --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/select..st @@ -0,0 +1,4 @@ +collection api +select: aBlock + + ^ self filter: aBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/methodProperties.json b/repository/ImmutableObjects.package/Cons.class/methodProperties.json new file mode 100644 index 00000000..44c62c5a --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/methodProperties.json @@ -0,0 +1,30 @@ +{ + "class" : { + "car:cdr:" : "topa 12/5/2016 09:18", + "new" : "topa 12/5/2016 08:19" }, + "instance" : { + "," : "topa 12/5/2016 16:41", + "append:" : "topa 12/5/2016 16:30", + "asCons" : "topa 12/5/2016 17:42", + "car" : "topa 12/5/2016 08:18", + "cdr" : "topa 12/5/2016 08:18", + "collect:" : "topa 12/5/2016 16:38", + "do:" : "topa 12/5/2016 17:34", + "filter:" : "topa 12/5/2016 16:32", + "findf:" : "topa 12/5/2016 17:31", + "findf:ifNone:" : "topa 12/5/2016 17:31", + "foldl:withInit:" : "topa 12/5/2016 17:15", + "foldr:withInit:" : "topa 12/5/2016 17:19", + "forEach:" : "topa 12/5/2016 17:34", + "inject:into:" : "topa 12/5/2016 16:54", + "innerPrintListOn:" : "topa 12/5/2016 09:25", + "isCons" : "topa 12/5/2016 09:25", + "map:" : "topa 12/5/2016 16:27", + "printListOn:" : "topa 12/5/2016 09:22", + "printOn:" : "topa 12/5/2016 09:20", + "reduce:" : "topa 12/5/2016 17:26", + "reject:" : "topa 12/5/2016 17:28", + "reverse" : "topa 12/5/2016 16:33", + "reverse:" : "topa 12/5/2016 16:36", + "select:" : "topa 12/5/2016 16:41", + "~" : "topa 12/5/2016 17:45" } } diff --git a/repository/ImmutableObjects.package/Cons.class/properties.json b/repository/ImmutableObjects.package/Cons.class/properties.json new file mode 100644 index 00000000..c8251d73 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/properties.json @@ -0,0 +1,15 @@ +{ + "category" : "ImmutableObjects-Structures", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + "car", + "cdr" ], + "name" : "Cons", + "pools" : [ + ], + "super" : "Object", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json index 3a3dce9e..17b150d2 100644 --- a/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json +++ b/repository/ImmutableObjects.package/ImmJustFixedPointersClass.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json index 126cc137..a13a8874 100644 --- a/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json +++ b/repository/ImmutableObjects.package/ImmJustVariablePointersClass.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json index e48fa45b..cd616efa 100644 --- a/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json +++ b/repository/ImmutableObjects.package/ImmMixedPointersClass.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json index 3d61168a..4b3007be 100644 --- a/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutabilityTestCase.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json index b61cc3e4..a872928b 100644 --- a/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableBytesObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json index d6fdf8f2..51ab31b6 100644 --- a/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableFixedObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json index ed7cdca8..93a1fef2 100644 --- a/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableForeignObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json index d86d4d5d..5e5e8fed 100644 --- a/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableMixedObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json index 119ad0a4..d3709382 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json index c2609f01..c84bdaed 100644 --- a/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableObjectsVMTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json index 17d2794a..b81cef9f 100644 --- a/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableVariableObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json index b41d4545..994b0061 100644 --- a/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json +++ b/repository/ImmutableObjects.package/ImmutableWordsObjectTest.class/properties.json @@ -1,5 +1,5 @@ { - "category" : "ImmutableObjects", + "category" : "ImmutableObjects-Tests", "classinstvars" : [ ], "classvars" : [ diff --git a/repository/ImmutableObjects.package/Object.extension/instance/^tilde.st b/repository/ImmutableObjects.package/Object.extension/instance/^tilde.st new file mode 100644 index 00000000..b1dd72fc --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/^tilde.st @@ -0,0 +1,5 @@ +*ImmutableObjects-Structures-testing +~ anObject + " printIt: [1 ~ 2 ~ 3] " + + ^ self asCons ~ anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/asCons.st b/repository/ImmutableObjects.package/Object.extension/instance/asCons.st new file mode 100644 index 00000000..839f8746 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/asCons.st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures-testing +asCons + + ^ Cons car: self cdr: nil \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/instance/isCons.st b/repository/ImmutableObjects.package/Object.extension/instance/isCons.st new file mode 100644 index 00000000..c02a0f28 --- /dev/null +++ b/repository/ImmutableObjects.package/Object.extension/instance/isCons.st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures-testing +isCons + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Object.extension/methodProperties.json b/repository/ImmutableObjects.package/Object.extension/methodProperties.json index 8d13bc71..9f58e454 100644 --- a/repository/ImmutableObjects.package/Object.extension/methodProperties.json +++ b/repository/ImmutableObjects.package/Object.extension/methodProperties.json @@ -2,7 +2,10 @@ "class" : { }, "instance" : { + "asCons" : "topa 12/5/2016 17:42", "asImmutable:" : "topa 11/28/2016 15:23", "immutableCopy" : "topa 11/28/2016 15:24", + "isCons" : "topa 12/5/2016 09:25", "isImmutable" : "topa 11/28/2016 15:23", - "primIsImmutable" : "topa 11/28/2016 15:23" } } + "primIsImmutable" : "topa 11/28/2016 15:23", + "~" : "topa 12/5/2016 17:45" } } diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st new file mode 100644 index 00000000..37bbf1bd --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/append..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +append: aCons + + ^ aCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st new file mode 100644 index 00000000..e7a28846 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/filter..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +filter: aBlock + + ^ self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st new file mode 100644 index 00000000..9dcc0b3e --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/findf.ifNone..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +findf: aBlock ifNone: anotherBlock + + ^ anotherBlock value \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st new file mode 100644 index 00000000..0680f01f --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldl.withInit..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +foldl: aBlock withInit: anObject + + ^ anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st new file mode 100644 index 00000000..8ff8e3db --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/foldr.withInit..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +foldr: aBlock withInit: anObject + + ^ anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st new file mode 100644 index 00000000..078149d3 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/isCons.st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +isCons + + ^ true \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st new file mode 100644 index 00000000..bfeb41cf --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/map..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +map: aBlock + + ^ self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st new file mode 100644 index 00000000..d599c732 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/instance/reverse..st @@ -0,0 +1,4 @@ +*ImmutableObjects-Structures +reverse: aCons + + ^ aCons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json b/repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json new file mode 100644 index 00000000..ab643692 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/methodProperties.json @@ -0,0 +1,12 @@ +{ + "class" : { + }, + "instance" : { + "append:" : "topa 12/5/2016 16:30", + "filter:" : "topa 12/5/2016 16:31", + "findf:ifNone:" : "topa 12/5/2016 17:32", + "foldl:withInit:" : "topa 12/5/2016 17:13", + "foldr:withInit:" : "topa 12/5/2016 16:53", + "isCons" : "topa 12/5/2016 16:26", + "map:" : "topa 12/5/2016 16:22", + "reverse:" : "topa 12/5/2016 16:40" } } diff --git a/repository/ImmutableObjects.package/UndefinedObject.extension/properties.json b/repository/ImmutableObjects.package/UndefinedObject.extension/properties.json new file mode 100644 index 00000000..508a24a8 --- /dev/null +++ b/repository/ImmutableObjects.package/UndefinedObject.extension/properties.json @@ -0,0 +1,2 @@ +{ + "name" : "UndefinedObject" } diff --git a/repository/ImmutableObjects.package/Vector.class/README.md b/repository/ImmutableObjects.package/Vector.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/Vector.class/class/new..st b/repository/ImmutableObjects.package/Vector.class/class/new..st new file mode 100644 index 00000000..5cf46568 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/new..st @@ -0,0 +1,4 @@ +instance creation +new: size + + self shouldNotImplement \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/new.st b/repository/ImmutableObjects.package/Vector.class/class/new.st new file mode 100644 index 00000000..8b15851a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/new.st @@ -0,0 +1,5 @@ +instance creation +new + + + ^ (self basicNew: 0) initialize \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/new.withAll..st b/repository/ImmutableObjects.package/Vector.class/class/new.withAll..st new file mode 100644 index 00000000..7f290564 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/new.withAll..st @@ -0,0 +1,4 @@ +instance creation +new: size withAll: value + + ^ self immutableFrom: (Array new: size withAll: value) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/newFrom..st b/repository/ImmutableObjects.package/Vector.class/class/newFrom..st new file mode 100644 index 00000000..570ce81b --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/newFrom..st @@ -0,0 +1,4 @@ +instance creation +newFrom: aCollection + + ^ self immutableFrom: aCollection asArray \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/newFromStream..st b/repository/ImmutableObjects.package/Vector.class/class/newFromStream..st new file mode 100644 index 00000000..9b04f6ac --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/newFromStream..st @@ -0,0 +1,5 @@ +instance creation +newFromStream: aStream + + self flag: #topa. "Todo." + self shouldBeImplemented. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st b/repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st new file mode 100644 index 00000000..38db8c54 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/primImmutableFrom..st @@ -0,0 +1,8 @@ +instance creation +primImmutableFrom: aCollection + " Overridden to be co-usable in mutable form " + + aCollection class isVariable ifFalse: [^ self primitiveFailed]. + + ^ (self basicNew: aCollection size) + replaceFrom: 1 to: aCollection size with: aCollection \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with..st b/repository/ImmutableObjects.package/Vector.class/class/with..st new file mode 100644 index 00000000..2d5f5fb5 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with..st @@ -0,0 +1,6 @@ +instance creation +with: anObject + "Answer a new instance of me, containing only anObject." + + " Fallback for non-immutable " + ^ super with: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with..st new file mode 100644 index 00000000..980301f0 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with..st @@ -0,0 +1,7 @@ +instance creation +with: firstObject with: secondObject + "Answer a new instance of me, containing firstObject and secondObject." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with..st new file mode 100644 index 00000000..f5fd3368 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with..st @@ -0,0 +1,8 @@ +instance creation +with: firstObject with: secondObject with: thirdObject + "Answer a new instance of me, containing only the three arguments as + elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st new file mode 100644 index 00000000..0003c228 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with..st @@ -0,0 +1,8 @@ +instance creation +with: firstObject with: secondObject with: thirdObject with: fourthObject + "Answer a new instance of me, containing only the four arguments as + elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject with: fourthObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st new file mode 100644 index 00000000..f881eb95 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with..st @@ -0,0 +1,8 @@ +instance creation +with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject + "Answer a new instance of me, containing only the five arguments as + elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject diff --git a/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st new file mode 100644 index 00000000..36c97bb9 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/with.with.with.with.with.with..st @@ -0,0 +1,7 @@ +instance creation +with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject with: sixthObject + "Answer a new instance of me, containing only the 6 arguments as elements." + + + " Fallback for non-immutable " + ^ super with: firstObject with: secondObject with: thirdObject with: fourthObject with: fifthObject with: sixthObject diff --git a/repository/ImmutableObjects.package/Vector.class/class/withAll..st b/repository/ImmutableObjects.package/Vector.class/class/withAll..st new file mode 100644 index 00000000..103c2b9f --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/class/withAll..st @@ -0,0 +1,6 @@ +instance creation +withAll: aCollection + "Create a new collection containing all the elements from aCollection." + + ^ self immutableFrom: aCollection asArray + \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/^comma.st b/repository/ImmutableObjects.package/Vector.class/instance/^comma.st new file mode 100644 index 00000000..4b7d3058 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/^comma.st @@ -0,0 +1,11 @@ +copying +, otherCollection + + | intermediateHolder | + intermediateHolder := self species + new: (self size + otherCollection size) + streamContents: [:stream | + stream + nextPutAll: self; + nextPutAll: otherCollection]. + ^ self class newFrom: intermediateHolder \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st b/repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st new file mode 100644 index 00000000..7cc5489a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/at.incrementBy..st @@ -0,0 +1,4 @@ +unsupported mutation +at: index incrementBy: value + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st b/repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st new file mode 100644 index 00000000..567dad35 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atAll.put..st @@ -0,0 +1,4 @@ +unsupported mutation +atAll: aCollection put: anObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st b/repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st new file mode 100644 index 00000000..572ee66d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atAll.putAll..st @@ -0,0 +1,4 @@ +unsupported mutation +atAll: indexArray putAll: valueArray + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st b/repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st new file mode 100644 index 00000000..c8dff94e --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atAllPut..st @@ -0,0 +1,4 @@ +unsupported mutation +atAllPut: anObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st b/repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st new file mode 100644 index 00000000..12bb3227 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atLast.put..st @@ -0,0 +1,4 @@ +unsupported mutation +atLast: indexFromEnd put: obj + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st b/repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st new file mode 100644 index 00000000..cf56dbe3 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/atWrap.put..st @@ -0,0 +1,4 @@ +unsupported mutation +atWrap: index put: value + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/collect..st b/repository/ImmutableObjects.package/Vector.class/instance/collect..st new file mode 100644 index 00000000..906a8e57 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/collect..st @@ -0,0 +1,4 @@ +enumerating +collect: aBlock + + ^ self class newFrom: (super collect: aBlock) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st b/repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st new file mode 100644 index 00000000..c19b7df1 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/collect.from.to..st @@ -0,0 +1,4 @@ +enumerating +collect: aBlock from: first to: last + + ^ self class newFrom: (super collect: aBlock from: first to: last) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st b/repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st new file mode 100644 index 00000000..9991f7e6 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyEmpty.st @@ -0,0 +1,4 @@ +copying +copyEmpty + " Whyever useful.. " + ^ self class new \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st b/repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st new file mode 100644 index 00000000..a347ede9 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyFrom.to..st @@ -0,0 +1,12 @@ +copying +copyFrom: start to: stop + + | temporaryHolder | + stop < start ifTrue: [^ self copyEmpty]. + + temporaryHolder := self species + new: stop - start + 1 + streamContents: [:aStream | + start to: stop do: [:index | + aStream nextPut: (self at: index)]]. + ^ self class newFrom: temporaryHolder \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st b/repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st new file mode 100644 index 00000000..40c827d2 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyReplaceFrom.to.with..st @@ -0,0 +1,19 @@ +copying +copyReplaceFrom: start to: stop with: replacementCollection + + | intermediateHolder endReplacement newSize | + newSize := self size - (stop - start + 1) + replacementCollection size. + endReplacement := start - 1 + replacementCollection size. + intermediateHolder := self species + new: newSize + streamContents: [:aStream | + start > 1 ifTrue: [ + 1 to: start - 1 do: [:index | + aStream nextPut: (self at: index)]]. + start <= endReplacement ifTrue: [ + 1 to: replacementCollection size do: [:index | + aStream nextPut: (replacementCollection at: index)]]. + endReplacement < newSize ifTrue: [ + stop + 1 to: self size do: [:index | + aStream nextPut: (self at: index)]]]. + ^ self class newFrom: intermediateHolder \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyWith..st b/repository/ImmutableObjects.package/Vector.class/instance/copyWith..st new file mode 100644 index 00000000..bf471e6a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyWith..st @@ -0,0 +1,4 @@ +copying +copyWith: newElement + + ^ self, { newElement } \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st b/repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st new file mode 100644 index 00000000..1619352e --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyWithFirst..st @@ -0,0 +1,4 @@ +copying +copyWithFirst: newElement + + ^ self class newFrom: { newElement }, self \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st b/repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st new file mode 100644 index 00000000..06d8a160 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/copyWithoutIndex..st @@ -0,0 +1,4 @@ +copying +copyWithoutIndex: index + + ^ (self first: index -1), (self allButFirst: index) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st b/repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st new file mode 100644 index 00000000..e5285e31 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/from.to.put..st @@ -0,0 +1,4 @@ +unsupported mutation +from: startIndex to: endIndex put: anObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/grownBy..st b/repository/ImmutableObjects.package/Vector.class/instance/grownBy..st new file mode 100644 index 00000000..564e0919 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/grownBy..st @@ -0,0 +1,4 @@ +unsupported mutation +grownBy: length + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st b/repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st new file mode 100644 index 00000000..1c5d4663 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/integerAt.put..st @@ -0,0 +1,4 @@ +unsupported mutation +integerAt: index put: value + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st b/repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st new file mode 100644 index 00000000..0bbd76f7 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/pvtAt.put..st @@ -0,0 +1,5 @@ +private mutation +pvtAt: anIndex put: anObject + " Will fail if we are immutable. Only for mutable support" + + ^ super at: anIndex put: anObject \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/replace..st b/repository/ImmutableObjects.package/Vector.class/instance/replace..st new file mode 100644 index 00000000..2a6cdb4a --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/replace..st @@ -0,0 +1,4 @@ +unsupported mutation +replace: aBlock + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st b/repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st new file mode 100644 index 00000000..d93975a6 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/replaceAll.with..st @@ -0,0 +1,4 @@ +unsupported mutation +replaceAll: oldObject with: newObject + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st b/repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st new file mode 100644 index 00000000..1daaa610 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/replaceFrom.to.with.startingAt..st @@ -0,0 +1,9 @@ +private mutation +replaceFrom: start to: stop with: replacement startingAt: repStart + " Use super with a private version of at:put:, as the actual one is not to be used" + + | index repOff | + repOff := repStart - start. + index := start - 1. + [(index := index + 1) <= stop] + whileTrue: [self pvtAt: index put: (replacement at: repOff + index)] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/reversed.st b/repository/ImmutableObjects.package/Vector.class/instance/reversed.st new file mode 100644 index 00000000..505317b5 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/reversed.st @@ -0,0 +1,6 @@ +converting +reversed + + ^ self class newFrom: + (self species new: self size streamContents: [:aStream| + self reverseDo: [:each | aStream nextPut: each]]) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/select..st b/repository/ImmutableObjects.package/Vector.class/instance/select..st new file mode 100644 index 00000000..4b5501a8 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/select..st @@ -0,0 +1,4 @@ +enumerating +select: aBlock + + ^ self class newFrom: (super select: aBlock) \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sort..st b/repository/ImmutableObjects.package/Vector.class/instance/sort..st new file mode 100644 index 00000000..ec421574 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sort..st @@ -0,0 +1,4 @@ +unsupported mutation +sort: aBlock + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sort.st b/repository/ImmutableObjects.package/Vector.class/instance/sort.st new file mode 100644 index 00000000..7726e8aa --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sort.st @@ -0,0 +1,4 @@ +unsupported mutation +sort + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sorted..st b/repository/ImmutableObjects.package/Vector.class/instance/sorted..st new file mode 100644 index 00000000..e896798d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sorted..st @@ -0,0 +1,4 @@ +sorting +sorted: aBlock + + self flag: #topa. "what do?" \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/sorted.st b/repository/ImmutableObjects.package/Vector.class/instance/sorted.st new file mode 100644 index 00000000..6aaf291d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/sorted.st @@ -0,0 +1,4 @@ +sorting +sorted + + self flag: #topa. "what do?" \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/species.st b/repository/ImmutableObjects.package/Vector.class/instance/species.st new file mode 100644 index 00000000..79599a8f --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/species.st @@ -0,0 +1,4 @@ +private +species + + ^ Array \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/instance/swap.with..st b/repository/ImmutableObjects.package/Vector.class/instance/swap.with..st new file mode 100644 index 00000000..b49a6246 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/instance/swap.with..st @@ -0,0 +1,4 @@ +unsupported mutation +swap: oneIndex with: anotherIndex + + self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Vector.class/methodProperties.json b/repository/ImmutableObjects.package/Vector.class/methodProperties.json new file mode 100644 index 00000000..9a6c5e99 --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/methodProperties.json @@ -0,0 +1,46 @@ +{ + "class" : { + "new" : "topa 12/5/2016 09:32", + "new:" : "topa 12/5/2016 09:29", + "new:withAll:" : "topa 12/5/2016 09:33", + "newFrom:" : "topa 12/5/2016 09:40", + "newFromStream:" : "topa 12/5/2016 09:35", + "primImmutableFrom:" : "topa 12/5/2016 09:45", + "with:" : "topa 12/5/2016 09:37", + "with:with:" : "topa 12/5/2016 09:37", + "with:with:with:" : "topa 12/5/2016 09:37", + "with:with:with:with:" : "topa 12/5/2016 09:38", + "with:with:with:with:with:" : "topa 12/5/2016 09:38", + "with:with:with:with:with:with:" : "topa 12/5/2016 09:38", + "withAll:" : "topa 12/5/2016 09:41" }, + "instance" : { + "," : "topa 12/5/2016 15:53", + "at:incrementBy:" : "topa 12/5/2016 15:12", + "atAll:put:" : "topa 12/5/2016 15:12", + "atAll:putAll:" : "topa 12/5/2016 15:12", + "atAllPut:" : "topa 12/5/2016 15:12", + "atLast:put:" : "topa 12/5/2016 15:13", + "atWrap:put:" : "topa 12/5/2016 15:14", + "collect:" : "topa 12/5/2016 16:17", + "collect:from:to:" : "topa 12/5/2016 16:17", + "copyEmpty" : "topa 12/5/2016 15:39", + "copyFrom:to:" : "topa 12/5/2016 15:55", + "copyReplaceFrom:to:with:" : "topa 12/5/2016 16:03", + "copyWith:" : "topa 12/5/2016 16:06", + "copyWithFirst:" : "topa 12/5/2016 16:05", + "copyWithoutIndex:" : "topa 12/5/2016 16:07", + "from:to:put:" : "topa 12/5/2016 16:10", + "grownBy:" : "topa 12/5/2016 16:10", + "integerAt:put:" : "topa 12/5/2016 16:10", + "pvtAt:put:" : "topa 12/5/2016 15:35", + "replace:" : "topa 12/5/2016 16:12", + "replaceAll:with:" : "topa 12/5/2016 16:12", + "replaceFrom:to:with:startingAt:" : "topa 12/5/2016 15:34", + "reversed" : "topa 12/5/2016 16:14", + "select:" : "topa 12/5/2016 16:15", + "sort" : "topa 12/5/2016 15:36", + "sort:" : "topa 12/5/2016 15:36", + "sorted" : "topa 12/5/2016 15:36", + "sorted:" : "topa 12/5/2016 15:36", + "species" : "topa 12/5/2016 15:38", + "swap:with:" : "topa 12/5/2016 16:16" } } diff --git a/repository/ImmutableObjects.package/Vector.class/properties.json b/repository/ImmutableObjects.package/Vector.class/properties.json new file mode 100644 index 00000000..45083c5d --- /dev/null +++ b/repository/ImmutableObjects.package/Vector.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-Structures", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "Vector", + "pools" : [ + ], + "super" : "ArrayedCollection", + "type" : "variable" } diff --git a/repository/ImmutableObjects.package/monticello.meta/categories.st b/repository/ImmutableObjects.package/monticello.meta/categories.st index 8d8b9e78..7ef2a65d 100644 --- a/repository/ImmutableObjects.package/monticello.meta/categories.st +++ b/repository/ImmutableObjects.package/monticello.meta/categories.st @@ -1 +1,2 @@ -SystemOrganization addCategory: #ImmutableObjects! +SystemOrganization addCategory: #'ImmutableObjects-Structures'! +SystemOrganization addCategory: #'ImmutableObjects-Tests'! diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 16f8d6f4..71a3306b 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 9155f740291a1f42c71e334e4d71e868ed879810 Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Mon, 5 Dec 2016 17:52:58 +0100 Subject: [PATCH 26/63] Allow immutable objects created from stack contents That is, initialize them with all arguments to the primitive message send --- rsqueakvm/plugins/immutability_plugin.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 69353be5..0f4166fd 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -121,6 +121,24 @@ def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): raise PrimitiveFailedError +@ImmutabilityPlugin.expose_primitive(unwrap_spec=None) +def primitiveImmutableFromArgs(interp, s_frame, argcount): + + w_arguments = s_frame.pop_and_return_n(argcount)[:] + w_cls = s_frame.pop() + space = interp.space + instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() + + if instance_kind == POINTERS: + return W_PointersObject.immutable_subclass(space, w_cls, w_arguments) + # TBD: + # elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): + # return W_BytesObject.immutable_subclass(space, w_cls, w_obj.bytes) + # elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): + # return W_WordsObject.immutable_subclass(space, w_cls, w_obj.words) + + raise PrimitiveFailedError + @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) def primitiveIsImmutable(interp, s_frame, w_recv): From 44d6e812af2d2730e1f30d00859b56df520ed4ab Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Tue, 6 Dec 2016 16:54:01 +0100 Subject: [PATCH 27/63] Fix cons, add Benchmarks (needs benches package, pls split :)) --- .../Cons.class/class/withAll..st | 7 +++++++ .../Cons.class/instance/at..st | 4 ++++ .../Cons.class/instance/at.ifAbsent..st | 7 +++++++ .../Cons.class/instance/detect.ifNone..st | 4 ++++ .../Cons.class/instance/first.st | 4 ++++ .../Cons.class/instance/isEmpty.st | 4 ++++ .../Cons.class/instance/last.st | 6 ++++++ .../Cons.class/instance/size.st | 4 ++++ .../Cons.class/methodProperties.json | 10 +++++++++- .../Cons.class/properties.json | 2 +- .../ConsNanoBenchmark.class/README.md | 0 .../instance/classUnderBenching.st | 4 ++++ .../instance/consWith.though..st | 6 ++++++ .../instance/createCharacterListOfSize..st | 6 ++++++ .../instance/createMixedListOfSize..st | 13 +++++++++++++ .../instance/createNumberListOfSize..st | 6 ++++++ .../instance/createObjectListOfSize..st | 6 ++++++ .../ConsNanoBenchmark.class/methodProperties.json | 10 ++++++++++ .../ConsNanoBenchmark.class/properties.json | 14 ++++++++++++++ .../monticello.meta/categories.st | 1 + .../monticello.meta/version | 2 +- 21 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 repository/ImmutableObjects.package/Cons.class/class/withAll..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/at..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/first.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/last.st create mode 100644 repository/ImmutableObjects.package/Cons.class/instance/size.st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/README.md create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json diff --git a/repository/ImmutableObjects.package/Cons.class/class/withAll..st b/repository/ImmutableObjects.package/Cons.class/class/withAll..st new file mode 100644 index 00000000..c2b83faf --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/class/withAll..st @@ -0,0 +1,7 @@ +as yet unclassified +withAll: aCollection + + ^ aCollection + ifEmpty: [nil] + ifNotEmpty: [:collection | + self car: collection first cdr: (self withAll: collection allButFirst)] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/at..st b/repository/ImmutableObjects.package/Cons.class/instance/at..st new file mode 100644 index 00000000..361aad8d --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/at..st @@ -0,0 +1,4 @@ +accessing +at: index + + ^ self at: index ifAbsent: [self errorSubscriptBounds: index] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st b/repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st new file mode 100644 index 00000000..ba8561df --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/at.ifAbsent..st @@ -0,0 +1,7 @@ +accessing +at: index ifAbsent: exceptionBlock + + | i | + index < 1 ifTrue: [^exceptionBlock value]. + i := 0. + ^ self findf: [:ea | (i := i + 1) = index] ifNone: exceptionBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st b/repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st new file mode 100644 index 00000000..e67a8f20 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/detect.ifNone..st @@ -0,0 +1,4 @@ +collection api +detect: aBlock ifNone: exceptionBlock + + self findf: aBlock ifNone: exceptionBlock \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/first.st b/repository/ImmutableObjects.package/Cons.class/instance/first.st new file mode 100644 index 00000000..e8ac84e1 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/first.st @@ -0,0 +1,4 @@ +accessing +first + + ^ self car \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st b/repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st new file mode 100644 index 00000000..cd367045 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/isEmpty.st @@ -0,0 +1,4 @@ +testing +isEmpty + + ^ false \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/last.st b/repository/ImmutableObjects.package/Cons.class/instance/last.st new file mode 100644 index 00000000..e264fe60 --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/last.st @@ -0,0 +1,6 @@ +accessing +last + + | prev | + prev := nil. + ^ self findf: [:ea | prev := ea. false "continue to end"] ifNone: [prev] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/instance/size.st b/repository/ImmutableObjects.package/Cons.class/instance/size.st new file mode 100644 index 00000000..8fb700fb --- /dev/null +++ b/repository/ImmutableObjects.package/Cons.class/instance/size.st @@ -0,0 +1,4 @@ +accessing +size + + ^ self count: [:ea | true] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/methodProperties.json b/repository/ImmutableObjects.package/Cons.class/methodProperties.json index 44c62c5a..cd3471a9 100644 --- a/repository/ImmutableObjects.package/Cons.class/methodProperties.json +++ b/repository/ImmutableObjects.package/Cons.class/methodProperties.json @@ -1,24 +1,31 @@ { "class" : { "car:cdr:" : "topa 12/5/2016 09:18", - "new" : "topa 12/5/2016 08:19" }, + "new" : "topa 12/5/2016 08:19", + "withAll:" : "topa 12/6/2016 16:29" }, "instance" : { "," : "topa 12/5/2016 16:41", "append:" : "topa 12/5/2016 16:30", "asCons" : "topa 12/5/2016 17:42", + "at:" : "topa 12/5/2016 21:52", + "at:ifAbsent:" : "topa 12/6/2016 16:43", "car" : "topa 12/5/2016 08:18", "cdr" : "topa 12/5/2016 08:18", "collect:" : "topa 12/5/2016 16:38", + "detect:ifNone:" : "topa 12/6/2016 16:34", "do:" : "topa 12/5/2016 17:34", "filter:" : "topa 12/5/2016 16:32", "findf:" : "topa 12/5/2016 17:31", "findf:ifNone:" : "topa 12/5/2016 17:31", + "first" : "topa 12/5/2016 21:52", "foldl:withInit:" : "topa 12/5/2016 17:15", "foldr:withInit:" : "topa 12/5/2016 17:19", "forEach:" : "topa 12/5/2016 17:34", "inject:into:" : "topa 12/5/2016 16:54", "innerPrintListOn:" : "topa 12/5/2016 09:25", "isCons" : "topa 12/5/2016 09:25", + "isEmpty" : "topa 12/5/2016 22:09", + "last" : "topa 12/5/2016 22:11", "map:" : "topa 12/5/2016 16:27", "printListOn:" : "topa 12/5/2016 09:22", "printOn:" : "topa 12/5/2016 09:20", @@ -27,4 +34,5 @@ "reverse" : "topa 12/5/2016 16:33", "reverse:" : "topa 12/5/2016 16:36", "select:" : "topa 12/5/2016 16:41", + "size" : "topa 12/5/2016 21:46", "~" : "topa 12/5/2016 17:45" } } diff --git a/repository/ImmutableObjects.package/Cons.class/properties.json b/repository/ImmutableObjects.package/Cons.class/properties.json index c8251d73..5b687d23 100644 --- a/repository/ImmutableObjects.package/Cons.class/properties.json +++ b/repository/ImmutableObjects.package/Cons.class/properties.json @@ -11,5 +11,5 @@ "name" : "Cons", "pools" : [ ], - "super" : "Object", + "super" : "SequenceableCollection", "type" : "normal" } diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/README.md b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st new file mode 100644 index 00000000..a4217fe8 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st @@ -0,0 +1,4 @@ +as yet unclassified +classUnderBenching + + ^ Cons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st new file mode 100644 index 00000000..54e1d6df --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st @@ -0,0 +1,6 @@ +as yet unclassified +consWith: aBlock though: aNumber + + ^ aNumber = 0 + ifTrue: [nil] + ifFalse: [Cons car: (aBlock cull: aNumber) cdr: (self consWith: aBlock though: (aNumber - 1))] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st new file mode 100644 index 00000000..7d89d12f --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -0,0 +1,6 @@ +as yet unclassified +createCharacterListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self consWith: [($a to: $z) atRandom: rng] though: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st new file mode 100644 index 00000000..b7df21ac --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st @@ -0,0 +1,13 @@ +as yet unclassified +createMixedListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self + consWith: [ + | roll | + roll := 3 atRandom: rng. + roll = 1 ifTrue: [rng nextInt: aNumber] ifFalse: [ + roll = 2 ifTrue: [($a to: $z) atRandom: rng] ifFalse: [ + roll = 3 ifTrue: [Box new value: (rng nextInt: aNumber)]]]] + though: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st new file mode 100644 index 00000000..b8b23e78 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st @@ -0,0 +1,6 @@ +as yet unclassified +createNumberListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self consWith: [rng nextInt: aNumber] though: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st new file mode 100644 index 00000000..45319061 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st @@ -0,0 +1,6 @@ +as yet unclassified +createObjectListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self consWith: [Box new value: (rng nextInt: aNumber)] though: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json new file mode 100644 index 00000000..d810f276 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json @@ -0,0 +1,10 @@ +{ + "class" : { + }, + "instance" : { + "classUnderBenching" : "topa 12/6/2016 16:16", + "consWith:though:" : "topa 12/6/2016 16:24", + "createCharacterListOfSize:" : "topa 12/6/2016 16:24", + "createMixedListOfSize:" : "topa 12/6/2016 16:24", + "createNumberListOfSize:" : "topa 12/6/2016 16:24", + "createObjectListOfSize:" : "topa 12/6/2016 16:24" } } diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json new file mode 100644 index 00000000..ca231639 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-ListNanos", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "ConsNanoBenchmark", + "pools" : [ + ], + "super" : "CollectionNanoBenchmark", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/categories.st b/repository/ImmutableObjects.package/monticello.meta/categories.st index 7ef2a65d..e9a37e83 100644 --- a/repository/ImmutableObjects.package/monticello.meta/categories.st +++ b/repository/ImmutableObjects.package/monticello.meta/categories.st @@ -1,2 +1,3 @@ +SystemOrganization addCategory: #'ImmutableObjects-ListNanos'! SystemOrganization addCategory: #'ImmutableObjects-Structures'! SystemOrganization addCategory: #'ImmutableObjects-Tests'! diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 71a3306b..c2c84e2e 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 29ba1eae5e196aef9aeadb01c28ca1323e456de9 Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Tue, 6 Dec 2016 16:56:44 +0100 Subject: [PATCH 28/63] Fix prefixes --- .../instance/createMixedListOfSize..st | 2 +- .../instance/createObjectListOfSize..st | 2 +- .../ConsNanoBenchmark.class/methodProperties.json | 4 ++-- .../ConsNanoBenchmark.class/properties.json | 2 +- repository/ImmutableObjects.package/monticello.meta/version | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st index b7df21ac..31c3389e 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st @@ -9,5 +9,5 @@ createMixedListOfSize: aNumber roll := 3 atRandom: rng. roll = 1 ifTrue: [rng nextInt: aNumber] ifFalse: [ roll = 2 ifTrue: [($a to: $z) atRandom: rng] ifFalse: [ - roll = 3 ifTrue: [Box new value: (rng nextInt: aNumber)]]]] + roll = 3 ifTrue: [SMarkBox new value: (rng nextInt: aNumber)]]]] though: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st index 45319061..97458344 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st @@ -3,4 +3,4 @@ createObjectListOfSize: aNumber | rng | rng := Random seed: 36rSQUEAKSMALLTALK. - self consWith: [Box new value: (rng nextInt: aNumber)] though: aNumber \ No newline at end of file + self consWith: [SMarkBox new value: (rng nextInt: aNumber)] though: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json index d810f276..ede1cb0f 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json @@ -5,6 +5,6 @@ "classUnderBenching" : "topa 12/6/2016 16:16", "consWith:though:" : "topa 12/6/2016 16:24", "createCharacterListOfSize:" : "topa 12/6/2016 16:24", - "createMixedListOfSize:" : "topa 12/6/2016 16:24", + "createMixedListOfSize:" : "topa 12/6/2016 16:55", "createNumberListOfSize:" : "topa 12/6/2016 16:24", - "createObjectListOfSize:" : "topa 12/6/2016 16:24" } } + "createObjectListOfSize:" : "topa 12/6/2016 16:55" } } diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json index ca231639..dd8b8051 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/properties.json @@ -10,5 +10,5 @@ "name" : "ConsNanoBenchmark", "pools" : [ ], - "super" : "CollectionNanoBenchmark", + "super" : "SMarkCollectionNanoBenchmark", "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index c2c84e2e..41379f2f 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 17a82fcc060443b7686ef86c5db1a53e00d4ff4c Mon Sep 17 00:00:00 2001 From: Tobias Pape Date: Wed, 4 Jan 2017 11:38:45 +0100 Subject: [PATCH 29/63] Don't stress the stack so much on Cons creation --- .../Cons.class/class/withAll..st | 9 +++++++-- .../Cons.class/methodProperties.json | 2 +- .../ImmutableObjects.package/monticello.meta/version | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/repository/ImmutableObjects.package/Cons.class/class/withAll..st b/repository/ImmutableObjects.package/Cons.class/class/withAll..st index c2b83faf..20c9d918 100644 --- a/repository/ImmutableObjects.package/Cons.class/class/withAll..st +++ b/repository/ImmutableObjects.package/Cons.class/class/withAll..st @@ -1,7 +1,12 @@ as yet unclassified withAll: aCollection - ^ aCollection +" ^ aCollection ifEmpty: [nil] ifNotEmpty: [:collection | - self car: collection first cdr: (self withAll: collection allButFirst)] \ No newline at end of file + self car: collection first cdr: (self withAll: collection allButFirst)] +" + | list | + list := nil. + aCollection reverseDo: [:each | list := Cons car: each cdr: list]. + ^ list diff --git a/repository/ImmutableObjects.package/Cons.class/methodProperties.json b/repository/ImmutableObjects.package/Cons.class/methodProperties.json index cd3471a9..a9d9b2a8 100644 --- a/repository/ImmutableObjects.package/Cons.class/methodProperties.json +++ b/repository/ImmutableObjects.package/Cons.class/methodProperties.json @@ -2,7 +2,7 @@ "class" : { "car:cdr:" : "topa 12/5/2016 09:18", "new" : "topa 12/5/2016 08:19", - "withAll:" : "topa 12/6/2016 16:29" }, + "withAll:" : "topa 1/4/2017 11:34" }, "instance" : { "," : "topa 12/5/2016 16:41", "append:" : "topa 12/5/2016 16:30", diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 41379f2f..9a336481 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 881d85f216e30e61a8586905f0be05e4bd17f846 Mon Sep 17 00:00:00 2001 From: jchromik Date: Thu, 5 Jan 2017 17:07:30 +0100 Subject: [PATCH 30/63] create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:) --- .../class/defaultProblemSize.st | 4 ++++ .../{consWith.though..st => consWith.through..st} | 4 ++-- .../instance/createCharacterListOfSize..st | 2 +- .../instance/createMixedListOfSize..st | 2 +- .../instance/createNumberListOfSize..st | 2 +- .../instance/createObjectListOfSize..st | 2 +- .../ConsNanoBenchmark.class/methodProperties.json | 12 ++++++------ .../VectorNanoBenchmark.class/README.md | 0 .../class/defaultProblemSize.st | 4 ++++ .../instance/classUnderBenching.st | 4 ++++ .../instance/createCharacterListOfSize..st | 6 ++++++ .../instance/createMixedListOfSize..st | 13 +++++++++++++ .../instance/createNumberListOfSize..st | 6 ++++++ .../instance/createObjectListOfSize..st | 6 ++++++ .../instance/vector.with.through..st | 6 ++++++ .../instance/vectorWith.through..st | 4 ++++ .../methodProperties.json | 11 +++++++++++ .../VectorNanoBenchmark.class/properties.json | 14 ++++++++++++++ .../monticello.meta/version | 2 +- 19 files changed, 91 insertions(+), 13 deletions(-) create mode 100644 repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st rename repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/{consWith.though..st => consWith.through..st} (63%) create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/README.md create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json create mode 100644 repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st new file mode 100644 index 00000000..abcff658 --- /dev/null +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st @@ -0,0 +1,4 @@ +as yet unclassified +defaultProblemSize + + ^ 1000 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st similarity index 63% rename from repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st rename to repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st index 54e1d6df..fd59aad5 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.though..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st @@ -1,6 +1,6 @@ as yet unclassified -consWith: aBlock though: aNumber +consWith: aBlock through: aNumber ^ aNumber = 0 ifTrue: [nil] - ifFalse: [Cons car: (aBlock cull: aNumber) cdr: (self consWith: aBlock though: (aNumber - 1))] \ No newline at end of file + ifFalse: [Cons car: (aBlock cull: aNumber) cdr: (self consWith: aBlock through: (aNumber - 1))] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st index 7d89d12f..c6f27c4c 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -3,4 +3,4 @@ createCharacterListOfSize: aNumber | rng | rng := Random seed: 36rSQUEAKSMALLTALK. - self consWith: [($a to: $z) atRandom: rng] though: aNumber \ No newline at end of file + self consWith: [($a to: $z) atRandom: rng] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st index 31c3389e..13340c25 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st @@ -10,4 +10,4 @@ createMixedListOfSize: aNumber roll = 1 ifTrue: [rng nextInt: aNumber] ifFalse: [ roll = 2 ifTrue: [($a to: $z) atRandom: rng] ifFalse: [ roll = 3 ifTrue: [SMarkBox new value: (rng nextInt: aNumber)]]]] - though: aNumber \ No newline at end of file + through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st index b8b23e78..1067de75 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st @@ -3,4 +3,4 @@ createNumberListOfSize: aNumber | rng | rng := Random seed: 36rSQUEAKSMALLTALK. - self consWith: [rng nextInt: aNumber] though: aNumber \ No newline at end of file + self consWith: [rng nextInt: aNumber] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st index 97458344..c026b92b 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st @@ -3,4 +3,4 @@ createObjectListOfSize: aNumber | rng | rng := Random seed: 36rSQUEAKSMALLTALK. - self consWith: [SMarkBox new value: (rng nextInt: aNumber)] though: aNumber \ No newline at end of file + self consWith: [SMarkBox new value: (rng nextInt: aNumber)] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json index ede1cb0f..5593410e 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/methodProperties.json @@ -1,10 +1,10 @@ { "class" : { - }, + "defaultProblemSize" : "jc 1/5/2017 16:25" }, "instance" : { "classUnderBenching" : "topa 12/6/2016 16:16", - "consWith:though:" : "topa 12/6/2016 16:24", - "createCharacterListOfSize:" : "topa 12/6/2016 16:24", - "createMixedListOfSize:" : "topa 12/6/2016 16:55", - "createNumberListOfSize:" : "topa 12/6/2016 16:24", - "createObjectListOfSize:" : "topa 12/6/2016 16:55" } } + "consWith:through:" : "jc 1/5/2017 16:51", + "createCharacterListOfSize:" : "jc 1/5/2017 16:51", + "createMixedListOfSize:" : "jc 1/5/2017 16:51", + "createNumberListOfSize:" : "jc 1/5/2017 16:51", + "createObjectListOfSize:" : "jc 1/5/2017 16:51" } } diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/README.md b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/README.md new file mode 100644 index 00000000..e69de29b diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st new file mode 100644 index 00000000..abcff658 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st @@ -0,0 +1,4 @@ +as yet unclassified +defaultProblemSize + + ^ 1000 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st new file mode 100644 index 00000000..de75c791 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st @@ -0,0 +1,4 @@ +as yet unclassified +classUnderBenching + + ^ Vector \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st new file mode 100644 index 00000000..59b2cc3d --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -0,0 +1,6 @@ +as yet unclassified +createCharacterListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self vectorWith: [($a to: $z) atRandom: rng] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st new file mode 100644 index 00000000..ccebac57 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st @@ -0,0 +1,13 @@ +as yet unclassified +createMixedListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self + vectorWith: [ + | roll | + roll := 3 atRandom: rng. + roll = 1 ifTrue: [rng nextInt: aNumber] ifFalse: [ + roll = 2 ifTrue: [($a to: $z) atRandom: rng] ifFalse: [ + roll = 3 ifTrue: [SMarkBox new value: (rng nextInt: aNumber)]]]] + through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st new file mode 100644 index 00000000..af3e4a5e --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st @@ -0,0 +1,6 @@ +as yet unclassified +createNumberListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self vectorWith: [rng nextInt: aNumber] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st new file mode 100644 index 00000000..2faec538 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st @@ -0,0 +1,6 @@ +as yet unclassified +createObjectListOfSize: aNumber + + | rng | + rng := Random seed: 36rSQUEAKSMALLTALK. + self vectorWith: [SMarkBox new value: (rng nextInt: aNumber)] through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st new file mode 100644 index 00000000..e3916976 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st @@ -0,0 +1,6 @@ +as yet unclassified +vector: aVector with: aBlock through: aNumber + + ^ aNumber = 0 + ifTrue: [aVector] + ifFalse: [self vector: (aVector copyWith: aBlock value) with: aBlock through: (aNumber - 1)] \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st new file mode 100644 index 00000000..3a35f709 --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st @@ -0,0 +1,4 @@ +as yet unclassified +vectorWith: aBlock through: aNumber + + ^ self vector: Vector new with: aBlock through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json new file mode 100644 index 00000000..0e08a91b --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/methodProperties.json @@ -0,0 +1,11 @@ +{ + "class" : { + "defaultProblemSize" : "jc 1/5/2017 16:29" }, + "instance" : { + "classUnderBenching" : "jc 1/5/2017 16:30", + "createCharacterListOfSize:" : "jc 1/5/2017 17:01", + "createMixedListOfSize:" : "jc 1/5/2017 17:02", + "createNumberListOfSize:" : "jc 1/5/2017 17:04", + "createObjectListOfSize:" : "jc 1/5/2017 17:05", + "vector:with:through:" : "jc 1/5/2017 16:57", + "vectorWith:through:" : "jc 1/5/2017 16:54" } } diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json new file mode 100644 index 00000000..6c73403d --- /dev/null +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/properties.json @@ -0,0 +1,14 @@ +{ + "category" : "ImmutableObjects-ListNanos", + "classinstvars" : [ + ], + "classvars" : [ + ], + "commentStamp" : "", + "instvars" : [ + ], + "name" : "VectorNanoBenchmark", + "pools" : [ + ], + "super" : "SMarkCollectionNanoBenchmark", + "type" : "normal" } diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 9a336481..b95e212d 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 8059e70eb7cbbbf0f294a387dd905c32abe2d357 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 2 Feb 2017 11:48:57 +0100 Subject: [PATCH 31/63] Add immutable W_PointersObject cls w/ fixed size --- rsqueakvm/plugins/immutability_plugin.py | 122 ++++++++++++++++++----- 1 file changed, 99 insertions(+), 23 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 0f4166fd..71f70856 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -1,9 +1,15 @@ from rsqueakvm.error import PrimitiveFailedError from rsqueakvm.model import * from rsqueakvm.plugins.plugin import Plugin -from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS +from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS, ClassShadow + +from rpython.rlib import jit, rerased +from rpython.rlib.unroll import unrolling_iterable + +""" +Documentation goes here. +""" -from rpython.rlib import jit ImmutabilityPlugin = Plugin() @@ -17,6 +23,7 @@ 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', 'setbytes', 'mutate' ] +STORAGE_ATTR_TEMPLATE = "storage_%d" def immutable_class(cls): @@ -32,32 +39,85 @@ def noop(self, *args): return cls -def _add_immutable_w_pointersobject_subclass(): - @immutable_class - class W_PointersObject_Immutable(W_PointersObject): - _attrs_ = ['storage', 'w_class', '_instsize'] - _immutable_fields_ = ['storage[*]', '_instsize'] - repr_classname = '%s_Immutable' % W_PointersObject.repr_classname +@immutable_class +class W_PointersObject_AbstractImmutable(W_PointersObject): + _attrs_ = [] + _immutable_fields_ = [] + repr_classname = ('%s_AbstractImmutable' % + W_PointersObject.repr_classname) - def __init__(self, space, w_cls, pointers_w): - W_AbstractObjectWithIdentityHash.__init__(self) - self.w_class = w_cls - self.storage = pointers_w - self._instsize = self.w_class.as_class_get_shadow(space).instsize() + def __init__(self, space, w_cls): + W_AbstractObjectWithIdentityHash.__init__(self) + # reuse strategy var to store cls + self.strategy = w_cls.as_class_get_shadow(space) - def getclass(self, space): - return self.w_class + def getclass(self, space): + return self.strategy.w_self() + + def class_shadow(self, space): + class_shadow = self.strategy + assert isinstance(class_shadow, ClassShadow) + return class_shadow + + def size(self): + raise NotImplementedError + + def fetch(self, space, n0): + raise NotImplementedError - def size(self): - return len(self.storage) - def instsize(self): - return self._instsize +def _generate_fixed_w_pointersobject_class(n_storage): + + storage_iter = unrolling_iterable(range(n_storage)) + cls_name = '%s_Immutable_%s' % (W_PointersObject.repr_classname, n_storage) + + class W_PointersObject_Immutable_Fixed(W_PointersObject_AbstractImmutable): + _storages_ = [(STORAGE_ATTR_TEMPLATE % x) for x in storage_iter] + _attrs_ = _storages_ + _immutable_fields_ = _storages_ + repr_classname = cls_name + + def __init__(self, space, w_cls, pointers_w): + W_PointersObject_AbstractImmutable.__init__(self, space, w_cls) + for x in storage_iter: + setattr(self, STORAGE_ATTR_TEMPLATE % x, pointers_w[x]) + + def size(self): + return n_storage def fetch(self, space, n0): + for x in storage_iter: + if x == n0: + return getattr(self, STORAGE_ATTR_TEMPLATE % x) + raise IndexError return self.storage[n0] - W_PointersObject.immutable_subclass = W_PointersObject_Immutable + W_PointersObject_Immutable_Fixed.__name__ = cls_name + + return W_PointersObject_Immutable_Fixed + + +def _immutable_w_pointersobject_subclass(): + class W_PointersObject_Immutable_N(W_PointersObject_AbstractImmutable): + _immutable_fields_ = ['_storage[*]'] + repr_classname = '%s_Immutable_N' % W_PointersObject.repr_classname + erase, unerase = rerased.new_erasing_pair('storage_eraser') + + def __init__(self, space, w_cls, pointers_w): + W_PointersObject_AbstractImmutable.__init__(self, space, w_cls) + self._storage = self.erase(pointers_w) + + def size(self): + return len(self.unerase(self._storage)) + + def fetch(self, space, n0): + return self.unerase(self._storage)[n0] + + classes = [] + for n_storage in range(0, 10): + classes.append(_generate_fixed_w_pointersobject_class(n_storage)) + classes.append(W_PointersObject_Immutable_N) + return classes def _add_immutable_w_bytesobject_subclass(): @@ -101,7 +161,20 @@ def is_immutable(self): W_Object.is_immutable = is_immutable _patch_w_object() -_add_immutable_w_pointersobject_subclass() + +pointers_classes = _immutable_w_pointersobject_subclass() +pointers_class_iter = unrolling_iterable(enumerate(pointers_classes)) + + +def select_pointers_class(storage): + length = len(storage) + for i, cls in pointers_class_iter: + if i == length: + return cls + # otherwise: + return pointers_classes[-1] + + _add_immutable_w_bytesobject_subclass() _add_immutable_w_wordsobject_subclass() @@ -113,7 +186,8 @@ def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): if instance_kind == POINTERS: pointers = w_obj.fetch_all(space) - return W_PointersObject.immutable_subclass(space, w_cls, pointers) + cls = select_pointers_class(pointers) + return cls(space, w_cls, pointers) elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): return W_BytesObject.immutable_subclass(space, w_cls, w_obj.bytes) elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): @@ -121,6 +195,7 @@ def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): raise PrimitiveFailedError + @ImmutabilityPlugin.expose_primitive(unwrap_spec=None) def primitiveImmutableFromArgs(interp, s_frame, argcount): @@ -130,7 +205,8 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() if instance_kind == POINTERS: - return W_PointersObject.immutable_subclass(space, w_cls, w_arguments) + cls = select_pointers_class(w_arguments) + return cls(space, w_cls, w_arguments) # TBD: # elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): # return W_BytesObject.immutable_subclass(space, w_cls, w_obj.bytes) From 7e686177ebdcabc0eb25617accf2ae1b453cf644 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 2 Feb 2017 11:52:26 +0100 Subject: [PATCH 32/63] Add doc badge [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ee255ae..690eaf53 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## RSqueak/VM [![Linux Build Status](https://travis-ci.org/HPI-SWA-Lab/RSqueak.svg?branch=master)](https://travis-ci.org/HPI-SWA-Lab/RSqueak) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/e37a79tt5irr7sx1/branch/master?svg=true)](https://ci.appveyor.com/project/timfel/rsqueak) [![Coverage Status](https://coveralls.io/repos/github/HPI-SWA-Lab/RSqueak/badge.svg?branch=master)](https://coveralls.io/github/HPI-SWA-Lab/RSqueak?branch=master) [![Benchmarks](https://img.shields.io/badge/benchmarks-open-yellowgreen.svg)](http://speed.squeak.org/) +## RSqueak/VM [![Linux Build Status](https://travis-ci.org/HPI-SWA-Lab/RSqueak.svg?branch=master)](https://travis-ci.org/HPI-SWA-Lab/RSqueak) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/e37a79tt5irr7sx1/branch/master?svg=true)](https://ci.appveyor.com/project/timfel/rsqueak) [![Coverage Status](https://coveralls.io/repos/github/HPI-SWA-Lab/RSqueak/badge.svg?branch=master)](https://coveralls.io/github/HPI-SWA-Lab/RSqueak?branch=master) [![Benchmarks](https://img.shields.io/badge/benchmarks-open-yellowgreen.svg)](http://speed.squeak.org/) [![Documentation Status](https://readthedocs.org/projects/rsqueak/badge/?version=latest)](http://rsqueak.readthedocs.io/en/latest/?badge=latest) A Squeak VM written in RPython. From 73ff7e13b3f510ae1265f3c8172bda86f281ec2f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 11:03:38 +0100 Subject: [PATCH 33/63] Add immutability_plugin as automodule [ci skip] --- docs/rsqueakvm.plugins.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/rsqueakvm.plugins.rst b/docs/rsqueakvm.plugins.rst index 3b542b05..994ac48f 100644 --- a/docs/rsqueakvm.plugins.rst +++ b/docs/rsqueakvm.plugins.rst @@ -28,6 +28,14 @@ rsqueakvm.plugins.file_plugin module :undoc-members: :show-inheritance: +rsqueakvm.plugins.immutability_plugin module +-------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability_plugin + :members: + :undoc-members: + :show-inheritance: + rsqueakvm.plugins.large_integers module --------------------------------------- From 287c5fcda45d9c4b59e201808e92843e00158035 Mon Sep 17 00:00:00 2001 From: jchromik Date: Wed, 8 Feb 2017 12:45:16 +0100 Subject: [PATCH 34/63] documentation for immutability plugin primitives --- rsqueakvm/plugins/immutability_plugin.py | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 71f70856..141cf0f6 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -181,6 +181,16 @@ def select_pointers_class(storage): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): + """ + Creates an immutable copy of a Smalltalk object. + + :param interp: The interpreter proxy. + :param s_frame: The stack frame. + :param w_cls: The imutable objects target class. + :param w_obj: The Smalltalk object to produce an immutable copy from. + :returns: Immutable copy of w_obj with class w_cls. + :raises: PrimitiveFailedError + """ space = interp.space instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() @@ -198,7 +208,15 @@ def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): @ImmutabilityPlugin.expose_primitive(unwrap_spec=None) def primitiveImmutableFromArgs(interp, s_frame, argcount): - + """ + Creates an immutable object with class and arguments from stack frame. + + :param interp: The interpreter proxy. + :param s_frame: The stack frame. + :param argcount: The number of arguments. + :returns: Immutable object with class and arguments from stack frame. + :raises: PrimitiveFailedError + """ w_arguments = s_frame.pop_and_return_n(argcount)[:] w_cls = s_frame.pop() space = interp.space @@ -218,6 +236,15 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) def primitiveIsImmutable(interp, s_frame, w_recv): + """ + Tests if w_recv is immutable. + + :param interp: The interpreter proxy. + :param s_frame: The stack frame. + :param w_recv: The receiver object. + :returns: Return w_true if w_recv is immutable object. Returns w_false otherwise. + :raises: *nothing* + """ if w_recv.is_immutable(): return interp.space.w_true return interp.space.w_false From 55416e6cda2c0035860ed6298f851df9088eb7d3 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 12:48:04 +0100 Subject: [PATCH 35/63] Refactor ImmutabilityPlugin --- rsqueakvm/plugins/immutability/__init__.py | 0 rsqueakvm/plugins/immutability/bytes.py | 21 +++ rsqueakvm/plugins/immutability/pointers.py | 97 ++++++++++ rsqueakvm/plugins/immutability/utils.py | 39 ++++ rsqueakvm/plugins/immutability/words.py | 18 ++ rsqueakvm/plugins/immutability_plugin.py | 205 +++------------------ 6 files changed, 198 insertions(+), 182 deletions(-) create mode 100644 rsqueakvm/plugins/immutability/__init__.py create mode 100644 rsqueakvm/plugins/immutability/bytes.py create mode 100644 rsqueakvm/plugins/immutability/pointers.py create mode 100644 rsqueakvm/plugins/immutability/utils.py create mode 100644 rsqueakvm/plugins/immutability/words.py diff --git a/rsqueakvm/plugins/immutability/__init__.py b/rsqueakvm/plugins/immutability/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py new file mode 100644 index 00000000..0b658485 --- /dev/null +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -0,0 +1,21 @@ +from rsqueakvm.model.base import W_AbstractObjectWithClassReference +from rsqueakvm.model.variable import W_BytesObject +from rsqueakvm.plugins.immutability.utils import immutable_class + +from rpython.rlib import jit + + +@immutable_class +class W_Immutable_BytesObject(W_BytesObject): + repr_classname = '%s_Immutable' % W_BytesObject.repr_classname + + def __init__(self, space, w_cls, bytes_w): + W_AbstractObjectWithClassReference.__init__(self, space, w_cls) + self.bytes = bytes_w + + @jit.elidable + def _bytes(self): + return W_BytesObject._bytes(self) + + def _version(self): + return None diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py new file mode 100644 index 00000000..e378d344 --- /dev/null +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -0,0 +1,97 @@ +from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash +from rsqueakvm.model.pointers import W_PointersObject +from rsqueakvm.storage_classes import ClassShadow +from rsqueakvm.plugins.immutability.utils import immutable_class + +from rpython.rlib import rerased +from rpython.rlib.unroll import unrolling_iterable + +STORAGE_ATTR_TEMPLATE = "storage_%d" + + +@immutable_class +class W_AbstractImmutable_PointersObject(W_PointersObject): + _attrs_ = [] + _immutable_fields_ = [] + repr_classname = ('%s_AbstractImmutable' % + W_PointersObject.repr_classname) + + def __init__(self, space, w_cls): + W_AbstractObjectWithIdentityHash.__init__(self) + # reuse strategy var to store cls + self.strategy = w_cls.as_class_get_shadow(space) + + def getclass(self, space): + return self.strategy.w_self() + + def class_shadow(self, space): + class_shadow = self.strategy + assert isinstance(class_shadow, ClassShadow) + return class_shadow + + def size(self): + raise NotImplementedError + + def fetch(self, space, n0): + raise NotImplementedError + + +class W_Immutable_PointersObject(W_AbstractImmutable_PointersObject): + _immutable_fields_ = ['_storage[*]'] + repr_classname = '%s_Immutable_N' % W_PointersObject.repr_classname + erase, unerase = rerased.new_erasing_pair('storage_eraser') + + def __init__(self, space, w_cls, pointers_w): + W_AbstractImmutable_PointersObject.__init__(self, space, w_cls) + self._storage = self.erase(pointers_w) + + def size(self): + return len(self.unerase(self._storage)) + + def fetch(self, space, n0): + return self.unerase(self._storage)[n0] + + +def generate_fixed_w_pointersobject_class(n_storage): + storage_iter = unrolling_iterable(range(n_storage)) + cls_name = '%s_Immutable_%s' % (W_PointersObject.repr_classname, n_storage) + + class W_FixedImmutable_PointersObject(W_AbstractImmutable_PointersObject): + _storages_ = [(STORAGE_ATTR_TEMPLATE % x) for x in storage_iter] + _attrs_ = _storages_ + _immutable_fields_ = _storages_ + repr_classname = cls_name + + def __init__(self, space, w_cls, pointers_w): + W_AbstractImmutable_PointersObject.__init__(self, space, w_cls) + for x in storage_iter: + setattr(self, STORAGE_ATTR_TEMPLATE % x, pointers_w[x]) + + def size(self): + return n_storage + + def fetch(self, space, n0): + for x in storage_iter: + if x == n0: + return getattr(self, STORAGE_ATTR_TEMPLATE % x) + raise IndexError + return self.storage[n0] + + W_FixedImmutable_PointersObject.__name__ = cls_name + + return W_FixedImmutable_PointersObject + +pointers_classes = [] +for n_storage in range(0, 10): + pointers_classes.append(generate_fixed_w_pointersobject_class(n_storage)) +pointers_classes.append(W_Immutable_PointersObject) +pointers_class_iter = unrolling_iterable(enumerate(pointers_classes)) + + +def select_immutable_pointers_class(storage): + length = len(storage) + for i, cls in pointers_class_iter: + if i == length: + return cls + # otherwise: + return pointers_classes[-1] diff --git a/rsqueakvm/plugins/immutability/utils.py b/rsqueakvm/plugins/immutability/utils.py new file mode 100644 index 00000000..65b5e4d8 --- /dev/null +++ b/rsqueakvm/plugins/immutability/utils.py @@ -0,0 +1,39 @@ +from rsqueakvm.model.base import W_Object + +WRITE_OPERATIONS = [ + # W_Object + 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', + 'fillin_weak', 'fillin_finalize', + # W_PointersObject + 'pointers_become_one_way', + # W_BytesObject / W_WordsObject + 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', + 'setbytes', 'mutate' +] + + +def immutable_class(cls): + """ + This function does something. + + :param cls: The class. + :returns: int -- the return code. + :raises: AttributeError, KeyError + + """ + def is_immutable(self): + return True + cls.is_immutable = is_immutable + + for method_name in WRITE_OPERATIONS: + if hasattr(cls, method_name): + def noop(self, *args): + pass + setattr(cls, method_name, noop) + return cls + + +def patch_w_object(): + def is_immutable(self): + return False + W_Object.is_immutable = is_immutable diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py new file mode 100644 index 00000000..b3fe5cef --- /dev/null +++ b/rsqueakvm/plugins/immutability/words.py @@ -0,0 +1,18 @@ +from rsqueakvm.model.base import W_AbstractObjectWithClassReference +from rsqueakvm.model.variable import W_WordsObject +from rsqueakvm.plugins.immutability.utils import immutable_class + +from rpython.rlib import jit + + +@immutable_class +class W_Immutable_WordsObject(W_WordsObject): + repr_classname = '%s_Immutable' % W_WordsObject.repr_classname + + def __init__(self, space, w_cls, words_w): + W_AbstractObjectWithClassReference.__init__(self, space, w_cls) + self.words = words_w + + @jit.elidable + def _words(self): + return W_WordsObject._words(self) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 71f70856..2c0e4e72 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -1,182 +1,30 @@ -from rsqueakvm.error import PrimitiveFailedError -from rsqueakvm.model import * -from rsqueakvm.plugins.plugin import Plugin -from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS, ClassShadow - -from rpython.rlib import jit, rerased -from rpython.rlib.unroll import unrolling_iterable - """ Documentation goes here. -""" - - -ImmutabilityPlugin = Plugin() - -WRITE_OPERATIONS = [ - # W_Object - 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', - 'fillin_weak', 'fillin_finalize', - # W_PointersObject - 'pointers_become_one_way', - # W_BytesObject / W_WordsObject - 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', - 'setbytes', 'mutate' -] -STORAGE_ATTR_TEMPLATE = "storage_%d" - - -def immutable_class(cls): - def is_immutable(self): - return True - cls.is_immutable = is_immutable - - for method_name in WRITE_OPERATIONS: - if hasattr(cls, method_name): - def noop(self, *args): - pass - setattr(cls, method_name, noop) - return cls - - -@immutable_class -class W_PointersObject_AbstractImmutable(W_PointersObject): - _attrs_ = [] - _immutable_fields_ = [] - repr_classname = ('%s_AbstractImmutable' % - W_PointersObject.repr_classname) - - def __init__(self, space, w_cls): - W_AbstractObjectWithIdentityHash.__init__(self) - # reuse strategy var to store cls - self.strategy = w_cls.as_class_get_shadow(space) - - def getclass(self, space): - return self.strategy.w_self() - - def class_shadow(self, space): - class_shadow = self.strategy - assert isinstance(class_shadow, ClassShadow) - return class_shadow - - def size(self): - raise NotImplementedError - - def fetch(self, space, n0): - raise NotImplementedError - - -def _generate_fixed_w_pointersobject_class(n_storage): - - storage_iter = unrolling_iterable(range(n_storage)) - cls_name = '%s_Immutable_%s' % (W_PointersObject.repr_classname, n_storage) - - class W_PointersObject_Immutable_Fixed(W_PointersObject_AbstractImmutable): - _storages_ = [(STORAGE_ATTR_TEMPLATE % x) for x in storage_iter] - _attrs_ = _storages_ - _immutable_fields_ = _storages_ - repr_classname = cls_name - - def __init__(self, space, w_cls, pointers_w): - W_PointersObject_AbstractImmutable.__init__(self, space, w_cls) - for x in storage_iter: - setattr(self, STORAGE_ATTR_TEMPLATE % x, pointers_w[x]) - - def size(self): - return n_storage - - def fetch(self, space, n0): - for x in storage_iter: - if x == n0: - return getattr(self, STORAGE_ATTR_TEMPLATE % x) - raise IndexError - return self.storage[n0] - - W_PointersObject_Immutable_Fixed.__name__ = cls_name - - return W_PointersObject_Immutable_Fixed - - -def _immutable_w_pointersobject_subclass(): - class W_PointersObject_Immutable_N(W_PointersObject_AbstractImmutable): - _immutable_fields_ = ['_storage[*]'] - repr_classname = '%s_Immutable_N' % W_PointersObject.repr_classname - erase, unerase = rerased.new_erasing_pair('storage_eraser') - - def __init__(self, space, w_cls, pointers_w): - W_PointersObject_AbstractImmutable.__init__(self, space, w_cls) - self._storage = self.erase(pointers_w) - - def size(self): - return len(self.unerase(self._storage)) - - def fetch(self, space, n0): - return self.unerase(self._storage)[n0] - - classes = [] - for n_storage in range(0, 10): - classes.append(_generate_fixed_w_pointersobject_class(n_storage)) - classes.append(W_PointersObject_Immutable_N) - return classes - - -def _add_immutable_w_bytesobject_subclass(): - @immutable_class - class W_BytesObject_Immutable(W_BytesObject): - repr_classname = '%s_Immutable' % W_BytesObject.repr_classname - - def __init__(self, space, w_cls, bytes_w): - W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.bytes = bytes_w - - @jit.elidable - def _bytes(self): - return W_BytesObject._bytes(self) - - def _version(self): - return None - - W_BytesObject.immutable_subclass = W_BytesObject_Immutable - - -def _add_immutable_w_wordsobject_subclass(): - @immutable_class - class W_WordsObject_Immutable(W_WordsObject): - repr_classname = '%s_Immutable' % W_WordsObject.repr_classname - - def __init__(self, space, w_cls, words_w): - W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.words = words_w - - @jit.elidable - def _words(self): - return W_WordsObject._words(self) - - W_WordsObject.immutable_subclass = W_WordsObject_Immutable +""" -def _patch_w_object(): - def is_immutable(self): - return False - W_Object.is_immutable = is_immutable +from rsqueakvm.error import PrimitiveFailedError +from rsqueakvm.plugins.plugin import Plugin +from rsqueakvm.model.variable import W_BytesObject, W_WordsObject +from rsqueakvm.plugins.immutability.utils import patch_w_object -_patch_w_object() +from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS -pointers_classes = _immutable_w_pointersobject_subclass() -pointers_class_iter = unrolling_iterable(enumerate(pointers_classes)) +from rsqueakvm.plugins.immutability.bytes import W_Immutable_BytesObject +from rsqueakvm.plugins.immutability.pointers import ( + select_immutable_pointers_class) +from rsqueakvm.plugins.immutability.words import W_Immutable_WordsObject -def select_pointers_class(storage): - length = len(storage) - for i, cls in pointers_class_iter: - if i == length: - return cls - # otherwise: - return pointers_classes[-1] +ImmutabilityPlugin = Plugin() +patch_w_object() -_add_immutable_w_bytesobject_subclass() -_add_immutable_w_wordsobject_subclass() +@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) +def primitiveIsImmutable(interp, s_frame, w_recv): + if w_recv.is_immutable(): + return interp.space.w_true + return interp.space.w_false @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) @@ -186,12 +34,12 @@ def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): if instance_kind == POINTERS: pointers = w_obj.fetch_all(space) - cls = select_pointers_class(pointers) + cls = select_immutable_pointers_class(pointers) return cls(space, w_cls, pointers) elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): - return W_BytesObject.immutable_subclass(space, w_cls, w_obj.bytes) + return W_Immutable_BytesObject(space, w_cls, w_obj.bytes) elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): - return W_WordsObject.immutable_subclass(space, w_cls, w_obj.words) + return W_Immutable_WordsObject(space, w_cls, w_obj.words) raise PrimitiveFailedError @@ -205,19 +53,12 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() if instance_kind == POINTERS: - cls = select_pointers_class(w_arguments) + cls = select_immutable_pointers_class(w_arguments) return cls(space, w_cls, w_arguments) # TBD: # elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): - # return W_BytesObject.immutable_subclass(space, w_cls, w_obj.bytes) + # return W_Immutable_BytesObject(space, w_cls, w_obj.bytes) # elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): - # return W_WordsObject.immutable_subclass(space, w_cls, w_obj.words) + # return W_Immutable_WordsObject(space, w_cls, w_obj.words) raise PrimitiveFailedError - - -@ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) -def primitiveIsImmutable(interp, s_frame, w_recv): - if w_recv.is_immutable(): - return interp.space.w_true - return interp.space.w_false From b1407cb31d5eb860b34ee9321dea7b95a6967f86 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 12:52:44 +0100 Subject: [PATCH 36/63] Do not include full module names in member list --- docs/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 131c2052..5f4effcc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,6 +44,9 @@ # 'sphinx.ext.githubpages' ] +# Do not include full module names in member list +add_module_names = False + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] From b891bfe6c58abf05497c593d915e68b60817230c Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 12:53:05 +0100 Subject: [PATCH 37/63] Add docs for ImmutabilityPlugin --- docs/rsqueakvm.plugins.immutability.rst | 41 +++++++++++++++++++++++++ docs/rsqueakvm.plugins.rst | 1 + 2 files changed, 42 insertions(+) create mode 100644 docs/rsqueakvm.plugins.immutability.rst diff --git a/docs/rsqueakvm.plugins.immutability.rst b/docs/rsqueakvm.plugins.immutability.rst new file mode 100644 index 00000000..830e737b --- /dev/null +++ b/docs/rsqueakvm.plugins.immutability.rst @@ -0,0 +1,41 @@ +rsqueakvm.plugins.immutability package +====================================== + +Submodules +---------- + +rsqueakvm.plugins.immutability.bytes module +------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.bytes + :members: + :show-inheritance: + +rsqueakvm.plugins.immutability.pointers module +---------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.pointers + :members: + :show-inheritance: + +rsqueakvm.plugins.immutability.utils module +------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.utils + :members: + :show-inheritance: + +rsqueakvm.plugins.immutability.words module +------------------------------------------- + +.. automodule:: rsqueakvm.plugins.immutability.words + :members: + :show-inheritance: + + +Module contents +--------------- + +.. automodule:: rsqueakvm.plugins.immutability + :members: + :show-inheritance: diff --git a/docs/rsqueakvm.plugins.rst b/docs/rsqueakvm.plugins.rst index 994ac48f..92ca1659 100644 --- a/docs/rsqueakvm.plugins.rst +++ b/docs/rsqueakvm.plugins.rst @@ -7,6 +7,7 @@ Subpackages .. toctree:: rsqueakvm.plugins.database + rsqueakvm.plugins.immutability rsqueakvm.plugins.vmdebugging Submodules From 8c4c7a8f7d030800feea46c53d36edd71457e626 Mon Sep 17 00:00:00 2001 From: jchromik Date: Wed, 8 Feb 2017 13:13:01 +0100 Subject: [PATCH 38/63] add documentation for immutability plugin [ci skip] --- rsqueakvm/plugins/immutability_plugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 48bd0f03..478985ad 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -1,6 +1,7 @@ """ -Documentation goes here. - +This plug-in implements immutable objects.\n +Immutable objects can be created as copy of existing objects +or from a list of arguments. """ from rsqueakvm.error import PrimitiveFailedError From c09cbbe82b127f4c2a350d6a9f6c751711a22994 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 13:16:43 +0100 Subject: [PATCH 39/63] Use immutable slots for bytes and words --- rsqueakvm/plugins/immutability/bytes.py | 12 ++++++++++-- rsqueakvm/plugins/immutability/words.py | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index 0b658485..dbac53ca 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -1,3 +1,5 @@ +"""Immutable W_BytesObject Implementation.""" + from rsqueakvm.model.base import W_AbstractObjectWithClassReference from rsqueakvm.model.variable import W_BytesObject from rsqueakvm.plugins.immutability.utils import immutable_class @@ -7,15 +9,21 @@ @immutable_class class W_Immutable_BytesObject(W_BytesObject): + _immutable_fields_ = ['immutable_bytes'] repr_classname = '%s_Immutable' % W_BytesObject.repr_classname def __init__(self, space, w_cls, bytes_w): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.bytes = bytes_w + self.immutable_bytes = bytes_w @jit.elidable def _bytes(self): - return W_BytesObject._bytes(self) + return self.immutable_bytes def _version(self): return None + + """ + No need to override other methods that reference self.bytes, because they + were stubbed out by @immutable_class. + """ diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index b3fe5cef..b6a30e8b 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -1,3 +1,5 @@ +"""Immutable W_WordsObject Implementation.""" + from rsqueakvm.model.base import W_AbstractObjectWithClassReference from rsqueakvm.model.variable import W_WordsObject from rsqueakvm.plugins.immutability.utils import immutable_class @@ -7,12 +9,18 @@ @immutable_class class W_Immutable_WordsObject(W_WordsObject): + _immutable_fields_ = ['immutable_words'] repr_classname = '%s_Immutable' % W_WordsObject.repr_classname def __init__(self, space, w_cls, words_w): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.words = words_w + self.immutable_words = words_w @jit.elidable def _words(self): - return W_WordsObject._words(self) + return self.immutable_words + + """ + No need to override other methods that reference self.words, because they + were stubbed out by @immutable_class. + """ From ab5d932434a1af9598ba93e028467c089fae2ba9 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 13:17:13 +0100 Subject: [PATCH 40/63] Add more docs on ImmutabilityPlugin [ci skip] --- rsqueakvm/plugins/immutability/pointers.py | 2 ++ rsqueakvm/plugins/immutability/utils.py | 11 +++++++---- rsqueakvm/plugins/immutability_plugin.py | 3 +-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py index e378d344..bd858aa6 100644 --- a/rsqueakvm/plugins/immutability/pointers.py +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -1,3 +1,5 @@ +"""Immutable W_PointersObject Implementation.""" + from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash from rsqueakvm.model.pointers import W_PointersObject from rsqueakvm.storage_classes import ClassShadow diff --git a/rsqueakvm/plugins/immutability/utils.py b/rsqueakvm/plugins/immutability/utils.py index 65b5e4d8..63c4b725 100644 --- a/rsqueakvm/plugins/immutability/utils.py +++ b/rsqueakvm/plugins/immutability/utils.py @@ -1,3 +1,5 @@ +"""Utility functions for ImmutabilityPlugin.""" + from rsqueakvm.model.base import W_Object WRITE_OPERATIONS = [ @@ -14,11 +16,11 @@ def immutable_class(cls): """ - This function does something. + This function decorates classes, so that `is_immutable` returns `True` and + all `WRITE_OPERATIONS` are implemented as NoOps. - :param cls: The class. - :returns: int -- the return code. - :raises: AttributeError, KeyError + :param cls: The target class. + :returns: The decorated class. """ def is_immutable(self): @@ -34,6 +36,7 @@ def noop(self, *args): def patch_w_object(): + """Add `W_Object.is_immutable` which by default returns `False`.""" def is_immutable(self): return False W_Object.is_immutable = is_immutable diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 48bd0f03..b5e1558f 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -28,8 +28,7 @@ def primitiveIsImmutable(interp, s_frame, w_recv): :param interp: The interpreter proxy. :param s_frame: The stack frame. :param w_recv: The receiver object. - :returns: Return w_true if w_recv is immutable object. Returns w_false otherwise. - :raises: *nothing* + :returns: w_true if w_recv is immutable object, otherwise w_false. """ if w_recv.is_immutable(): return interp.space.w_true From 381297a709dc940a5ff82f331efc004007f3cc15 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 13:52:56 +0100 Subject: [PATCH 41/63] Finialize ImmutabilityPlugin documentation [ci skip] --- rsqueakvm/plugins/immutability/bytes.py | 15 ++++++ rsqueakvm/plugins/immutability/pointers.py | 54 ++++++++++++++++++---- rsqueakvm/plugins/immutability/utils.py | 8 +++- rsqueakvm/plugins/immutability/words.py | 10 ++++ rsqueakvm/plugins/immutability_plugin.py | 19 ++++---- 5 files changed, 87 insertions(+), 19 deletions(-) diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index dbac53ca..72d842d6 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -9,18 +9,33 @@ @immutable_class class W_Immutable_BytesObject(W_BytesObject): + """`W_BytesObject` subclass with immutable bytes.""" _immutable_fields_ = ['immutable_bytes'] repr_classname = '%s_Immutable' % W_BytesObject.repr_classname def __init__(self, space, w_cls, bytes_w): + """ + Initialize immutable bytes object and store its bytes in + `self.immutable_bytes` slot. + """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_bytes = bytes_w @jit.elidable def _bytes(self): + """ + `W_BytesObject._bytes(self)` override. + + :returns: bytes from `self.immutable_bytes` slot. + """ return self.immutable_bytes def _version(self): + """ + `W_BytesObject._version(self)` override. + + :returns: `None`. + """ return None """ diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py index bd858aa6..2ea972bc 100644 --- a/rsqueakvm/plugins/immutability/pointers.py +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -1,4 +1,15 @@ -"""Immutable W_PointersObject Implementation.""" +""" +Immutable W_PointersObject Implementation. + +.. data:: POINTERS_CLASSES +A list of all immutable W_PointersObject subclasses. The position of each class +in the list correlates to its number of storage slots (`0` no storage, `1` has +one storage slot, ...). The last class in the list is an immutable +W_PointersObject subclass with variable storage size. + +.. data:: POINTERS_CLASS_ITER +Unrolling iterable of `POINTERS_CLASSES`. +""" from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash from rsqueakvm.model.pointers import W_PointersObject @@ -13,32 +24,41 @@ @immutable_class class W_AbstractImmutable_PointersObject(W_PointersObject): + """Abstract `W_PointersObject` subclass for immutable pointers objects.""" _attrs_ = [] _immutable_fields_ = [] repr_classname = ('%s_AbstractImmutable' % W_PointersObject.repr_classname) def __init__(self, space, w_cls): + """ + Initialize immutable pointers object, but avoid initializing storage + and reuse `self.strategy` slot to store class shadow. + """ W_AbstractObjectWithIdentityHash.__init__(self) - # reuse strategy var to store cls self.strategy = w_cls.as_class_get_shadow(space) def getclass(self, space): + """:returns: Class from class shadow stored in `self.strategy` slot.""" return self.strategy.w_self() def class_shadow(self, space): + """:returns: Class shadow stored in `self.strategy` slot.""" class_shadow = self.strategy assert isinstance(class_shadow, ClassShadow) return class_shadow def size(self): + """:raises: NotImplementedError""" raise NotImplementedError def fetch(self, space, n0): + """:raises: NotImplementedError""" raise NotImplementedError class W_Immutable_PointersObject(W_AbstractImmutable_PointersObject): + """`W_PointersObject` subclass with immutable storage of variable size.""" _immutable_fields_ = ['_storage[*]'] repr_classname = '%s_Immutable_N' % W_PointersObject.repr_classname erase, unerase = rerased.new_erasing_pair('storage_eraser') @@ -54,11 +74,18 @@ def fetch(self, space, n0): return self.unerase(self._storage)[n0] -def generate_fixed_w_pointersobject_class(n_storage): +def generate_fixed_immutable_subclass(n_storage): + """ + Generate `W_PointersObject` subclass with immutable storage of fixed size. + + :param n_storage: Number of storage slots. + :returns: Immutable `W_PointersObject` subclass with fixed slots. + """ storage_iter = unrolling_iterable(range(n_storage)) cls_name = '%s_Immutable_%s' % (W_PointersObject.repr_classname, n_storage) class W_FixedImmutable_PointersObject(W_AbstractImmutable_PointersObject): + """`W_PointersObject` subclass with immutable storage of fixed size.""" _storages_ = [(STORAGE_ATTR_TEMPLATE % x) for x in storage_iter] _attrs_ = _storages_ _immutable_fields_ = _storages_ @@ -83,17 +110,24 @@ def fetch(self, space, n0): return W_FixedImmutable_PointersObject -pointers_classes = [] +POINTERS_CLASSES = [] for n_storage in range(0, 10): - pointers_classes.append(generate_fixed_w_pointersobject_class(n_storage)) -pointers_classes.append(W_Immutable_PointersObject) -pointers_class_iter = unrolling_iterable(enumerate(pointers_classes)) + POINTERS_CLASSES.append(generate_fixed_immutable_subclass(n_storage)) +POINTERS_CLASSES.append(W_Immutable_PointersObject) +POINTERS_CLASS_ITER = unrolling_iterable(enumerate(POINTERS_CLASSES)) def select_immutable_pointers_class(storage): + """ + Select immutable `W_PointersObject` subclass for a given pointers storage. + If there is no immutable `W_PointersObject` subclass with the right fixed + storage size, it returns the immutable subclass with variable storage size. + + :param storage: Pointers to store. + :returns: Immutable `W_PointersObject` subclass. + """ length = len(storage) - for i, cls in pointers_class_iter: + for i, cls in POINTERS_CLASS_ITER: if i == length: return cls - # otherwise: - return pointers_classes[-1] + return W_Immutable_PointersObject diff --git a/rsqueakvm/plugins/immutability/utils.py b/rsqueakvm/plugins/immutability/utils.py index 63c4b725..bbcc9de0 100644 --- a/rsqueakvm/plugins/immutability/utils.py +++ b/rsqueakvm/plugins/immutability/utils.py @@ -1,4 +1,10 @@ -"""Utility functions for ImmutabilityPlugin.""" +""" +Utility functions for ImmutabilityPlugin. + +.. data:: WRITE_OPERATIONS +A list of all write operations to be stubbed out by `immutable_class(cls)` +decorator. +""" from rsqueakvm.model.base import W_Object diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index b6a30e8b..1b7e5ace 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -9,15 +9,25 @@ @immutable_class class W_Immutable_WordsObject(W_WordsObject): + """`W_WordsObject` subclass with immutable words.""" _immutable_fields_ = ['immutable_words'] repr_classname = '%s_Immutable' % W_WordsObject.repr_classname def __init__(self, space, w_cls, words_w): + """ + Initialize immutable words object and store its words in + `self.immutable_words` slot. + """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_words = words_w @jit.elidable def _words(self): + """ + `W_WordsObject._words(self)` override. + + :returns: words from `self.immutable_words` slot. + """ return self.immutable_words """ diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index b9be724a..d9122a54 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -1,7 +1,9 @@ """ -This plug-in implements immutable objects.\n +RSqueak/VM plugin which provides support for immutable objects. + Immutable objects can be created as copy of existing objects -or from a list of arguments. +or from a list of arguments. The package `ImmutableObjects`, located in +`/repository`, needs to be loaded in the image. """ from rsqueakvm.error import PrimitiveFailedError @@ -24,12 +26,12 @@ @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object]) def primitiveIsImmutable(interp, s_frame, w_recv): """ - Tests if w_recv is immutable. + Tests if `w_recv` is an immutable object. :param interp: The interpreter proxy. :param s_frame: The stack frame. :param w_recv: The receiver object. - :returns: w_true if w_recv is immutable object, otherwise w_false. + :returns: `w_true` if `w_recv` is immutable object, otherwise `w_false`. """ if w_recv.is_immutable(): return interp.space.w_true @@ -39,13 +41,13 @@ def primitiveIsImmutable(interp, s_frame, w_recv): @ImmutabilityPlugin.expose_primitive(unwrap_spec=[object, object]) def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): """ - Creates an immutable copy of a Smalltalk object. + Creates an immutable copy of a given Smalltalk object. :param interp: The interpreter proxy. :param s_frame: The stack frame. :param w_cls: The imutable objects target class. :param w_obj: The Smalltalk object to produce an immutable copy from. - :returns: Immutable copy of w_obj with class w_cls. + :returns: An immutable copy of `w_obj` with class `w_cls`. :raises: PrimitiveFailedError """ space = interp.space @@ -66,12 +68,13 @@ def primitiveImmutableFrom(interp, s_frame, w_cls, w_obj): @ImmutabilityPlugin.expose_primitive(unwrap_spec=None) def primitiveImmutableFromArgs(interp, s_frame, argcount): """ - Creates an immutable object with class and arguments from stack frame. + Returns an immutable instance of the receiver (which is a class) with + all fields initialized with the arguments given. :param interp: The interpreter proxy. :param s_frame: The stack frame. :param argcount: The number of arguments. - :returns: Immutable object with class and arguments from stack frame. + :returns: An immutable object. :raises: PrimitiveFailedError """ w_arguments = s_frame.pop_and_return_n(argcount)[:] From c8318a9babed01dc094bfb234a97ea0e179191f6 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 13:54:16 +0100 Subject: [PATCH 42/63] Re-enable all disabled build jobs [ci skip] --- .travis.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index a71afaa2..0729cf94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,31 +21,31 @@ env: - LIBRARY_PATH=$LIBRARY_PATH:$HOME/SDL2/lib - C_INCLUDE_PATH=$C_INCLUDE_PATH:$HOME/SDL2/include matrix: - # - BUILD_ARCH=32bit TEST_TYPE=default - # - BUILD_ARCH=32bit - # - BUILD_ARCH=32bit TEST_TYPE=coverage + - BUILD_ARCH=32bit TEST_TYPE=default + - BUILD_ARCH=32bit + - BUILD_ARCH=32bit TEST_TYPE=coverage # - BUILD_ARCH=lldebug - # - BUILD_ARCH=64bit TEST_TYPE=default + - BUILD_ARCH=64bit TEST_TYPE=default - BUILD_ARCH=64bit - # - BUILD_ARCH=armv6 - # - BUILD_ARCH=armv7-a - # - BUILD_ARCH=armv8-a + - BUILD_ARCH=armv6 + - BUILD_ARCH=armv7-a + - BUILD_ARCH=armv8-a # - BUILD_ARCH=64bit PLUGINS=DatabasePlugin - # - BUILD_ARCH=64bit PLUGINS=RubyPlugin + - BUILD_ARCH=64bit PLUGINS=RubyPlugin matrix: include: - # - os: osx - # osx_image: xcode7.3 - # env: BUILD_ARCH=64bit TEST_TYPE=default + - os: osx + osx_image: xcode7.3 + env: BUILD_ARCH=64bit TEST_TYPE=default - os: osx osx_image: xcode7.3 env: BUILD_ARCH=64bit - # - os: osx - # osx_image: xcode7.3 - # env: BUILD_ARCH=64bit PLUGINS=RubyPlugin - # allow_failures: - # - env: BUILD_ARCH=64bit PLUGINS=DatabasePlugin - # - env: BUILD_ARCH=64bit PLUGINS=RubyPlugin + - os: osx + osx_image: xcode7.3 + env: BUILD_ARCH=64bit PLUGINS=RubyPlugin + allow_failures: + # - env: BUILD_ARCH=64bit PLUGINS=DatabasePlugin + - env: BUILD_ARCH=64bit PLUGINS=RubyPlugin fast_finish: true install: .travis/install_requirements.sh script: .travis/build.sh From 5beb31197830682f1e0f050e0100a0661edbb9d1 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 14:01:34 +0100 Subject: [PATCH 43/63] Move utils into __init__.py and adjust imports --- rsqueakvm/plugins/immutability/__init__.py | 48 ++++++++++++++++++++++ rsqueakvm/plugins/immutability/bytes.py | 2 +- rsqueakvm/plugins/immutability/pointers.py | 2 +- rsqueakvm/plugins/immutability/utils.py | 48 ---------------------- rsqueakvm/plugins/immutability/words.py | 2 +- rsqueakvm/plugins/immutability_plugin.py | 8 ++-- 6 files changed, 54 insertions(+), 56 deletions(-) delete mode 100644 rsqueakvm/plugins/immutability/utils.py diff --git a/rsqueakvm/plugins/immutability/__init__.py b/rsqueakvm/plugins/immutability/__init__.py index e69de29b..f176a773 100644 --- a/rsqueakvm/plugins/immutability/__init__.py +++ b/rsqueakvm/plugins/immutability/__init__.py @@ -0,0 +1,48 @@ +""" +Base functions for ImmutabilityPlugin. + +.. data:: WRITE_OPERATIONS +A list of all write operations to be stubbed out by `immutable_class(cls)` +decorator. +""" + +from rsqueakvm.model.base import W_Object + +WRITE_OPERATIONS = [ + # W_Object + 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', + 'fillin_weak', 'fillin_finalize', + # W_PointersObject + 'pointers_become_one_way', + # W_BytesObject / W_WordsObject + 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', + 'setbytes', 'mutate' +] + + +def immutable_class(cls): + """ + This function decorates classes, so that `is_immutable` returns `True` and + all `WRITE_OPERATIONS` are implemented as NoOps. + + :param cls: The target class. + :returns: The decorated class. + + """ + def is_immutable(self): + return True + cls.is_immutable = is_immutable + + for method_name in WRITE_OPERATIONS: + if hasattr(cls, method_name): + def noop(self, *args): + pass + setattr(cls, method_name, noop) + return cls + + +def patch_w_object(): + """Add `W_Object.is_immutable` which by default returns `False`.""" + def is_immutable(self): + return False + W_Object.is_immutable = is_immutable diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index 72d842d6..b67b74b1 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -2,7 +2,7 @@ from rsqueakvm.model.base import W_AbstractObjectWithClassReference from rsqueakvm.model.variable import W_BytesObject -from rsqueakvm.plugins.immutability.utils import immutable_class +from rsqueakvm.plugins.immutability import immutable_class from rpython.rlib import jit diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py index 2ea972bc..5f5c1132 100644 --- a/rsqueakvm/plugins/immutability/pointers.py +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -13,8 +13,8 @@ from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash from rsqueakvm.model.pointers import W_PointersObject +from rsqueakvm.plugins.immutability import immutable_class from rsqueakvm.storage_classes import ClassShadow -from rsqueakvm.plugins.immutability.utils import immutable_class from rpython.rlib import rerased from rpython.rlib.unroll import unrolling_iterable diff --git a/rsqueakvm/plugins/immutability/utils.py b/rsqueakvm/plugins/immutability/utils.py deleted file mode 100644 index bbcc9de0..00000000 --- a/rsqueakvm/plugins/immutability/utils.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -Utility functions for ImmutabilityPlugin. - -.. data:: WRITE_OPERATIONS -A list of all write operations to be stubbed out by `immutable_class(cls)` -decorator. -""" - -from rsqueakvm.model.base import W_Object - -WRITE_OPERATIONS = [ - # W_Object - 'atput0', 'store', 'store_all', 'setword' '_become', 'fillin', - 'fillin_weak', 'fillin_finalize', - # W_PointersObject - 'pointers_become_one_way', - # W_BytesObject / W_WordsObject - 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', - 'setbytes', 'mutate' -] - - -def immutable_class(cls): - """ - This function decorates classes, so that `is_immutable` returns `True` and - all `WRITE_OPERATIONS` are implemented as NoOps. - - :param cls: The target class. - :returns: The decorated class. - - """ - def is_immutable(self): - return True - cls.is_immutable = is_immutable - - for method_name in WRITE_OPERATIONS: - if hasattr(cls, method_name): - def noop(self, *args): - pass - setattr(cls, method_name, noop) - return cls - - -def patch_w_object(): - """Add `W_Object.is_immutable` which by default returns `False`.""" - def is_immutable(self): - return False - W_Object.is_immutable = is_immutable diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index 1b7e5ace..b265e92f 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -2,7 +2,7 @@ from rsqueakvm.model.base import W_AbstractObjectWithClassReference from rsqueakvm.model.variable import W_WordsObject -from rsqueakvm.plugins.immutability.utils import immutable_class +from rsqueakvm.plugins.immutability import immutable_class from rpython.rlib import jit diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index d9122a54..a8ca6f6d 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -7,16 +7,14 @@ """ from rsqueakvm.error import PrimitiveFailedError -from rsqueakvm.plugins.plugin import Plugin from rsqueakvm.model.variable import W_BytesObject, W_WordsObject -from rsqueakvm.plugins.immutability.utils import patch_w_object - -from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS - +from rsqueakvm.plugins.immutability import patch_w_object from rsqueakvm.plugins.immutability.bytes import W_Immutable_BytesObject from rsqueakvm.plugins.immutability.pointers import ( select_immutable_pointers_class) from rsqueakvm.plugins.immutability.words import W_Immutable_WordsObject +from rsqueakvm.plugins.plugin import Plugin +from rsqueakvm.storage_classes import BYTES, POINTERS, WORDS ImmutabilityPlugin = Plugin() From 52ebfd0272821922cc84960ef2a7cf84b4e24a3d Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 14:05:31 +0100 Subject: [PATCH 44/63] Remove utils from docs [ci skip] --- docs/rsqueakvm.plugins.immutability.rst | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/rsqueakvm.plugins.immutability.rst b/docs/rsqueakvm.plugins.immutability.rst index 830e737b..a6e0de00 100644 --- a/docs/rsqueakvm.plugins.immutability.rst +++ b/docs/rsqueakvm.plugins.immutability.rst @@ -18,13 +18,6 @@ rsqueakvm.plugins.immutability.pointers module :members: :show-inheritance: -rsqueakvm.plugins.immutability.utils module -------------------------------------------- - -.. automodule:: rsqueakvm.plugins.immutability.utils - :members: - :show-inheritance: - rsqueakvm.plugins.immutability.words module ------------------------------------------- From efbecb1fda8ddb9d52c9b504a14ab3b35568ca29 Mon Sep 17 00:00:00 2001 From: jchromik Date: Wed, 8 Feb 2017 16:34:49 +0100 Subject: [PATCH 45/63] categorization of nano benchmark methods --- .../ConsNanoBenchmark.class/instance/classUnderBenching.st | 2 +- .../ConsNanoBenchmark.class/instance/consWith.through..st | 2 +- .../instance/createCharacterListOfSize..st | 2 +- .../ConsNanoBenchmark.class/instance/createMixedListOfSize..st | 2 +- .../ConsNanoBenchmark.class/instance/createNumberListOfSize..st | 2 +- .../ConsNanoBenchmark.class/instance/createObjectListOfSize..st | 2 +- .../VectorNanoBenchmark.class/instance/classUnderBenching.st | 2 +- .../instance/createCharacterListOfSize..st | 2 +- .../instance/createMixedListOfSize..st | 2 +- .../instance/createNumberListOfSize..st | 2 +- .../instance/createObjectListOfSize..st | 2 +- .../VectorNanoBenchmark.class/instance/vector.with.through..st | 2 +- .../VectorNanoBenchmark.class/instance/vectorWith.through..st | 2 +- repository/ImmutableObjects.package/monticello.meta/version | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st index a4217fe8..2817a7ec 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/classUnderBenching.st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks classUnderBenching ^ Cons \ No newline at end of file diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st index fd59aad5..f381381e 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/consWith.through..st @@ -1,4 +1,4 @@ -as yet unclassified +set up consWith: aBlock through: aNumber ^ aNumber = 0 diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st index c6f27c4c..be889449 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createCharacterListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st index 13340c25..26a9cce7 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createMixedListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createMixedListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st index 1067de75..ac4947d1 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createNumberListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createNumberListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st index c026b92b..ba016341 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/instance/createObjectListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createObjectListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st index de75c791..f0892176 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/classUnderBenching.st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks classUnderBenching ^ Vector \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st index 59b2cc3d..274a21d1 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createCharacterListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createCharacterListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st index ccebac57..8a7a1105 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createMixedListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createMixedListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st index af3e4a5e..17186f7c 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createNumberListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createNumberListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st index 2faec538..a6ceb6cd 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/createObjectListOfSize..st @@ -1,4 +1,4 @@ -as yet unclassified +benchmark hooks createObjectListOfSize: aNumber | rng | diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st index e3916976..7c70b45e 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vector.with.through..st @@ -1,4 +1,4 @@ -as yet unclassified +set up vector: aVector with: aBlock through: aNumber ^ aNumber = 0 diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st index 3a35f709..b6f441df 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/instance/vectorWith.through..st @@ -1,4 +1,4 @@ -as yet unclassified +set up vectorWith: aBlock through: aNumber ^ self vector: Vector new with: aBlock through: aNumber \ No newline at end of file diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index b95e212d..d83746ab 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-jc.19' message 'categorization' id 'b1f5d5d1-596c-47e3-b0b2-74fd4fb4c6b7' date '8 February 2017' time '4:33:54.634511 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 6181ea8404d6542164977ff807015cbee3ad9cb7 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 16:46:04 +0100 Subject: [PATCH 46/63] Improve __init__ comments --- rsqueakvm/plugins/immutability/bytes.py | 2 ++ rsqueakvm/plugins/immutability/pointers.py | 9 ++++++--- rsqueakvm/plugins/immutability/words.py | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index b67b74b1..04e47d37 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -17,6 +17,8 @@ def __init__(self, space, w_cls, bytes_w): """ Initialize immutable bytes object and store its bytes in `self.immutable_bytes` slot. + `W_BytesObject.__init__(self, space, w_class, size)` not called, + because there is no need to `self.mutate()` and set `self.bytes`. """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_bytes = bytes_w diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py index 5f5c1132..ac2e25ce 100644 --- a/rsqueakvm/plugins/immutability/pointers.py +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -33,7 +33,10 @@ class W_AbstractImmutable_PointersObject(W_PointersObject): def __init__(self, space, w_cls): """ Initialize immutable pointers object, but avoid initializing storage - and reuse `self.strategy` slot to store class shadow. + by calling `W_AbstractObjectWithIdentityHash.__init__(self)` instead of + `W_PointersObject.__init__(self)`. + Additionally, reuse `self.strategy` slot to store class shadow. + """ W_AbstractObjectWithIdentityHash.__init__(self) self.strategy = w_cls.as_class_get_shadow(space) @@ -50,11 +53,11 @@ def class_shadow(self, space): def size(self): """:raises: NotImplementedError""" - raise NotImplementedError + raise NotImplementedError('abstract base class') def fetch(self, space, n0): """:raises: NotImplementedError""" - raise NotImplementedError + raise NotImplementedError('abstract base class') class W_Immutable_PointersObject(W_AbstractImmutable_PointersObject): diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index b265e92f..e589f501 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -17,6 +17,8 @@ def __init__(self, space, w_cls, words_w): """ Initialize immutable words object and store its words in `self.immutable_words` slot. + `W_Immutable_WordsObject.__init__(self, space, w_class, size)` not + called, because there is no need to initialize `self.words`. """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_words = words_w From 50933428fa67acb13def0b390bec54015e9b7dee Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 16:46:46 +0100 Subject: [PATCH 47/63] primImmutableFromArgs now supports byte/word objs --- rsqueakvm/plugins/immutability_plugin.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index a8ca6f6d..8a88b10a 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -75,7 +75,10 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): :returns: An immutable object. :raises: PrimitiveFailedError """ + if argcount == 0: + raise PrimitiveFailedError w_arguments = s_frame.pop_and_return_n(argcount)[:] + w_first_arg = w_arguments[0] w_cls = s_frame.pop() space = interp.space instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() @@ -83,10 +86,9 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): if instance_kind == POINTERS: cls = select_immutable_pointers_class(w_arguments) return cls(space, w_cls, w_arguments) - # TBD: - # elif instance_kind == BYTES and isinstance(w_obj, W_BytesObject): - # return W_Immutable_BytesObject(space, w_cls, w_obj.bytes) - # elif instance_kind == WORDS and isinstance(w_obj, W_WordsObject): - # return W_Immutable_WordsObject(space, w_cls, w_obj.words) + elif instance_kind == BYTES and isinstance(w_first_arg, W_BytesObject): + return W_Immutable_BytesObject(space, w_cls, w_first_arg.bytes) + elif instance_kind == WORDS and isinstance(w_first_arg, W_WordsObject): + return W_Immutable_WordsObject(space, w_cls, w_first_arg.words) raise PrimitiveFailedError From c4d1351d650f118c5cfb11bb2b81e49fc2a8c97a Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 17:55:45 +0100 Subject: [PATCH 48/63] Add setword to blacklist --- rsqueakvm/plugins/immutability/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rsqueakvm/plugins/immutability/__init__.py b/rsqueakvm/plugins/immutability/__init__.py index f176a773..378d84dc 100644 --- a/rsqueakvm/plugins/immutability/__init__.py +++ b/rsqueakvm/plugins/immutability/__init__.py @@ -15,8 +15,8 @@ # W_PointersObject 'pointers_become_one_way', # W_BytesObject / W_WordsObject - 'setchar', 'short_atput0', 'setwords', 'convert_to_bytes_layout', - 'setbytes', 'mutate' + 'setchar', 'short_atput0', 'setword', 'setwords', + 'convert_to_bytes_layout', 'setbytes', 'mutate' ] From e017beb90893819dd6d758b2c1ecf53455824000 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 17:56:17 +0100 Subject: [PATCH 49/63] Add vm-level tests for ImmutabilityPlugin --- rsqueakvm/plugins/immutability/pointers.py | 3 +- rsqueakvm/test/test_immutability_plugin.py | 74 ++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 rsqueakvm/test/test_immutability_plugin.py diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py index ac2e25ce..593dce1d 100644 --- a/rsqueakvm/plugins/immutability/pointers.py +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -64,7 +64,8 @@ class W_Immutable_PointersObject(W_AbstractImmutable_PointersObject): """`W_PointersObject` subclass with immutable storage of variable size.""" _immutable_fields_ = ['_storage[*]'] repr_classname = '%s_Immutable_N' % W_PointersObject.repr_classname - erase, unerase = rerased.new_erasing_pair('storage_eraser') + erase, unerase = map( + staticmethod, rerased.new_erasing_pair('storage_eraser')) def __init__(self, space, w_cls, pointers_w): W_AbstractImmutable_PointersObject.__init__(self, space, w_cls) diff --git a/rsqueakvm/test/test_immutability_plugin.py b/rsqueakvm/test/test_immutability_plugin.py new file mode 100644 index 00000000..f64ae073 --- /dev/null +++ b/rsqueakvm/test/test_immutability_plugin.py @@ -0,0 +1,74 @@ +import py +import pytest + +from rsqueakvm import storage_classes +from rsqueakvm.plugins.immutability.bytes import W_Immutable_BytesObject +from rsqueakvm.plugins.immutability.pointers import ( + select_immutable_pointers_class) +from rsqueakvm.plugins.immutability.words import W_Immutable_WordsObject +from rsqueakvm.model.pointers import W_PointersObject + +from .util import create_space, cleanup_module + + +def test_space(): + return create_space(bootstrap=True) + +space = pytest.fixture(test_space) +bootstrap_class = None + + +def setup_module(): + global bootstrap_class, space + v_space = test_space() + space = v_space + bootstrap_class = space.bootstrap_class + + +def teardown_module(): + cleanup_module(__name__) + + +def test_W_Immutable_BytesObject(): + w_class = bootstrap_class(0, format=storage_classes.BYTES) + w_bytes = w_class.as_class_get_shadow(space).new(20) + w_ibytes = W_Immutable_BytesObject(space, w_class, w_bytes.bytes) + assert w_ibytes.is_immutable() + assert w_ibytes.getclass(space).is_same_object(w_class) + assert w_ibytes.size() == 20 + assert w_ibytes.getchar(3) == "\x00" + w_ibytes.setchar(3, "\xAA") + assert w_ibytes.getchar(3) == "\x00" + py.test.raises(IndexError, lambda: w_ibytes.getchar(20)) + + +def test_W_Immutable_PointersObjects(): + w_class = bootstrap_class(0) + for i in range(20): + w_pointers = W_PointersObject(space, w_class, i) + cls = select_immutable_pointers_class(w_pointers.fetch_all(space)) + assert (i == len(cls._immutable_fields_) or + cls._immutable_fields_ == ['_storage[*]']) + placeholder = object() + w_ipointers = cls(space, w_class, [placeholder] * i) + assert w_ipointers.is_immutable() + assert w_ipointers.getclass(space).is_same_object(w_class) + assert w_ipointers.size() == i + if i > 0: + assert w_ipointers.fetch(space, 0) is placeholder + w_ipointers.store(space, 0, space.w_true) + assert w_ipointers.fetch(space, 0) is placeholder + + +def test_W_Immutable_WordsObject(): + w_class = bootstrap_class(0, format=storage_classes.WORDS) + w_words = w_class.as_class_get_shadow(space).new(20) + w_iwords = W_Immutable_WordsObject(space, w_class, w_words.words) + assert w_iwords.is_immutable() + assert w_iwords.getclass(space).is_same_object(w_class) + assert w_iwords.size() == 20 + assert w_class.as_class_get_shadow(space).instsize() == 0 + assert w_iwords.getword(3) == 0 + w_iwords.setword(3, 42) + assert w_iwords.getword(3) == 0 + py.test.raises(AssertionError, lambda: w_iwords.getword(20)) From 373058650b1d9e3a976cb0e5c9314928a19eb13b Mon Sep 17 00:00:00 2001 From: jchromik Date: Wed, 8 Feb 2017 18:02:10 +0100 Subject: [PATCH 50/63] categorization of nano benchmark methods --- .../ConsNanoBenchmark.class/class/defaultProblemSize.st | 2 +- .../VectorNanoBenchmark.class/class/defaultProblemSize.st | 2 +- repository/ImmutableObjects.package/monticello.meta/version | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st index abcff658..1bcac077 100644 --- a/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st +++ b/repository/ImmutableObjects.package/ConsNanoBenchmark.class/class/defaultProblemSize.st @@ -1,4 +1,4 @@ -as yet unclassified +defaults defaultProblemSize ^ 1000 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st index abcff658..1bcac077 100644 --- a/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st +++ b/repository/ImmutableObjects.package/VectorNanoBenchmark.class/class/defaultProblemSize.st @@ -1,4 +1,4 @@ -as yet unclassified +defaults defaultProblemSize ^ 1000 \ No newline at end of file diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index d83746ab..87fa739a 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-jc.19' message 'categorization' id 'b1f5d5d1-596c-47e3-b0b2-74fd4fb4c6b7' date '8 February 2017' time '4:33:54.634511 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-jc.20' message 'categorization' id 'c4601ecc-c634-4e7b-a9ba-d7884b036196' date '8 February 2017' time '6:01:30.202538 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.19' message 'categorization' id 'b1f5d5d1-596c-47e3-b0b2-74fd4fb4c6b7' date '8 February 2017' time '4:33:54.634511 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From d6afdaa738bbb461287d2437e99defff8b6eefbf Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 18:03:36 +0100 Subject: [PATCH 51/63] Only allow one argument for byte/word object --- rsqueakvm/plugins/immutability_plugin.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 8a88b10a..3591d7e8 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -77,18 +77,19 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): """ if argcount == 0: raise PrimitiveFailedError - w_arguments = s_frame.pop_and_return_n(argcount)[:] - w_first_arg = w_arguments[0] + w_args = s_frame.pop_and_return_n(argcount)[:] w_cls = s_frame.pop() space = interp.space instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() if instance_kind == POINTERS: - cls = select_immutable_pointers_class(w_arguments) - return cls(space, w_cls, w_arguments) - elif instance_kind == BYTES and isinstance(w_first_arg, W_BytesObject): - return W_Immutable_BytesObject(space, w_cls, w_first_arg.bytes) - elif instance_kind == WORDS and isinstance(w_first_arg, W_WordsObject): - return W_Immutable_WordsObject(space, w_cls, w_first_arg.words) + cls = select_immutable_pointers_class(w_args) + return cls(space, w_cls, w_args) + elif (instance_kind == BYTES and + len(w_args) == 1 and isinstance(w_args[0], W_BytesObject)): + return W_Immutable_BytesObject(space, w_cls, w_args[0].bytes) + elif (instance_kind == WORDS and + len(w_args) == 1 and isinstance(w_args[0], W_WordsObject)): + return W_Immutable_WordsObject(space, w_cls, w_args[0].words) raise PrimitiveFailedError From cf206f2ea048857b1064683d752fc7b68aa31d1f Mon Sep 17 00:00:00 2001 From: jchromik Date: Wed, 8 Feb 2017 18:07:14 +0100 Subject: [PATCH 52/63] categorization of nano benchmark methods --- .../ImmutableObjects.package/Cons.class/class/car.cdr..st | 2 +- repository/ImmutableObjects.package/Cons.class/class/new.st | 2 +- .../ImmutableObjects.package/Cons.class/class/withAll..st | 2 +- repository/ImmutableObjects.package/monticello.meta/version | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st b/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st index 38bea290..5f867934 100644 --- a/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st +++ b/repository/ImmutableObjects.package/Cons.class/class/car.cdr..st @@ -1,4 +1,4 @@ -as yet unclassified +instance creation car: anObject cdr: anotherObject diff --git a/repository/ImmutableObjects.package/Cons.class/class/new.st b/repository/ImmutableObjects.package/Cons.class/class/new.st index 70e36bcd..a4307b49 100644 --- a/repository/ImmutableObjects.package/Cons.class/class/new.st +++ b/repository/ImmutableObjects.package/Cons.class/class/new.st @@ -1,4 +1,4 @@ -as yet unclassified +instance creation new self shouldNotImplement. \ No newline at end of file diff --git a/repository/ImmutableObjects.package/Cons.class/class/withAll..st b/repository/ImmutableObjects.package/Cons.class/class/withAll..st index 20c9d918..c894914f 100644 --- a/repository/ImmutableObjects.package/Cons.class/class/withAll..st +++ b/repository/ImmutableObjects.package/Cons.class/class/withAll..st @@ -1,4 +1,4 @@ -as yet unclassified +instance creation withAll: aCollection " ^ aCollection diff --git a/repository/ImmutableObjects.package/monticello.meta/version b/repository/ImmutableObjects.package/monticello.meta/version index 87fa739a..0ef6583b 100644 --- a/repository/ImmutableObjects.package/monticello.meta/version +++ b/repository/ImmutableObjects.package/monticello.meta/version @@ -1 +1 @@ -(name 'ImmutableObjects-jc.20' message 'categorization' id 'c4601ecc-c634-4e7b-a9ba-d7884b036196' date '8 February 2017' time '6:01:30.202538 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.19' message 'categorization' id 'b1f5d5d1-596c-47e3-b0b2-74fd4fb4c6b7' date '8 February 2017' time '4:33:54.634511 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file +(name 'ImmutableObjects-jc.21' message 'categorization' id 'fbe5d9bf-4b63-4b9b-a5c1-0968226aa876' date '8 February 2017' time '6:06:51.260485 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.20' message 'categorization' id 'c4601ecc-c634-4e7b-a9ba-d7884b036196' date '8 February 2017' time '6:01:30.202538 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.19' message 'categorization' id 'b1f5d5d1-596c-47e3-b0b2-74fd4fb4c6b7' date '8 February 2017' time '4:33:54.634511 pm' author 'jc' ancestors ((name 'ImmutableObjects-jc.18' message 'create VectorNanoBenchmark set reasonable defaultProblemSize fix typo (consWith:though: --> consWith:through:)' id 'a1d1f390-30d4-48bc-9eb3-5a26d0e5103d' date '5 January 2017' time '5:06:46.341336 pm' author 'jc' ancestors ((name 'ImmutableObjects-topa.17' message 'Don''t stress the stack so much on Cons creation' id 'd81df794-119a-4acd-ada5-d865419b49c1' date '4 January 2017' time '11:38:11.379491 am' author 'topa' ancestors ((name 'ImmutableObjects-topa.16' message 'Fix Prefixes' id '6183d9db-a7f8-4834-bc28-9589c7390f09' date '6 December 2016' time '4:56:05.576111 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.15' message 'Fix cons, add Benchmarks (needs benches package, pls split :))' id 'e256f0d3-ce70-4ba7-817d-efc361cb5df3' date '6 December 2016' time '4:53:43.81309 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.14' message 'Add Cons and Vector structures as example. need test uses' id 'c80b2f19-4a6e-47da-b404-9067c1dfd870' date '5 December 2016' time '5:46:47.275156 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.13' message 'Fix ImmutableFixedObjectTest. ImmJustFixedPointersClass has instSpec 1 (non-indexable) and therefore Object>>at:put: failed.' id 'd4f4dae6-b9bb-41ec-b855-4b1d695ed2fb' date '1 December 2016' time '10:29:19.995254 am' author 'jc' ancestors ((name 'ImmutableObjects-fn.12' message 'Add ImmutableMixedObjectTest' id 'a3f5337c-f68a-4344-b932-e3e17040c3dc' date '28 November 2016' time '8:57:52.96228 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.11' message 'Add ImmutableBytesObjectTest and ImmutableWordsObjectTest, also fix existing tests' id '96973e4d-2875-4556-a2a8-8092ecc5ccbf' date '28 November 2016' time '8:42:11.025442 pm' author 'fn' ancestors ((name 'ImmutableObjects-topa.10' message 'test immutable object creation from not-same-class objects' id 'd36f3a69-a35d-45a9-aeb2-4d6eacee5b41' date '28 November 2016' time '4:29:31.097749 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.9' message 'Extend tests a little' id '5d3468ba-9ef0-4ed6-8270-3641ed77a52f' date '28 November 2016' time '4:22:15.120739 pm' author 'topa' ancestors ((name 'ImmutableObjects-topa.8' message 'Naming, consistency, and coding style (+idioms)' id '972cf1d6-a080-4cdc-9150-add6bf15b531' date '28 November 2016' time '3:32:21.382314 pm' author 'topa' ancestors ((name 'ImmutableObjects-jc.7' message 'Introduce Behavior>>immutableFrom:' id 'e23b7e19-1965-4fed-a136-7ac3cf98ff23' date '28 November 2016' time '1:16:32.931351 pm' author 'jc' ancestors ((name 'ImmutableObjects-fn.6' message 'Introduce Object>>asImmutable:' id '59d77511-df73-4012-99ab-f3e8a011b5f1' date '28 November 2016' time '11:26:11.454812 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.5' message 'Add Behavior>>allImmutableInstances' id 'df54e420-4021-4280-ad99-f856e90d9936' date '28 November 2016' time '1:46:49.974355 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.4' message 'New implementation via immutableCopy' id 'e35dfa12-ad91-43a2-90c0-b071cee29c34' date '28 November 2016' time '12:58:22.32651 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.3' message 'Switch to array implementation' id '130935ab-6103-44b0-95cc-099debbf67dd' date '21 November 2016' time '10:54:07.640112 am' author 'fn' ancestors ((name 'ImmutableObjects-fn.2' message 'Second iteration' id 'c95aad86-2f9d-40a4-a9e2-21e53b8a4db1' date '20 November 2016' time '9:34:56.770639 pm' author 'fn' ancestors ((name 'ImmutableObjects-fn.1' message 'Initial commit' id '36f98fa2-d002-4283-84c8-6943276b0865' date '20 November 2016' time '7:05:00.438521 pm' author 'fn' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ()) \ No newline at end of file From 114793d6abce14ece5fbd537cce38230366db365 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 18:11:50 +0100 Subject: [PATCH 53/63] Fix compilation --- rsqueakvm/plugins/immutability_plugin.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index 3591d7e8..b75c5722 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -78,6 +78,7 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): if argcount == 0: raise PrimitiveFailedError w_args = s_frame.pop_and_return_n(argcount)[:] + w_first_arg = w_args[0] w_cls = s_frame.pop() space = interp.space instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() @@ -86,10 +87,10 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): cls = select_immutable_pointers_class(w_args) return cls(space, w_cls, w_args) elif (instance_kind == BYTES and - len(w_args) == 1 and isinstance(w_args[0], W_BytesObject)): - return W_Immutable_BytesObject(space, w_cls, w_args[0].bytes) + len(w_args) == 1 and isinstance(w_first_arg, W_BytesObject)): + return W_Immutable_BytesObject(space, w_cls, w_first_arg.bytes) elif (instance_kind == WORDS and - len(w_args) == 1 and isinstance(w_args[0], W_WordsObject)): - return W_Immutable_WordsObject(space, w_cls, w_args[0].words) + len(w_args) == 1 and isinstance(w_first_arg, W_WordsObject)): + return W_Immutable_WordsObject(space, w_cls, w_first_arg.words) raise PrimitiveFailedError From 50e5bd1ece3f06fc22704411dfd77b9bba56ee8c Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 19:26:12 +0100 Subject: [PATCH 54/63] Make primitiveImmutableFromArgs consistent --- rsqueakvm/plugins/immutability/bytes.py | 4 ++-- rsqueakvm/plugins/immutability/words.py | 4 ++-- rsqueakvm/plugins/immutability_plugin.py | 21 +++++++++++++-------- rsqueakvm/test/test_immutability_plugin.py | 6 +++--- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index 04e47d37..19dde687 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -13,7 +13,7 @@ class W_Immutable_BytesObject(W_BytesObject): _immutable_fields_ = ['immutable_bytes'] repr_classname = '%s_Immutable' % W_BytesObject.repr_classname - def __init__(self, space, w_cls, bytes_w): + def __init__(self, space, w_cls, bytes): """ Initialize immutable bytes object and store its bytes in `self.immutable_bytes` slot. @@ -21,7 +21,7 @@ def __init__(self, space, w_cls, bytes_w): because there is no need to `self.mutate()` and set `self.bytes`. """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.immutable_bytes = bytes_w + self.immutable_bytes = bytes @jit.elidable def _bytes(self): diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index e589f501..1d251356 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -13,7 +13,7 @@ class W_Immutable_WordsObject(W_WordsObject): _immutable_fields_ = ['immutable_words'] repr_classname = '%s_Immutable' % W_WordsObject.repr_classname - def __init__(self, space, w_cls, words_w): + def __init__(self, space, w_cls, words): """ Initialize immutable words object and store its words in `self.immutable_words` slot. @@ -21,7 +21,7 @@ def __init__(self, space, w_cls, words_w): called, because there is no need to initialize `self.words`. """ W_AbstractObjectWithClassReference.__init__(self, space, w_cls) - self.immutable_words = words_w + self.immutable_words = words @jit.elidable def _words(self): diff --git a/rsqueakvm/plugins/immutability_plugin.py b/rsqueakvm/plugins/immutability_plugin.py index b75c5722..5bcd294e 100644 --- a/rsqueakvm/plugins/immutability_plugin.py +++ b/rsqueakvm/plugins/immutability_plugin.py @@ -6,7 +6,7 @@ `/repository`, needs to be loaded in the image. """ -from rsqueakvm.error import PrimitiveFailedError +from rsqueakvm.error import PrimitiveFailedError, UnwrappingError from rsqueakvm.model.variable import W_BytesObject, W_WordsObject from rsqueakvm.plugins.immutability import patch_w_object from rsqueakvm.plugins.immutability.bytes import W_Immutable_BytesObject @@ -78,7 +78,6 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): if argcount == 0: raise PrimitiveFailedError w_args = s_frame.pop_and_return_n(argcount)[:] - w_first_arg = w_args[0] w_cls = s_frame.pop() space = interp.space instance_kind = w_cls.as_class_get_shadow(space).get_instance_kind() @@ -86,11 +85,17 @@ def primitiveImmutableFromArgs(interp, s_frame, argcount): if instance_kind == POINTERS: cls = select_immutable_pointers_class(w_args) return cls(space, w_cls, w_args) - elif (instance_kind == BYTES and - len(w_args) == 1 and isinstance(w_first_arg, W_BytesObject)): - return W_Immutable_BytesObject(space, w_cls, w_first_arg.bytes) - elif (instance_kind == WORDS and - len(w_args) == 1 and isinstance(w_first_arg, W_WordsObject)): - return W_Immutable_WordsObject(space, w_cls, w_first_arg.words) + elif instance_kind == BYTES: + try: + bytes = [chr(interp.space.unwrap_uint(b)) for b in w_args] + except (ValueError, TypeError, UnwrappingError): + raise PrimitiveFailedError + return W_Immutable_BytesObject(space, w_cls, bytes) + elif instance_kind == WORDS: + try: + words = [interp.space.unwrap_uint(b) for b in w_args] + except UnwrappingError: + raise PrimitiveFailedError + return W_Immutable_WordsObject(space, w_cls, words) raise PrimitiveFailedError diff --git a/rsqueakvm/test/test_immutability_plugin.py b/rsqueakvm/test/test_immutability_plugin.py index f64ae073..65010d47 100644 --- a/rsqueakvm/test/test_immutability_plugin.py +++ b/rsqueakvm/test/test_immutability_plugin.py @@ -36,9 +36,9 @@ def test_W_Immutable_BytesObject(): assert w_ibytes.is_immutable() assert w_ibytes.getclass(space).is_same_object(w_class) assert w_ibytes.size() == 20 - assert w_ibytes.getchar(3) == "\x00" - w_ibytes.setchar(3, "\xAA") - assert w_ibytes.getchar(3) == "\x00" + assert w_ibytes.getchar(3) == '\x00' + w_ibytes.setchar(3, '\xAA') + assert w_ibytes.getchar(3) == '\x00' py.test.raises(IndexError, lambda: w_ibytes.getchar(20)) From c285c197573792e442f2c44812cb5c1d6b87b85e Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 19:26:25 +0100 Subject: [PATCH 55/63] Minor cleanups --- rsqueakvm/model/variable.py | 2 -- rsqueakvm/test/test_model.py | 16 ++++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/rsqueakvm/model/variable.py b/rsqueakvm/model/variable.py index 84fb020f..6fc6f74b 100644 --- a/rsqueakvm/model/variable.py +++ b/rsqueakvm/model/variable.py @@ -4,8 +4,6 @@ from rpython.rlib import jit from rpython.rlib.rarithmetic import intmask, r_uint, r_uint32, r_int64 -from rpython.rlib.objectmodel import we_are_translated, always_inline, specialize -from rpython.rtyper.lltypesystem import lltype, rffi class W_BytesObject(W_AbstractObjectWithClassReference): diff --git a/rsqueakvm/test/test_model.py b/rsqueakvm/test/test_model.py index afb50837..d9750860 100644 --- a/rsqueakvm/test/test_model.py +++ b/rsqueakvm/test/test_model.py @@ -74,15 +74,15 @@ def test_bytes_object(): def test_word_object(): w_class = bootstrap_class(0, format=storage_classes.WORDS) - w_bytes = w_class.as_class_get_shadow(space).new(20) - assert w_bytes.getclass(space).is_same_object(w_class) - assert w_bytes.size() == 20 + w_words = w_class.as_class_get_shadow(space).new(20) + assert w_words.getclass(space).is_same_object(w_class) + assert w_words.size() == 20 assert w_class.as_class_get_shadow(space).instsize() == 0 - assert w_bytes.getword(3) == 0 - w_bytes.setword(3, 42) - assert w_bytes.getword(3) == 42 - assert w_bytes.getword(0) == 0 - py.test.raises(AssertionError, lambda: w_bytes.getword(20)) + assert w_words.getword(3) == 0 + w_words.setword(3, 42) + assert w_words.getword(3) == 42 + assert w_words.getword(0) == 0 + py.test.raises(AssertionError, lambda: w_words.getword(20)) def test_method_lookup(): class mockmethod(object): From ee7ad22f823495a034a87810fc145c2cb43663e3 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Wed, 8 Feb 2017 19:50:50 +0100 Subject: [PATCH 56/63] Remove jit.elidables The return values are already listed as immutable --- rsqueakvm/plugins/immutability/bytes.py | 3 --- rsqueakvm/plugins/immutability/words.py | 3 --- 2 files changed, 6 deletions(-) diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index 19dde687..9873c404 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -4,8 +4,6 @@ from rsqueakvm.model.variable import W_BytesObject from rsqueakvm.plugins.immutability import immutable_class -from rpython.rlib import jit - @immutable_class class W_Immutable_BytesObject(W_BytesObject): @@ -23,7 +21,6 @@ def __init__(self, space, w_cls, bytes): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_bytes = bytes - @jit.elidable def _bytes(self): """ `W_BytesObject._bytes(self)` override. diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index 1d251356..815f593d 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -4,8 +4,6 @@ from rsqueakvm.model.variable import W_WordsObject from rsqueakvm.plugins.immutability import immutable_class -from rpython.rlib import jit - @immutable_class class W_Immutable_WordsObject(W_WordsObject): @@ -23,7 +21,6 @@ def __init__(self, space, w_cls, words): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_words = words - @jit.elidable def _words(self): """ `W_WordsObject._words(self)` override. From fb73fdb9f6b07de0847bc5bab0969d486e750bb3 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 9 Feb 2017 11:04:19 +0100 Subject: [PATCH 57/63] Add minor comment [ci skip] --- rsqueakvm/plugins/immutability/bytes.py | 1 + rsqueakvm/plugins/immutability/words.py | 1 + 2 files changed, 2 insertions(+) diff --git a/rsqueakvm/plugins/immutability/bytes.py b/rsqueakvm/plugins/immutability/bytes.py index 9873c404..259fc2bd 100644 --- a/rsqueakvm/plugins/immutability/bytes.py +++ b/rsqueakvm/plugins/immutability/bytes.py @@ -21,6 +21,7 @@ def __init__(self, space, w_cls, bytes): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_bytes = bytes + # No need to make this jit.elidable, jit can prove return val is constant. def _bytes(self): """ `W_BytesObject._bytes(self)` override. diff --git a/rsqueakvm/plugins/immutability/words.py b/rsqueakvm/plugins/immutability/words.py index 815f593d..2b3df6d9 100644 --- a/rsqueakvm/plugins/immutability/words.py +++ b/rsqueakvm/plugins/immutability/words.py @@ -21,6 +21,7 @@ def __init__(self, space, w_cls, words): W_AbstractObjectWithClassReference.__init__(self, space, w_cls) self.immutable_words = words + # No need to make this jit.elidable, jit can prove return val is constant. def _words(self): """ `W_WordsObject._words(self)` override. From 916ee9d3c97b24f8a3a91af99aeb0d517bf90d83 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 9 Feb 2017 11:10:46 +0100 Subject: [PATCH 58/63] Minor addition [ci skip] --- rsqueakvm/plugins/immutability/pointers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rsqueakvm/plugins/immutability/pointers.py b/rsqueakvm/plugins/immutability/pointers.py index 593dce1d..9716350e 100644 --- a/rsqueakvm/plugins/immutability/pointers.py +++ b/rsqueakvm/plugins/immutability/pointers.py @@ -9,6 +9,13 @@ .. data:: POINTERS_CLASS_ITER Unrolling iterable of `POINTERS_CLASSES`. + +.. data:: STORAGE_ATTR_TEMPLATE +Storage attribute template. + +.. data:: MAX_FIXED_SLOTS +Number of immutable subclasses with fixed number of slots to generate. + """ from rsqueakvm.model.base import W_AbstractObjectWithIdentityHash @@ -21,6 +28,8 @@ STORAGE_ATTR_TEMPLATE = "storage_%d" +MAX_FIXED_SLOTS = 9 + @immutable_class class W_AbstractImmutable_PointersObject(W_PointersObject): @@ -115,7 +124,7 @@ def fetch(self, space, n0): return W_FixedImmutable_PointersObject POINTERS_CLASSES = [] -for n_storage in range(0, 10): +for n_storage in range(0, MAX_FIXED_SLOTS + 1): POINTERS_CLASSES.append(generate_fixed_immutable_subclass(n_storage)) POINTERS_CLASSES.append(W_Immutable_PointersObject) POINTERS_CLASS_ITER = unrolling_iterable(enumerate(POINTERS_CLASSES)) From 02a07180cf5ef3ed598e092b60cacb314ba45c2f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 9 Feb 2017 11:30:40 +0100 Subject: [PATCH 59/63] Unset theme And use readthedocs theme by default [ci skip] --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 5f4effcc..3f4c9007 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -97,7 +97,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +# html_theme = 'alabaster' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the From 419ba56d1f7c1bfb8bf52b1bf6688dcc4963c44f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 9 Feb 2017 12:11:19 +0100 Subject: [PATCH 60/63] Move contents from README.md to docs and clean up README.md [ci skip] --- README.md | 170 +++++++++------------------------- docs/building_from_source.rst | 53 +++++++++++ docs/development.rst | 81 ++++++++++++++++ docs/index.rst | 3 + 4 files changed, 179 insertions(+), 128 deletions(-) create mode 100644 docs/building_from_source.rst create mode 100644 docs/development.rst diff --git a/README.md b/README.md index 690eaf53..b0f62399 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -## RSqueak/VM [![Linux Build Status](https://travis-ci.org/HPI-SWA-Lab/RSqueak.svg?branch=master)](https://travis-ci.org/HPI-SWA-Lab/RSqueak) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/e37a79tt5irr7sx1/branch/master?svg=true)](https://ci.appveyor.com/project/timfel/rsqueak) [![Coverage Status](https://coveralls.io/repos/github/HPI-SWA-Lab/RSqueak/badge.svg?branch=master)](https://coveralls.io/github/HPI-SWA-Lab/RSqueak?branch=master) [![Benchmarks](https://img.shields.io/badge/benchmarks-open-yellowgreen.svg)](http://speed.squeak.org/) [![Documentation Status](https://readthedocs.org/projects/rsqueak/badge/?version=latest)](http://rsqueak.readthedocs.io/en/latest/?badge=latest) +## RSqueak/VM [![Linux Build Status][travis_badge]][travis] [![Windows Build Status][appveyor_badge]][appveyor] [![Coverage Status][coveralls_badge]][coveralls] [![Benchmarks][benchmarks_badge]][benchmarks] [![Documentation Status][docs_badge]][docs] A Squeak VM written in RPython. ### Download -All-in-One bundle for Linux, Windows and OS X: +All-in-One bundle for Linux, Windows and macOS: -[![Download zip](https://img.shields.io/badge/Download-zip-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.zip) [![Download tar.gz](https://img.shields.io/badge/Download-tar.gz-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.tar.gz) +[![Download zip][dl_zip_badge]][dl_zip] [![Download tar.gz][dl_tgz_badge]][dl_tgz] Pre-built 32-bit binaries: -[![Download Linux](https://img.shields.io/badge/Download-Linux-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-latest) [![Download Mac OS X](https://img.shields.io/badge/Download-Mac_OS_X-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-latest) [![Download Windows](https://img.shields.io/badge/Download-Windows-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-win32-latest.exe) +[![Download Linux][dl_linux_badge]][dl_linux] [![Download macOS][dl_macos_badge]][dl_macos] [![Download Windows][dl_win_badge]][dl_win] Pre-built 64-bit binaries (note that the goal for RSqueak/VM to support all image formats that are <= the native word size - so the 64-bit VMs should open @@ -18,11 +18,11 @@ both 32-bit and 64-bit images; it should simply be faster. Due to limitations of the underlying RPython toolchain, Windows binaries cannot currently be built in 64-bit mode): -[![Download Linux x86_64](https://img.shields.io/badge/Download-Linux_x86__64-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-x86_64-latest) [![Download Mac OS X x86_64](https://img.shields.io/badge/Download-Mac%20OS%20X%20x86__64-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-x86_64-latest) +[![Download Linux x86_64][dl_linux64_badge]][dl_linux64] [![Download macOS x86_64][dl_macos64_badge]][dl_macos64] We also have experimental builds for Raspberry Pi: -[![Download Raspberry Pi 1](https://img.shields.io/badge/Download-Raspberry_Pi_1-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv6raspbian-latest) [![Download Raspberry Pi 2](https://img.shields.io/badge/Download-Raspberry_Pi_2-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv7-araspbian-latest) [![Download Raspberry Pi 3](https://img.shields.io/badge/Download-Raspberry_Pi_3-blue.svg)](https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv8-araspbian-latest) +[![Download Raspberry Pi 1][dl_raspi1_badge]][dl_raspi1] [![Download Raspberry Pi 2][dl_raspi2_badge]][dl_raspi2] [![Download Raspberry Pi 3][dl_raspi3_badge]][dl_raspi3] ### Finding a working image @@ -42,125 +42,39 @@ Note that RSqueak/VM will *always* save images in 32-bit Cog-Spur format, regardless of what it was when you opened it. So make sure to save as new version if you want to keep the original around. -### Building from Source - -###### Common to all systems - -We have scripts for installing dependencies, building, running the unit tests, -and running JIT tests in the `.build` subdirectory. You need the `PyPy` source -tree, and the `rsdl` source tree. If you already have all these, run -`.build/build.py --32bit` to build 32-bit VM. Run `.build/build.py` to compile a -64-bit VM. The script passes all other arguments on to the `rpython` translator, -so you can pass other options. - -It will generate a config file `.build/buildconfig.ini` where you can set your -paths. You can also run `.build/download_dependencies.py` to download the -dependencies automatically. You will also need a Python and a C compiler for -32-bit compilation, if you plan to do 32-bit development. - -###### Windows - -On Windows, you will have to use the C compiler that comes with Visual Studio -2008, because newer ones crash the JIT. It suffices to just install the -[Microsoft C compiler V90 plus Windows SDK 7](https://github.com/HPI-SWA-Lab/RSqueak/releases/download/Dependencies/vc_stdx86.zip). -Also, install the [Python 2.7 Visual Studio compiler package](aka.ms/vcpython27). -The -packages provided in the link install it to the default paths. If you already -have the compiler and SDK, you can also just update the paths in -`.build/buildconfig.ini`. - -###### Linux - -RSqueak/VM can currently be compiled in both 32-bit and 64-bit -configurations. For 32-bit, you need to use 32-bit python and SDL2 using 32-bit -libraries for everything. The easiest way to ensure that is to use a chroot, but -you can also install the `:i386` versions of the SDL2 dependencies for your -distro. - -###### Mac OS X - -To compile RSqueak/VM for 32-bit, run - -```bash -export VERSIONER_PYTHON_PREFER_32_BIT=yes -``` - -before you run any of the python scripts in the `.build` directory. You also -need to download SDL2 as a framework (homebrew version is not tested). Check -the `.travis/build-osx.sh` if you get stuck anywhere. - -### Developing - -The `.build` directory includes several scripts that make development -easier. Once you've setup your system for building, you can use these -to work on the RSqueak/VM. - -###### run.py - -This script executes RSqueak/VM in *hosted* mode, that is, it runs on -top of a Python interpreter. This is very slow (we recommend using PyPy), -but it can be useful to debug specific aspects of the VM quickly. Ideally, -you set up an image so that it executes the code that you are interested in -early during startup (`DisplayScreen class>>startUp` is a good candidate) -and then you add your breakpoints to the source. You can also pass commandline -arguments to the script or tweak the default arguments in the script itself. - -__Running a "Smalltalk REPL"__ - -When you want to work on primitives or plugins, it is useful to prepare an image -a little (for example, make it so test runs print to the console), and then run -the following: - -```bash -pypy .build/run.py --shell -``` - -This will load the image and dump you in a simple REPL for Smalltalk, but with -some commands to help you execute Python code and, in particular, to reload the -Python code you write in any plugin or primitive file. Thus, you can run some -Smalltalk code, check for errors, change the primitive code, reload it, and try -again. This avoids having to reload the image in interpreted mode all the time -(which can be slow). - -There is an integrated help that you can get by typing !help, and there is -limited autocomplete, too. - -Note that the REPL only loads the image, but does not process startup. For many -things, you might want to run `FileStream startUp: true` or `Delay startUp` to -get basic I/O working or delays working. - -###### unittests.py - -The second script that is useful for working on issues regarding the -interpreter is `unittests.py`. By default it runs all tests under the -`rsqueakvm/test` directory (but not those in `rsqueakvm/test/jittest/`). This -is a standalone pytest script, so you can pass arguments or select single -test files as you would for pytest. - -###### jittests.py - -This script requires that you have already built an `rsqueak` binary and -that you have the C Squeak VM installed. It executes the tests in -`rsqueakvm/test/jittest/` and checks for the JIT output. We use these tests to -ensure that development on the VM does not break JIT optimizations. - -###### jit.py - -This script is useful to figure out what the JIT is doing. Like `run.py`, -it executes the RSqueak/VM in hosted mode, but this time it also simulates -the JIT. This is even slower, but allows us to test small code snippets -without having to retranslate the entire VM. The code snippets are configured -directly in the file. When you run it, it does part of the translation process -(but only enough to execute your specific code) and then runs the code. When -the JIT kicks in, the compiled loop is shown in a PyGame window. You can then -inspect it at your leisure and when you quit the window, the code continues -executing. In order for this to work, you need to have `pygame` and `graphviz` -installed and in your PATH. - -###### shell.py - -This script sets all the environment variables as if for translating the VM, -and the drops you into an interactive Python prompt. You can type `terminal()` -to drop into a system shell (`%COMSPEC%` on Windows `$SHELL` or `/bin/sh` on -Unices) which then has all the environment variables set up that you need to -do manual partial translations or similar things. +### [Building from Source][build_from_source] +### [Development][development] + + +[appveyor]: https://ci.appveyor.com/project/timfel/rsqueak +[appveyor_badge]: https://ci.appveyor.com/api/projects/status/e37a79tt5irr7sx1/branch/master?svg=true +[benchmarks]: http://speed.squeak.org/ +[benchmarks_badge]: https://img.shields.io/badge/benchmarks-open-yellowgreen.svg +[build_from_source]: http://rsqueak.readthedocs.io/en/latest/building_from_source.html +[coveralls]: https://coveralls.io/github/HPI-SWA-Lab/RSqueak?branch=master +[coveralls_badge]: https://coveralls.io/repos/github/HPI-SWA-Lab/RSqueak/badge.svg?branch=master +[development]: http://rsqueak.readthedocs.io/en/latest/development.html +[dl_linux64]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-x86_64-latest +[dl_linux64_badge]: https://img.shields.io/badge/Download-Linux_x86__64-blue.svg +[dl_linux]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-latest +[dl_linux_badge]: https://img.shields.io/badge/Download-Linux-blue.svg +[dl_macos64]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-x86_64-latest +[dl_macos64_badge]: https://img.shields.io/badge/Download-Mac%20OS%20X%20x86__64-blue.svg +[dl_macos]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-darwin-latest +[dl_macos_badge]: https://img.shields.io/badge/Download-Mac_OS_X-blue.svg +[dl_raspi1]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv6raspbian-latest +[dl_raspi1_badge]: https://img.shields.io/badge/Download-Raspberry_Pi_1-blue.svg +[dl_raspi2]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv7-araspbian-latest +[dl_raspi2_badge]: https://img.shields.io/badge/Download-Raspberry_Pi_2-blue.svg +[dl_raspi3]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-linux-armv8-araspbian-latest +[dl_raspi3_badge]: https://img.shields.io/badge/Download-Raspberry_Pi_3-blue.svg +[dl_tgz]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.tar.gz +[dl_tgz_badge]: https://img.shields.io/badge/Download-tar.gz-blue.svg +[dl_win]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/rsqueak-win32-latest.exe +[dl_win_badge]: https://img.shields.io/badge/Download-Windows-blue.svg +[dl_zip]: https://www.hpi.uni-potsdam.de/hirschfeld/artefacts/rsqueak/bundle/RSqueak.zip +[dl_zip_badge]: https://img.shields.io/badge/Download-zip-blue.svg +[docs]: http://rsqueak.readthedocs.io/en/latest/?badge=latest +[docs_badge]: https://readthedocs.org/projects/rsqueak/badge/?version=latest +[travis]: https://travis-ci.org/HPI-SWA-Lab/RSqueak +[travis_badge]: https://travis-ci.org/HPI-SWA-Lab/RSqueak.svg?branch=master diff --git a/docs/building_from_source.rst b/docs/building_from_source.rst new file mode 100644 index 00000000..db809dc2 --- /dev/null +++ b/docs/building_from_source.rst @@ -0,0 +1,53 @@ +Building from Source +===================== + +Common to all systems +---------------------- + +We have scripts for installing dependencies, building, running the unit tests, +and running JIT tests in the `.build` subdirectory. You need the `PyPy` source +tree, and the `rsdl` source tree. If you already have all these, run +`.build/build.py --32bit` to build 32-bit VM. Run `.build/build.py` to compile a +64-bit VM. The script passes all other arguments on to the `rpython` translator, +so you can pass other options. + +It will generate a config file `.build/buildconfig.ini` where you can set your +paths. You can also run `.build/download_dependencies.py` to download the +dependencies automatically. You will also need a Python and a C compiler for +32-bit compilation, if you plan to do 32-bit development. + +Windows +-------- + +On Windows, you will have to use the C compiler that comes with Visual Studio +2008, because newer ones crash the JIT. It suffices to just install the +`Microsoft C compiler V90 plus Windows SDK 7`_. +Also, install the `Python 2.7 Visual Studio compiler package`_. +The packages provided in the link install it to the default paths. If you +already have the compiler and SDK, you can also just update the paths in +`.build/buildconfig.ini`. + +.. _Microsoft C compiler V90 plus Windows SDK 7: https://github.com/HPI-SWA-Lab/RSqueak/releases/download/Dependencies/vc_stdx86.zip +.. _Python 2.7 Visual Studio compiler package: https://aka.ms/vcpython27 + +Linux +------ + +RSqueak/VM can currently be compiled in both 32-bit and 64-bit +configurations. For 32-bit, you need to use 32-bit python and SDL2 using 32-bit +libraries for everything. The easiest way to ensure that is to use a chroot, but +you can also install the `:i386` versions of the SDL2 dependencies for your +distro. + +Mac OS X +--------- + +To compile RSqueak/VM for 32-bit, run + +.. code-block:: bash + + export VERSIONER_PYTHON_PREFER_32_BIT=yes + +before you run any of the python scripts in the `.build` directory. You also +need to download SDL2 as a framework (homebrew version is not tested). Check +the `.travis/build-osx.sh` if you get stuck anywhere. \ No newline at end of file diff --git a/docs/development.rst b/docs/development.rst new file mode 100644 index 00000000..bad2e2ef --- /dev/null +++ b/docs/development.rst @@ -0,0 +1,81 @@ +Development +====================================== + +The `.build` directory includes several scripts that make development +easier. Once you've setup your system for building, you can use these +to work on the RSqueak/VM. + +run.py +---------- + +This script executes RSqueak/VM in *hosted* mode, that is, it runs on +top of a Python interpreter. This is very slow (we recommend using PyPy), +but it can be useful to debug specific aspects of the VM quickly. Ideally, +you set up an image so that it executes the code that you are interested in +early during startup (`DisplayScreen class>>startUp` is a good candidate) +and then you add your breakpoints to the source. You can also pass commandline +arguments to the script or tweak the default arguments in the script itself. + +*Running a "Smalltalk REPL"* + +When you want to work on primitives or plugins, it is useful to prepare an image +a little (for example, make it so test runs print to the console), and then run +the following: + +.. code-block:: bash + + pypy .build/run.py --shell + +This will load the image and dump you in a simple REPL for Smalltalk, but with +some commands to help you execute Python code and, in particular, to reload the +Python code you write in any plugin or primitive file. Thus, you can run some +Smalltalk code, check for errors, change the primitive code, reload it, and try +again. This avoids having to reload the image in interpreted mode all the time +(which can be slow). + +There is an integrated help that you can get by typing !help, and there is +limited autocomplete, too. + +Note that the REPL only loads the image, but does not process startup. For many +things, you might want to run `FileStream startUp: true` or `Delay startUp` to +get basic I/O working or delays working. + +unittests.py +------------- + +The second script that is useful for working on issues regarding the +interpreter is `unittests.py`. By default it runs all tests under the +`rsqueakvm/test` directory (but not those in `rsqueakvm/test/jittest/`). This +is a standalone pytest script, so you can pass arguments or select single +test files as you would for pytest. + +jittests.py +------------ + +This script requires that you have already built an `rsqueak` binary and +that you have the C Squeak VM installed. It executes the tests in +`rsqueakvm/test/jittest/` and checks for the JIT output. We use these tests to +ensure that development on the VM does not break JIT optimizations. + +jit.py +------- + +This script is useful to figure out what the JIT is doing. Like `run.py`, +it executes the RSqueak/VM in hosted mode, but this time it also simulates +the JIT. This is even slower, but allows us to test small code snippets +without having to retranslate the entire VM. The code snippets are configured +directly in the file. When you run it, it does part of the translation process +(but only enough to execute your specific code) and then runs the code. When +the JIT kicks in, the compiled loop is shown in a PyGame window. You can then +inspect it at your leisure and when you quit the window, the code continues +executing. In order for this to work, you need to have `pygame` and `graphviz` +installed and in your PATH. + +shell.py +--------- + +This script sets all the environment variables as if for translating the VM, +and the drops you into an interactive Python prompt. You can type `terminal()` +to drop into a system shell (`%COMSPEC%` on Windows `$SHELL` or `/bin/sh` on +Unices) which then has all the environment variables set up that you need to +do manual partial translations or similar things. diff --git a/docs/index.rst b/docs/index.rst index 98d3540c..c7b7e7e0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,6 +10,9 @@ RSqueak/VM's documentation :maxdepth: 2 :caption: Contents: + building_from_source + development + .. toctree:: :maxdepth: 4 From f433def58211a45a20b0cacc418742883ca40490 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 9 Feb 2017 12:20:43 +0100 Subject: [PATCH 61/63] OS X -> macOS [ci skip] --- .travis/{build-osx.sh => build-macos.sh} | 0 .travis/build.sh | 2 +- .travis/install_requirements.sh | 4 ++-- docs/building_from_source.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename .travis/{build-osx.sh => build-macos.sh} (100%) diff --git a/.travis/build-osx.sh b/.travis/build-macos.sh similarity index 100% rename from .travis/build-osx.sh rename to .travis/build-macos.sh diff --git a/.travis/build.sh b/.travis/build.sh index 4f54e5c4..732f406b 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -21,7 +21,7 @@ case "$TRAVIS_OS_NAME" in fi # set up PKG_CONFIG_PATH in order to use openssl installed via Homebrew export PKG_CONFIG_PATH=$(brew --prefix)/opt/openssl/lib/pkgconfig - SCRIPT_NAME="build-osx.sh" + SCRIPT_NAME="build-macos.sh" ;; esac diff --git a/.travis/install_requirements.sh b/.travis/install_requirements.sh index caee7e3d..5e08f391 100755 --- a/.travis/install_requirements.sh +++ b/.travis/install_requirements.sh @@ -4,7 +4,7 @@ set -ex readonly BASE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" presetup_osx() { - echo "OS X Pre-setup" + echo "macOS Pre-setup" } setup_osx() { @@ -21,7 +21,7 @@ setup_osx() { # todo: Squeak for jittests - # Don't install coveralls on OS X, because it's too slow (see #116) + # Don't install coveralls on macOS, because it's too slow (see #116) # curl -L -O https://bootstrap.pypa.io/get-pip.py # sudo python get-pip.py # sudo pip install coveralls pytest-cov diff --git a/docs/building_from_source.rst b/docs/building_from_source.rst index db809dc2..602bd711 100644 --- a/docs/building_from_source.rst +++ b/docs/building_from_source.rst @@ -39,7 +39,7 @@ libraries for everything. The easiest way to ensure that is to use a chroot, but you can also install the `:i386` versions of the SDL2 dependencies for your distro. -Mac OS X +macOS --------- To compile RSqueak/VM for 32-bit, run From df066030d2a3c76e7bd0c3f74d6f93f944799fb0 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Tue, 24 Jan 2017 14:29:24 +0100 Subject: [PATCH 62/63] fix sending of two keystrokes on linux --- rsqueakvm/display.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/rsqueakvm/display.py b/rsqueakvm/display.py index fbad0210..e0ca4d53 100644 --- a/rsqueakvm/display.py +++ b/rsqueakvm/display.py @@ -426,12 +426,14 @@ def get_next_event(self, time=0): return self.get_next_mouse_wheel_event(time, event) elif event_type == RSDL.KEYDOWN: self.handle_keyboard_event(event_type, event) - if not self.is_modifier_key(self.key) and ( - self.is_control_key(self.key) - or RSDL.GetModState() & ~RSDL.KMOD_SHIFT != 0): - # no TEXTINPUT event for this key will follow - # but Squeak needs a KeyStroke anyway - self._deferred_events.append(self.get_next_key_event(EventKeyChar, time)) + if not self.is_modifier_key(self.key): + # no TEXTINPUT event for this key will follow, but + # Squeak needs a KeyStroke anyway + if ((system.IS_LINUX and self.is_control_key(self.key)) or + (not system.IS_LINUX and + (self.is_control_key(self.key) or + RSDL.GetModState() & ~RSDL.KMOD_SHIFT != 0))): + self._deferred_events.append(self.get_next_key_event(EventKeyChar, time)) self.fix_key_code_case() return self.get_next_key_event(EventKeyDown, time) elif event_type == RSDL.TEXTINPUT: From d75dfa9c706c11b0582700bb2fffac9bd658d522 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 1 Feb 2017 13:57:03 +0100 Subject: [PATCH 63/63] fix keystroke tests on linux --- rsqueakvm/test/test_display.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rsqueakvm/test/test_display.py b/rsqueakvm/test/test_display.py index 4c9604f1..65647614 100644 --- a/rsqueakvm/test/test_display.py +++ b/rsqueakvm/test/test_display.py @@ -269,10 +269,22 @@ def test_keyboard_chords(sut, mocked_sdl_event_queue, stub_events, stub_mod_stat mocked_sdl_event_queue.append(a_down) sqADown = sut.get_next_event() # A entered + if system.IS_LINUX: + # on linux, we don't get this + a_stroke = stub_events.malloc(RSDL.TextInputEvent) + a_stroke.c_type = RSDL.TEXTINPUT + rffi.str2chararray('a\x00', a_stroke.c_text, RSDL.TEXTINPUTEVENT_TEXT_SIZE) + mocked_sdl_event_queue.append(a_stroke) sqAStroke = sut.get_next_event() # repeat A mocked_sdl_event_queue.append(a_down) sqADown2 = sut.get_next_event() + if system.IS_LINUX: + # on linux, we don't get this + a_stroke = stub_events.malloc(RSDL.TextInputEvent) + a_stroke.c_type = RSDL.TEXTINPUT + rffi.str2chararray('a\x00', a_stroke.c_text, RSDL.TEXTINPUTEVENT_TEXT_SIZE) + mocked_sdl_event_queue.append(a_stroke) sqAStroke2 = sut.get_next_event() # A up a_up = stub_events.malloc(RSDL.KeyboardEvent)