|
1 |
| -# A serialization context contains a bunch of objects that we want to persist |
2 |
| -# across the compile time / run time boundary. |
| 1 | +# While the grammar represents the syntactic elements of our language and |
| 2 | +# the actions take care of building up an AST to represent the semantics |
| 3 | +# of it, the world is about the declarative aspects of a language. This |
| 4 | +# includes: |
3 | 5 | #
|
4 |
| -# The long term goal is that we'll support actually serializing these in an |
5 |
| -# efficient way, and be able to do load-time linking between objects in |
6 |
| -# different libraries. For now, that's a lot of work, so we adopt a simpler |
7 |
| -# approach, in the hope that it will be upgradeable to a "full blown" |
8 |
| -# mechanism in the future. |
| 6 | +# * Symbol table management |
| 7 | +# * Creating meta-object instances |
| 8 | +# * Parts of library loading (most likely it delegates to an actual loader) |
| 9 | +# * Resolving references to objects, within or between compilation units |
9 | 10 | #
|
10 |
| -# A serialization context is essentially made up of objects and "events" that |
11 |
| -# we perform on them. By performing an action on an object through the context |
12 |
| -# builder, it ensures that the action is performed both on the object now, and |
13 |
| -# also enough information is persisted to be able to re-create an object with |
14 |
| -# the same state. There are two common situations. |
| 11 | +# Just as there is one AST produced per compilation unit, there is also a |
| 12 | +# world produce per compilation unit. |
15 | 13 | #
|
16 |
| -# 1) We compile some code and run it straight away. In this case, the objects |
17 |
| -# have already been created, and we only need to do some fixing up. |
18 |
| -# 2) We compile some code and persist it as PIR. In this case, the objects need |
19 |
| -# to be re-created by replaying the event stream that creates them. |
| 14 | +# A world includes a serialization context. This contains a bunch of |
| 15 | +# objects - often meta-objects - that we want to persist across the |
| 16 | +# compile time / run time boundary. In the near future, we'll switch to |
| 17 | +# actually serializing these. At the moment, we instead save a series of |
| 18 | +# "events" that will be used to re-construct them. |
20 | 19 | #
|
21 |
| -# Essentially, we use PIR as our serialization language until we can do better. |
22 |
| -# Note that deserialization and installation aren't the same thing; the first |
23 |
| -# step sees us producing an array of objects, while the second is about putting |
24 |
| -# them in places the HLL can find them. |
25 |
| -# |
26 |
| -# It may be that this approach will also carry almost directly over to nqpclr |
27 |
| -# and nqpjvm. |
| 20 | +# Note that this reconstruction code is not generated in the case that we |
| 21 | +# are just going to immediately run. |
28 | 22 |
|
29 |
| -class HLL::Compiler::SerializationContextBuilder { |
| 23 | +class HLL::World { |
30 | 24 | # Represents an event that we need to handle when fixing up or deserializing.
|
31 | 25 | my class Event {
|
32 | 26 | # The PAST that we emit to perform the action if in deserialization mode.
|
@@ -73,8 +67,8 @@ class HLL::Compiler::SerializationContextBuilder {
|
73 | 67 | method BUILD(:$handle!, :$description!) {
|
74 | 68 | $!sc := pir::nqp_create_sc__PS($handle);
|
75 | 69 | $!handle := $handle;
|
76 |
| - %!addr_to_slot := pir::new('Hash'); |
77 |
| - @!event_stream := pir::new('ResizablePMCArray'); |
| 70 | + %!addr_to_slot := nqp::hash(); |
| 71 | + @!event_stream := nqp::list(); |
78 | 72 | $!sc.set_description($description);
|
79 | 73 | $!precomp_mode := %*COMPILING<%?OPTIONS><target> eq 'pir';
|
80 | 74 | }
|
@@ -163,7 +157,7 @@ class HLL::Compiler::SerializationContextBuilder {
|
163 | 157 |
|
164 | 158 | # Gets PAST for referencing an object in a serialization context,
|
165 | 159 | # either the one being built or another one.
|
166 |
| - method get_object_sc_ref_past($obj) { |
| 160 | + method get_ref($obj) { |
167 | 161 | # Get the object's serialization context; we're stuck if it
|
168 | 162 | # has none.
|
169 | 163 | my $sc := pir::nqp_get_sc_for_object__PP($obj);
|
|
0 commit comments