@@ -77,6 +77,43 @@ compiler calls this method in response to a ".lex STRING, PREG" directive.
77
77
GET_ATTR_name_to_register_map(INTERP, SELF, name_to_register_map);
78
78
VTABLE_set_integer_keyed_str(INTERP, name_to_register_map, name, preg);
79
79
}
80
+
81
+ METHOD set_static_lexpad_value(STRING *key, PMC *value) {
82
+ /* Stash static value in hash. */
83
+ PMC *svs;
84
+ GET_ATTR_static_values(INTERP, SELF, svs);
85
+ if (PMC_IS_NULL(svs)) {
86
+ svs = pmc_new(interp, enum_class_Hash);
87
+ SET_ATTR_static_values(INTERP, SELF, svs);
88
+ }
89
+ VTABLE_set_pmc_keyed_str(interp, svs, key, value);
90
+ }
91
+
92
+ METHOD finish_static_lexpad() {
93
+ /* Build caches from the static lexpad. */
94
+ PMC *svs;
95
+ GET_ATTR_static_values(INTERP, SELF, svs);
96
+ if (PMC_IS_NULL(svs) || !VTABLE_elements(interp, svs)) {
97
+ /* No values; clear caches. */
98
+ SET_ATTR_static_slots_cache(INTERP, SELF, PMCNULL);
99
+ SET_ATTR_static_values_cache(INTERP, SELF, PMCNULL);
100
+ }
101
+ else {
102
+ /* Build caches. */
103
+ PMC *slots = pmc_new(interp, enum_class_ResizableIntegerArray);
104
+ PMC *values = pmc_new(interp, enum_class_ResizablePMCArray);
105
+ PMC *iter = VTABLE_get_iter(interp, svs);
106
+ while (VTABLE_get_bool(interp, iter)) {
107
+ STRING *name = VTABLE_shift_string(interp, iter);
108
+ INTVAL slot = VTABLE_get_integer_keyed_str(interp, SELF, name);
109
+ PMC *value = VTABLE_get_pmc_keyed_str(interp, svs, name);
110
+ VTABLE_push_integer(interp, slots, slot);
111
+ VTABLE_push_pmc(interp, values, value);
112
+ }
113
+ SET_ATTR_static_slots_cache(INTERP, SELF, slots);
114
+ SET_ATTR_static_values_cache(INTERP, SELF, values);
115
+ }
116
+ }
80
117
81
118
/*
82
119
0 commit comments