Example #1
0
 def make_prefab(w_key, w_values):
     w_struct_type = W_StructType.make_prefab(
         W_PrefabKey.from_raw_key(w_key, len(w_values)))
     for i, value in enumerate(w_values):
         if not w_struct_type.is_immutable_field_index(i):
             w_values[i] = values.W_Cell(value)
     return W_Struct.make(w_values, w_struct_type)
Example #2
0
 def make_prefab(w_key, w_values):
     w_struct_type = W_StructType.make_prefab(
         W_PrefabKey.from_raw_key(w_key, len(w_values)))
     constant_false = []
     for i, value in enumerate(w_values):
         if not w_struct_type.is_immutable_field_index(i):
             w_values[i] = values.W_Cell(value)
         elif value is values.w_false:
             constant_false.append(i)
     cls = lookup_struct_class(constant_false)
     if cls is not W_Struct:
         w_values = reduce_field_values(w_values, constant_false)
     return cls.make(w_values, w_struct_type)
Example #3
0
 def constr_proc_cont(self, field_values, env, cont, _vals):
     from pycket.interpreter import return_value
     guard_super_values = _vals.get_all_values()
     struct_type = jit.promote(self.type)
     if guard_super_values:
         field_values = guard_super_values + field_values[len(guard_super_values):]
     if len(struct_type.auto_values) > 0:
         field_values = field_values + struct_type.auto_values
     for i, value in enumerate(field_values):
         if not struct_type.is_immutable_field_index(i):
             value = values.W_Cell(value)
             field_values[i] = value
     result = W_Struct.make(field_values, struct_type)
     return return_value(result, env, cont)
Example #4
0
def construct_struct_final(struct_type, field_values, env, cont):
    from pycket.interpreter import return_value
    assert len(field_values) == struct_type.total_field_cnt
    constant_false = []
    for i, value in enumerate(field_values):
        if not struct_type.is_immutable_field_index(i):
            value = values.W_Cell(value)
            field_values[i] = value
        elif value is values.w_false:
            constant_false.append(i)
    cls = lookup_struct_class(constant_false)
    if cls is not W_Struct:
        field_values = reduce_field_values(field_values, constant_false)
    result = cls.make(field_values, struct_type)
    return return_value(result, env, cont)