Skip to content

Commit

Permalink
Mega refactoring and reworking.
Browse files Browse the repository at this point in the history
  • Loading branch information
stlutz committed Jul 29, 2019
1 parent 5813240 commit c6ec1ea
Show file tree
Hide file tree
Showing 211 changed files with 371 additions and 448 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Squeak-ActiveExpressions [![Build Status][travis_b]][travis_url] [![Coverage Status][coveralls_b]][coveralls_url]
# ActiveExpression/S [![Build Status][travis_b]][travis_url] [![Coverage Status][coveralls_b]][coveralls_url]

Squeak-ActiveExpressions aims to offer an implementation of [Active Expressions] in Squeak.
ActiveExpression/S aims to offer an implementation of [Active Expressions] in [Squeak/Smalltalk][Squeak].

## Installation Instructions

ActiveExpressions are compatible with Squeak-5.1 and Squeak-trunk (check Travis for more information). First install the latest [Metacello], then you can use the following code to load ActiveExpressions and all their prerequisites:
ActiveExpression/S is compatible with Squeak-5.2 and Squeak-trunk (check Travis for more information). First install the latest [Metacello], then you can use the following code to load ActiveExpression/S and all its prerequisites:

```
Metacello new
Expand Down Expand Up @@ -105,6 +105,8 @@ A more complete implementation of Active Expressions in JavaScript which is also

[Active Expressions]: http://programming-journal.org/2017/1/12/
[JavaScript Implementation]: https://github.com/active-expressions/active-expressions

[Squeak]: https://squeak.org
[Metacello]: https://github.com/Metacello/metacello

[Issues]: https://github.com/stlutz/Squeak-ActiveExpressions/tree/master/src/ActiveExpressions-Examples.package/AExpIssues.class
Expand Down
12 changes: 12 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- tests
- simulation
- quick methods
- performs
- finds accesses to instVars / tempVars / litVars
- when assignment result is used
- normally
- correct result
- AxLayer
- remember potential side effects during simulation
- fix baseline
- update README
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defaults
defaultType

^ SynchronousActiveExpression

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
instance creation
on: aBlock

| type |
type := self = ActiveExpression ifTrue: [self defaultType] ifFalse: [self].
^ type basicNew
setMonitoredBlock: aBlock;
initialize
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"class" : {
"compilerClass" : "sl 10/12/2018 09:59",
"monitoring:" : "sl 12/26/2017 18:55" },
"defaultType" : "stlu 7/29/2019 08:53",
"on:" : "stlu 7/29/2019 13:54" },
"instance" : {
"addCallback:" : "sl 1/10/2018 19:51",
"callbacks" : "sl 1/10/2018 19:27",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*ActiveExpressions-Core
onChangeDo: aBlock

^ (ActiveExpression monitoring: self) onChangeDo: aBlock
^ (ActiveExpression on: self) onChangeDo: aBlock
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"class" : {
},
"instance" : {
"onChangeDo:" : "sl 1/10/2018 19:36" } }
"onChangeDo:" : "stlu 7/29/2019 13:55" } }

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/ActiveExpressions-Core.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'ActiveExpressions-Core-stlu.4' message 'empty log message' id '34099b2e-56c9-4de8-854a-3865294d1fb1' date '25 February 2019' time '1:34:03.587085 pm' author 'stlu' ancestors ((name 'ActiveExpressions-Core-sl.3' message 'empty log message' id '9aa1eb9e-e325-4bde-bc51-f7868a4fc4ad' date '11 October 2018' time '12:52:43.435234 pm' author 'sl' ancestors ((name 'ActiveExpressions-Core-sl.2' message 'empty log message' id '41ca1443-0aeb-4357-823d-106bb24155a2' date '10 October 2018' time '10:35:53.535738 pm' author 'sl' ancestors ((name 'ActiveExpressions-Core-cypress.1' message 'fabricated from a Cypress format repository' id '2cd42bda-65a2-4a1c-94fb-5a30b7e75183' date '10 October 2018' time '9:53:46.888779 am' author '' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
(name 'ActiveExpressions-Core-stlu.7' message 'empty log message' id 'fe862fff-2263-4c1e-8995-1269a5353e89' date '29 July 2019' time '2:00:04.848422 pm' author 'stlu' ancestors ((name 'ActiveExpressions-Core-stlu.6' message 'empty log message' id '131f6c3a-44ff-43a5-80e1-097d126a3dcd' date '14 March 2019' time '2:07:30.564715 am' author 'stlu' ancestors ((name 'ActiveExpressions-Core-stlu.5' message 'empty log message' id '97781d30-1386-41d9-9f94-14b22edb938b' date '2 March 2019' time '8:48:44.597709 am' author 'stlu' ancestors ((name 'ActiveExpressions-Core-stlu.4' message 'empty log message' id '34099b2e-56c9-4de8-854a-3865294d1fb1' date '25 February 2019' time '1:34:03.587085 pm' author 'stlu' ancestors ((name 'ActiveExpressions-Core-sl.3' message 'empty log message' id '9aa1eb9e-e325-4bde-bc51-f7868a4fc4ad' date '11 October 2018' time '12:52:43.435234 pm' author 'sl' ancestors ((name 'ActiveExpressions-Core-sl.2' message 'empty log message' id '41ca1443-0aeb-4357-823d-106bb24155a2' date '10 October 2018' time '10:35:53.535738 pm' author 'sl' ancestors ((name 'ActiveExpressions-Core-cypress.1' message 'fabricated from a Cypress format repository' id '2cd42bda-65a2-4a1c-94fb-5a30b7e75183' date '10 October 2018' time '9:53:46.888779 am' author '' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"commentStamp" : "",
"instvars" : [
"activeExpression" ],
"name" : "AExpAnnotationMorph",
"name" : "AxAnnotationMorph",
"pools" : [
],
"super" : "Morph",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ testAtomicOperationsAreNotRespected
"Objects often have operations they consider to be atomic, where the state in between a few actions is technically undefined but usually also not visible to the outside world. During that short time frame said obejct can make no guarantees as to its correct functioning (e.g. holding its contracts) - and also doesn't need to. Installing monitors into such an operation causes us to try to use the object at exactly that point in time, which might cause errors."
stack := OrderedCollection withAll: { 1 . 2 . 3 }.
stackSize := 3.
aexp := VarTraActiveExpression monitoring: [self stackTop].
aexp := SynchronousActiveExpression on: [self stackTop].
self atomicOperation "Throws an error trying to access stack (size 3) at index 4"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests
testValueObjectsAlwaysChangeIdentity
"Value objects are usually treated as being identical to each other, so long as they are equal to each other. This is not reflected in their #== comparator, which causes the 'same' value object to be seen by an ActiveExpression as being a change in state."
aexp := ActiveExpression monitoring: [1@1]. "This expression never really changes state."
aexp := ActiveExpression on: [1@1]. "This expression never really changes state."
aexp onChangeDo: [self fail]. "Therefor, this should never be executed."
aexp update. "But it is..."
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@
"stackSize:" : "sl 2/7/2018 22:31",
"stackTop" : "sl 2/7/2018 22:34",
"tearDown" : "sl 2/7/2018 22:09",
"testAtomicOperationsAreNotRespected" : "sl 10/10/2018 10:16",
"testContextMethodsInstVarsAreNotRewritten" : "sl 10/10/2018 10:16",
"testContextMethodsTempVarsAreNotRewritten" : "sl 10/10/2018 10:16",
"testValueObjectsAlwaysChangeIdentity" : "sl 2/7/2018 22:13" } }
"testAtomicOperationsAreNotRespected" : "stlu 7/29/2019 13:54",
"testValueObjectsAlwaysChangeIdentity" : "stlu 7/29/2019 13:55" } }
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"instVar",
"stack",
"stackSize" ],
"name" : "AExpIssues",
"name" : "AxIssues",
"pools" : [
],
"super" : "TestCase",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(name 'ActiveExpressions-Examples-sl.2' message 'empty log message' id '3d983293-fc17-4b60-bd20-fbfa28d508fe' date '10 October 2018' time '10:36:59.308802 pm' author 'sl' ancestors ((name 'ActiveExpressions-Examples-cypress.1' message 'fabricated from a Cypress format repository' id 'cf3f2556-f9c8-43b6-b686-4c70213eb05a' date '10 October 2018' time '9:53:50.185253 am' author '' ancestors () stepChildren ())) stepChildren ())
(name 'ActiveExpressions-Examples-stlu.4' message 'empty log message' id '4c65e06e-ea9b-4eb9-9ef9-cb0162b14060' date '29 July 2019' time '2:40:42.7763 pm' author 'stlu' ancestors ((name 'ActiveExpressions-Examples-stlu.3' message 'empty log message' id '2fb666fb-3e5f-4a39-a945-366d2e6429af' date '29 July 2019' time '2:00:22.424908 pm' author 'stlu' ancestors ((name 'ActiveExpressions-Examples-sl.2' message 'empty log message' id '3d983293-fc17-4b60-bd20-fbfa28d508fe' date '10 October 2018' time '10:36:59.308802 pm' author 'sl' ancestors ((name 'ActiveExpressions-Examples-cypress.1' message 'fabricated from a Cypress format repository' id 'cf3f2556-f9c8-43b6-b686-4c70213eb05a' date '10 October 2018' time '9:53:50.185253 am' author '' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
utility
logContext: aContext stream: aStream offset: offset

offset * 2 timesRepeat: [aStream space].
aContext printOn: aStream.
aStream
cr;
flush
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
simulation
simulate: aBlock

| simulationContext |
aBlock hasMethodReturn
ifTrue: [self error: 'simulation of blocks with ^ can run loose']. "could probably be solved by guarding method returns"
simulationContext := thisContext.
currentContext := topContext := aBlock asContext.
currentContext pushArgs: Array new from: simulationContext.
[currentContext == simulationContext] whileFalse: [
currentContext := currentContext interpretNextInstructionFor: self].
result := simulationContext pop
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
utility
simulate: aBlock log: aStream

| simulationContext depth |
aBlock hasMethodReturn
ifTrue: [self error: 'simulation of blocks with ^ can run loose']. "could probably be solved by guarding method returns"
simulationContext := thisContext.
currentContext := topContext := aBlock asContext.
currentContext pushArgs: Array new from: simulationContext.
aStream nextPutAll: '#################################'; cr.
self logContext: currentContext stream: aStream offset: (depth := 0).
[currentContext == simulationContext] whileFalse: [
| previousContext previousDepth |
previousContext := currentContext.
previousDepth := depth.
currentContext := currentContext interpretNextInstructionFor: self.
depth := currentContext depthBelow: topContext.
(previousDepth < depth and: [currentContext ~~ simulationContext]) ifTrue: [
self logContext: currentContext stream: aStream offset: depth]].
result := simulationContext pop.
aStream flush
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"blockReturnConstant:" : "sl 10/10/2018 16:28",
"blockReturnTop" : "sl 10/10/2018 16:28",
"callPrimitive:" : "sl 10/10/2018 16:31",
"currentContext" : "sl 10/10/2018 13:18",
"directedSuperSend:numArgs:" : "sl 10/10/2018 16:32",
"doDup" : "sl 10/10/2018 16:32",
"doPop" : "sl 10/10/2018 16:32",
"jump:" : "sl 10/10/2018 16:33",
"jump:if:" : "sl 10/10/2018 16:33",
"logContext:stream:offset:" : "stlu 3/3/2019 23:48",
"methodReturnConstant:" : "sl 10/10/2018 16:34",
"methodReturnReceiver" : "sl 10/10/2018 16:34",
"methodReturnTop" : "sl 10/10/2018 22:05",
Expand All @@ -31,7 +31,8 @@
"pushTemporaryVariable:" : "sl 10/10/2018 16:40",
"result" : "sl 10/11/2018 10:41",
"send:super:numArgs:" : "sl 10/10/2018 16:41",
"simulate:" : "sl 10/11/2018 10:41",
"simulate:" : "stlu 3/4/2019 00:24",
"simulate:log:" : "stlu 3/19/2019 23:29",
"storeIntoLiteralVariable:" : "sl 10/10/2018 16:41",
"storeIntoReceiverVariable:" : "sl 10/10/2018 17:44",
"storeIntoRemoteTemp:inVectorAt:" : "sl 10/10/2018 17:44",
Expand Down
Loading

0 comments on commit c6ec1ea

Please sign in to comment.