-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNOTES
77 lines (41 loc) · 3.65 KB
/
NOTES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Packages are unimplemented -- lookups are complicated, but route
I'm not even sure what Ellipses does, or ExtSlice. We're just going to do subscript and slices[start:end]
Not going to support cyclic gc at this point
Yo, deal with builtins
globals/locals are in __builtin__, which aren't actually in globals() by default. Thus, we can *probably* just track if globals/locals are gotten but not immediately called. Even doing so, there are some caveats, mostly from doing something to get all of __builtins__, which can lead to globals/locals escaping to the outside world.
The orelse clauses of for and while statements are currently unimplemented. A description of how I would handle them is given in controlFlowTranslator.py
Function's captures aren't identified until after IR generation. This is done because captures work on >1st degree scopes, and you don't know at the end of the scope all of the locals of the enclosing scopes. Instead, we're going to identify captures at the end of top-level scopes generation, and we'll do this after IR generation as a correctness pass.
Generators
-------------------------
I removed the isgenerator flag from IRCode -- Generators should probably be distinct from functions some way or another
Generators are currently unhandled in C generation. We will use the `switch` trick.
Exceptions
-------------------------
If there are multiple exception handlers, and one catches, but then raises an exception, are the others considered? NO
a return in a try happens *AFTER* the finally clause. I don't think C++ does this, and this is actually not that trivial to translate to the target language. The IR assumes C semantics. I think I'll rely on an IR transform to make this behave according to Python semantics.
Generators in a try-finally get invoked on destruction so the finally occurs
With statements aren't implemented, but just because they're Try/Catch, and would take unnecessary work.
I don't think we're supporting tracebacks, unless there's support at a C / assembly level.
Objects
-------------------------
In C, classes should be implemented as structs, with slots for common member. __dict__ shouldn't always retain the values -- they may be offsets into an instance. This can be accomplished with tagged pointers (i.e. storing the type in the bits of memory that must be 0 in pointers for alignement).
Lookups, however, shouldn't use strings; they should use id numbers. The id numbers should start at 0 and be consecutive, and ideally the id numbers for identifiers that represent members of an object should be consecutive. This way, lookups can be done with a switch statement, and it can be potentially very dense.
class definitions have their own scope -- the classes!
No plans to support multiple inheritance
No plans to support metaclasses
Actually, no plans to support inheritance
New-style classes only, (even though it doesn't make a difference)
__slots__ is just more work
TODOs
-------------------------
TODO: Methods are currently undetected. I believe this should happen in _Call
TODO: optimization to remove code in a block after an unconditional return (or raise)
Insert an *only once* mechanism into loading modules, and a way to get+clear it for reloads. Also, add a call to the module's load on imports.
TODO: MEMORY MANAGEMENT!!
TODO: check if things are defined, raise otherwise
TODO: eliminate if (isTruthy(IsStopIterationSignal(obj)))
TODO: Defaults
TODO: Captures
__builtin__ as part of the variable lookup path makes life very difficult. It's just not handled yet.
TODO: intern strings
TODO: there's a bug in the generation of loadtime which makes local variables for the globals which shadow the globals