You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-8
Original file line number
Diff line number
Diff line change
@@ -94,11 +94,11 @@ aexpr(lambda: tmp.method())
94
94
The dependencies are `self.f` and `self.g` (from object `tmp`).
95
95
To be able to monitor the dependencies of the expression, we have to find them first.
96
96
97
-
## Step 1: Find the dependencies
97
+
###Step 1: Find the dependencies
98
98
99
99
Therefore this library performs a static byte-code analysis of the expression and all nested methods.
100
100
It converts the binary byte-code of the expression and all nested methods with the library [`dis`](https://docs.python.org/2/library/dis.html).
101
-
Afterwards it simulates an object-stack and an own variable mapping and processes all byte-code instruction itself.
101
+
Afterwards it simulates an object-stack and an own variable mapping and processes all byte-code instructions itself.
102
102
103
103
**Short Example** (the complete one is in the [presentation](https://github.com/active-expressions/active-expressions-static-python/blob/master/presentation/presentation.pdf)):
104
104
```
@@ -122,10 +122,10 @@ An addition for example only takes two elements from the object stack and pushes
122
122
A multiplication does the same.
123
123
Thats the reason why all elements on our own object stack are wrapped in an [ObjectWrapper](https://github.com/active-expressions/active-expressions-static-python/blob/master/aexpr/aexpr.py#L29), which can be an real object or a placeholder.
124
124
125
-
## Step 2: Monitor the dependencies
125
+
###Step 2: Monitor the dependencies
126
126
127
127
When we found the dependencies we have to monitor them to be able to trigger if something changes.
128
-
For all dependencies (attribute of a object) we modify the `__setattr__`-method of the object, which will be called when setting a attribute of that object.
128
+
For all dependencies (fields of a object) we modify the `__setattr__`-method of the object, which will be called when setting a attribute of that object.
129
129
We install a hook in that `__setattr__`-method which checks if we monitor that specific attribute and calls all triggers if so.
130
130
The [method `placeaexpr`](https://github.com/active-expressions/active-expressions-static-python/blob/master/aexpr/aexpr.py#L46) installs these hooks.
131
131
@@ -144,22 +144,23 @@ The full example for this analysis is shown in the [presentation](https://github
144
144
145
145
This library has the few following limitations. Feel free to contribute and fix these limitations:
146
146
147
-
-**Lists, Sets, Maps:** Datastructures are not supported so far. Means if you store a dependency in a list and access the an attribute later, you can not monitor on that attribute.
147
+
-**Lists, Sets, Maps:** Datastructures are not supported so far. Means if you store a dependency in a list and access an attribute later, you can not monitor on that attribute.
148
148
-**Local Variables:** Local Variables are not instrumentable since they do not have a `__setattr__` or something else. Only fields of objects are instrumentable.
149
149
-**External Resources:** Monitoring if a server is available or a file exists would require to poll this information repeatedly. This is not supported.
150
150
-**Transactions:** Each time a dependency changes all triggers are triggered. Its not possible to pause this to change more attributes at once.
151
-
-**Other language features:** Not supported are for examples *exceptions* and *closures*; *concurreny*, *asynchrony* and *meta-programming* can cause issues as well.
151
+
-**Other language features:** Not supported are for examples *exceptions* and *closures*; *concurrency*, *asynchrony* and *meta-programming* can cause issues as well.
152
152
153
153
You can find some code examples for some of them in the [presentation](https://github.com/active-expressions/active-expressions-static-python/blob/master/presentation/presentation.pdf).
154
154
155
155
## Contribution
156
156
157
157
If you have some complex expression to monitor it can happen that you get an `UnimplementedInstructionException`.
158
-
This means that you try to perform an instruction which is not so far supported.
158
+
This means that you try to process an instruction which is so far not supported.
159
159
Afterwards you see the unsupported byte-code-instruction.
160
-
Feel free to create pull request to this repository to support that instruction.
160
+
Feel free to create pull requests to this repository to support unknown instructions.
161
161
162
162
To support a new instruction you have to modify the content of the `aexpr`-method.
163
163
Call the method `opcode` once with the new supported op-codes of the instruction and call the result with a method which performs the required actions.
164
164
Therefore you get the instruction, the rest of the instruction queue, the object stack and the variable mapping as parameters.
165
165
There are already a lot of examples for this in this method.
166
+
You can find an overview over all opcodes [here](http://unpyc.sourceforge.net/Opcodes.html).
0 commit comments