source: src/joint/TranslateUtils.ma @ 1283

Last change on this file since 1283 was 1283, checked in by sacerdot, 9 years ago

Bad programming practice removed: change_label is no longer required and
add_graph now takes function from label to statements in place of taking
statements containing a wrong label to be fixed.

File size: 3.0 KB
RevLine 
[1280]1include "joint/Joint.ma".
2
3definition fresh_reg:
4 ∀pars0,globals. joint_internal_function … (rtl_ertl_params pars0 globals) → (joint_internal_function … (rtl_ertl_params pars0 globals)) × register ≝
5  λpars0,globals,def.
6    let 〈r,runiverse〉 ≝ fresh … (joint_if_runiverse … def) in
7     〈set_locals ?? (set_runiverse ?? def runiverse) (r::joint_if_locals ?? def), r〉.
8
9let rec fresh_regs (pars0:?) (globals: list ident) (def: joint_internal_function … (rtl_ertl_params pars0 globals)) (n: nat) on n ≝
10  match n with
11  [ O ⇒ 〈def, [ ]〉
12  | S n' ⇒
13    let 〈def', regs'〉 ≝ fresh_regs pars0 globals def n' in
14    let 〈def', reg〉 ≝ fresh_reg … def' in
15      〈def', reg :: regs'〉
16  ].
17 
18lemma fresh_regs_length:
19 ∀pars0,globals.∀def: joint_internal_function … (rtl_ertl_params pars0 globals). ∀n: nat.
20  |(\snd (fresh_regs … def n))| = n.
21 #pars0 #globals #def #n elim n
22  [ %
23  | #m whd in ⊢ (? → ??(??%)?) whd in ⊢ (? → ??(??match % with [ _ ⇒ ?])?)
24    cases (fresh_regs pars0 globals def m) normalize nodelta
25    #def' #regs #EQ change in EQ with (|regs| = m) <EQ
26    change with
27    (|let 〈a,b〉 ≝ let 〈x,y〉 ≝ let 〈r,runiverse〉 ≝ ? in ? in ? in ?| = ?)
28    cases (fresh … (joint_if_runiverse … def')) normalize // ]
29qed.
30
31definition fresh_regs_strong:
32 ∀pars0,globals. joint_internal_function … (rtl_ertl_params pars0 globals) →
33  ∀n: nat. Σregs: (joint_internal_function … (rtl_ertl_params pars0 globals)) × (list register). |\snd regs| = n ≝
34 λpars0,globals,def,n.fresh_regs pars0 globals def n. //
35qed.
36
37definition fresh_label ≝
38  λglobals,params. λdef: joint_internal_function globals params.
39    fresh LabelTag (joint_if_luniverse … def).
40
41let rec adds_graph
42  (pars1: params1) (globals: list ident)
[1283]43  (stmt_list: list (label → joint_statement (graph_params_ pars1) globals))
[1280]44  (start_lbl: label) (dest_lbl: label)
45  (def: joint_internal_function … (graph_params pars1 globals))
46    on stmt_list ≝
47  match stmt_list with
[1282]48  [ nil ⇒ add_graph … start_lbl (GOTO … dest_lbl) def
[1280]49  | cons stmt stmt_list ⇒
50    match stmt_list with
[1283]51    [ nil ⇒ add_graph … start_lbl (stmt dest_lbl) def
[1280]52    | _ ⇒
53      let 〈tmp_lbl, nuniv〉 ≝ fresh_label … def in
[1283]54      let def ≝ add_graph … start_lbl (stmt tmp_lbl) def in
[1280]55        adds_graph pars1 globals stmt_list tmp_lbl dest_lbl def]].
56
57let rec add_translates
58  (pars1: params1) (globals: list ident)
59  (translate_list: list ?) (start_lbl: label) (dest_lbl: label)
60  (def: joint_internal_function … (graph_params pars1 globals))
61    on translate_list ≝
62  match translate_list with
[1282]63  [ nil ⇒ add_graph … start_lbl (GOTO … dest_lbl) def
[1280]64  | cons trans translate_list ⇒
65    match translate_list with
66    [ nil ⇒ trans start_lbl dest_lbl def
67    | _ ⇒
68      let 〈tmp_lbl, nuniv〉 ≝ fresh_label … def in
69      let def ≝ trans start_lbl tmp_lbl def in
[1283]70        add_translates pars1 globals translate_list tmp_lbl dest_lbl def]].
Note: See TracBrowser for help on using the repository browser.