-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathenv.k
49 lines (43 loc) · 1.46 KB
/
env.k
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module C-ENV-SYNTAX
imports BASIC-K
imports INT-SYNTAX
imports COMMON-SORTS
imports SYMLOC-SORTS
imports C-TYPING-SORTS
syntax KItem ::= addToEnv(CId, SymBase)
syntax KItem ::= giveType(CId, Type)
syntax KItem ::= populateFromGlobal(K)
endmodule
module C-ENV
imports STRING
imports C-CONFIGURATION
imports C-DYNAMIC-SYNTAX
imports C-ENV-SYNTAX
imports C-TYPING-SYNTAX
rule <k> populateFromGlobal(_) => .K ...</k>
<curr-tu> Tu:String </curr-tu>
<tu-id> Tu </tu-id>
<genv> G:Map </genv>
<rgenv> RG:Map </rgenv>
<gtypes> GT:Map </gtypes>
<env> _ => G </env>
<renv> _ => RG </renv>
<types> _ => GT </types>
requires Tu =/=String "native"
[structural]
rule <k> populateFromGlobal(T::Type) => .K ...</k>
<curr-tu> "native" </curr-tu>
<curr-scope> blockScope(... functionId: F:CId) </curr-scope>
<env> _ => .Map </env>
<renv> _ => .Map </renv>
<types> _ => F |-> T </types>
[structural]
rule <k> addToEnv(X::CId, Base::SymBase) => .K ...</k>
<env> E:Map => E[X <- Base] </env>
<renv> RE:Map => RE[Base <- X] </renv>
[structural]
rule <k> giveType(X::CId, T::Type) => .K ...</k>
<types> L:Map => L[X <- tagRestrict(S, T)] </types>
<curr-scope> S:Scope </curr-scope>
[structural]
endmodule