|
@@ -1882,19 +1882,26 @@ module StdReflect = struct
|
|
|
let name = hash (decode_vstring name).sstring in
|
|
|
match vresolve o with
|
|
|
| VObject o ->
|
|
|
- let found = ref false in
|
|
|
- let fields = IntMap.fold (fun name' i acc ->
|
|
|
- if name = name' then begin
|
|
|
- found := true;
|
|
|
- acc
|
|
|
+ begin match o.oproto with
|
|
|
+ | OProto proto ->
|
|
|
+ let found = ref false in
|
|
|
+ let fields = IntMap.fold (fun name' i acc ->
|
|
|
+ if name = name' then begin
|
|
|
+ found := true;
|
|
|
+ acc
|
|
|
+ end else
|
|
|
+ (name',o.ofields.(i)) :: acc
|
|
|
+ ) proto.pinstance_names [] in
|
|
|
+ if !found then begin
|
|
|
+ update_object_prototype o fields;
|
|
|
+ vtrue
|
|
|
end else
|
|
|
- (name',o.ofields.(i)) :: acc
|
|
|
- ) o.oproto.pinstance_names [] in
|
|
|
- if !found then begin
|
|
|
- update_object_prototype o fields;
|
|
|
- vtrue
|
|
|
- end else
|
|
|
- vfalse
|
|
|
+ vfalse
|
|
|
+ | ODictionary d ->
|
|
|
+ let has = IntMap.mem name d in
|
|
|
+ if has then o.oproto <- ODictionary (IntMap.remove name d);
|
|
|
+ vbool has
|
|
|
+ end
|
|
|
| _ ->
|
|
|
vfalse
|
|
|
)
|
|
@@ -1931,7 +1938,11 @@ module StdReflect = struct
|
|
|
let hasField = vfun2 (fun o field ->
|
|
|
let name = hash (decode_vstring field).sstring in
|
|
|
let b = match vresolve o with
|
|
|
- | VObject o -> IntMap.mem name o.oproto.pinstance_names
|
|
|
+ | VObject o ->
|
|
|
+ begin match o.oproto with
|
|
|
+ | OProto proto -> IntMap.mem name proto.pinstance_names
|
|
|
+ | ODictionary d -> IntMap.mem name d
|
|
|
+ end
|
|
|
| VInstance vi -> IntMap.mem name vi.iproto.pinstance_names || IntMap.mem name vi.iproto.pnames
|
|
|
| VPrototype proto -> IntMap.mem name proto.pnames
|
|
|
| _ -> unexpected_value o "object"
|
|
@@ -1960,7 +1971,7 @@ module StdReflect = struct
|
|
|
)
|
|
|
|
|
|
let setField = vfun3 (fun o name v ->
|
|
|
- (try set_field o (hash (decode_vstring name).sstring) v with Not_found -> ()); vnull
|
|
|
+ (try set_field_runtime o (hash (decode_vstring name).sstring) v with Not_found -> ()); vnull
|
|
|
)
|
|
|
|
|
|
let setProperty = vfun3 (fun o name v ->
|
|
@@ -1969,7 +1980,7 @@ module StdReflect = struct
|
|
|
let vset = field o name_set in
|
|
|
if vset <> VNull then call_value_on o vset [v]
|
|
|
else begin
|
|
|
- (try set_field o (hash name.sstring) v with Not_found -> ());
|
|
|
+ (try set_field_runtime o (hash name.sstring) v with Not_found -> ());
|
|
|
vnull
|
|
|
end
|
|
|
)
|