diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-26 23:12:44 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-12-26 23:12:44 +0100 |
commit | 7f1c80eb804d7d46feec2f0b8def5c6e1a0f6a7f (patch) | |
tree | a8c0d3a530697e82fbec9a563396bf073203dead /src/typing.ml | |
parent | b5b6163332977297617990863564659d49d3e086 (diff) | |
download | LPC-Projet-7f1c80eb804d7d46feec2f0b8def5c6e1a0f6a7f.tar.gz LPC-Projet-7f1c80eb804d7d46feec2f0b8def5c6e1a0f6a7f.zip |
Optimization.
Diffstat (limited to 'src/typing.ml')
-rw-r--r-- | src/typing.ml | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/typing.ml b/src/typing.ml index 4c105da..a405855 100644 --- a/src/typing.ml +++ b/src/typing.ml @@ -93,7 +93,7 @@ and tproto = { and tcls_supers = tcls_hier list and tcls_hier = { h_class : tident; - h_pos : int; + mutable h_pos : int; mutable h_vtable : (int * tproto) list; (* only to be muted during class definition parsing *) h_supers : tcls_supers } @@ -714,6 +714,18 @@ let compute_tclass env c = tp_ret_type = None; tp_args = [] }::meth in + (* if vtable is empty, remove it *) + let mem = + if hier.h_vtable = [] then + let rec mv_h h = + h.h_pos <- h.h_pos - 4; + List.iter mv_h h.h_supers + in + List.iter mv_h hier.h_supers; + Smap.map (fun (ty, pos) -> (ty, pos-4)) mem + else + mem + in { tc_name = cls_name; tc_size = mem_u; tc_hier = hier; |