src/HOL/Bali/Value.thy
author berghofe
Sat Jan 30 17:03:46 2010 +0100 (2010-01-30)
changeset 34990 81e8fdfeb849
parent 32960 69916a850301
child 35069 09154b995ed8
permissions -rw-r--r--
Adapted to changes in cases method.
wenzelm@12857
     1
(*  Title:      HOL/Bali/Value.thy
schirmer@12854
     2
    ID:         $Id$
schirmer@12854
     3
    Author:     David von Oheimb
schirmer@12854
     4
*)
schirmer@12854
     5
header {* Java values *}
schirmer@12854
     6
schirmer@12854
     7
schirmer@12854
     8
haftmann@16417
     9
theory Value imports Type begin
schirmer@12854
    10
schirmer@13688
    11
typedecl loc            --{* locations, i.e. abstract references on objects *}
schirmer@12854
    12
schirmer@12854
    13
datatype val
wenzelm@32960
    14
        = Unit          --{* dummy result value of void methods *}
wenzelm@32960
    15
        | Bool bool     --{* Boolean value *}
wenzelm@32960
    16
        | Intg int      --{* integer value *}
wenzelm@32960
    17
        | Null          --{* null reference *}
wenzelm@32960
    18
        | Addr loc      --{* addresses, i.e. locations of objects *}
schirmer@12854
    19
schirmer@12854
    20
schirmer@12854
    21
translations "val" <= (type) "Term.val"
schirmer@12854
    22
             "loc" <= (type) "Term.loc"
schirmer@12854
    23
schirmer@12854
    24
consts   the_Bool   :: "val \<Rightarrow> bool"  
schirmer@12854
    25
primrec "the_Bool (Bool b) = b"
schirmer@12854
    26
consts   the_Intg   :: "val \<Rightarrow> int"
schirmer@12854
    27
primrec "the_Intg (Intg i) = i"
schirmer@12854
    28
consts   the_Addr   :: "val \<Rightarrow> loc"
schirmer@12854
    29
primrec "the_Addr (Addr a) = a"
schirmer@12854
    30
wenzelm@32960
    31
types   dyn_ty      = "loc \<Rightarrow> ty option"
schirmer@12854
    32
consts
schirmer@12854
    33
  typeof        :: "dyn_ty \<Rightarrow> val \<Rightarrow> ty option"
schirmer@13688
    34
  defpval       :: "prim_ty \<Rightarrow> val"  --{* default value for primitive types *}
schirmer@13688
    35
  default_val   :: "     ty \<Rightarrow> val"  --{* default value for all types *}
schirmer@12854
    36
schirmer@12854
    37
primrec "typeof dt  Unit    = Some (PrimT Void)"
wenzelm@32960
    38
        "typeof dt (Bool b) = Some (PrimT Boolean)"
wenzelm@32960
    39
        "typeof dt (Intg i) = Some (PrimT Integer)"
wenzelm@32960
    40
        "typeof dt  Null    = Some NT"
wenzelm@32960
    41
        "typeof dt (Addr a) = dt a"
schirmer@12854
    42
wenzelm@32960
    43
primrec "defpval Void    = Unit"
wenzelm@32960
    44
        "defpval Boolean = Bool False"
wenzelm@32960
    45
        "defpval Integer = Intg 0"
wenzelm@32960
    46
primrec "default_val (PrimT pt) = defpval pt"
wenzelm@32960
    47
        "default_val (RefT  r ) = Null"
schirmer@12854
    48
schirmer@12854
    49
end