~ubuntu-branches/ubuntu/wily/coq-doc/wily

« back to all changes in this revision

Viewing changes to kernel/csymtable.ml

  • Committer: Package Import Robot
  • Author(s): Stéphane Glondu
  • Date: 2012-01-03 23:42:48 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20120103234248-p9r8h1579n67v55a
Tags: 8.3pl3-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
 
82
82
exception NotEvaluated
83
83
 
 
84
open Pp
84
85
let key rk =
85
86
  match !rk with
86
 
  | Some k -> k
 
87
  | Some k -> (*Pp.msgnl (str"found at: "++int k);*)  k
87
88
  | _ -> raise NotEvaluated
88
89
 
89
90
(************************)
110
111
  let (cb,rk) = lookup_constant_key kn env in
111
112
  try key rk
112
113
  with NotEvaluated ->
 
114
(*    Pp.msgnl(str"not yet evaluated");*)
113
115
    let pos =
114
116
      match Cemitcodes.force cb.const_body_code with
115
117
      | BCdefined(boxed,(code,pl,fv)) ->
118
120
        else set_global v
119
121
    | BCallias kn' -> slot_for_getglobal env kn'
120
122
    | BCconstant -> set_global (val_of_constant kn) in
 
123
(*Pp.msgnl(str"value stored at: "++int pos);*)
121
124
    rk := Some pos;
122
125
    pos
123
126
 
154
157
      end
155
158
 
156
159
and eval_to_patch env (buff,pl,fv) =
 
160
  (* copy code *before* patching because of nested evaluations:
 
161
     the code we are patching might be called (and thus "concurrently" patched)
 
162
     and results in wrong results. Side-effects... *)
 
163
  let buff = Cemitcodes.copy buff in
157
164
  let patch = function
158
165
    | Reloc_annot a, pos -> patch_int buff pos (slot_for_annot a)
159
166
    | Reloc_const sc, pos -> patch_int buff pos (slot_for_str_cst sc)
160
167
    | Reloc_getglobal kn, pos ->
161
 
        patch_int buff pos (slot_for_getglobal env kn)
 
168
(*      Pp.msgnl (str"patching global: "++str(debug_string_of_con kn));*)
 
169
        patch_int buff pos (slot_for_getglobal env kn);
 
170
(*      Pp.msgnl (str"patch done: "++str(debug_string_of_con kn))*)
162
171
  in
163
172
  List.iter patch pl;
164
173
  let vm_env = Array.map (slot_for_fv env) fv in
165
174
  let tc = tcode_of_code buff (length buff) in
 
175
(*Pp.msgnl (str"execute code");*)
166
176
  eval_tcode tc vm_env
167
177
 
168
178
and val_of_constr env c =