src/HOL/MicroJava/J/Value.thy
changeset 62042 6c6ccf573479
parent 61361 8b5f00202e1a
child 67443 3abf6a722518
equal deleted inserted replaced
62041:52a87574bca9 62042:6c6ccf573479
     4 
     4 
     5 section \<open>Java Values\<close>
     5 section \<open>Java Values\<close>
     6 
     6 
     7 theory Value imports Type begin
     7 theory Value imports Type begin
     8 
     8 
     9 typedecl loc' -- "locations, i.e. abstract references on objects" 
     9 typedecl loc' \<comment> "locations, i.e. abstract references on objects" 
    10 
    10 
    11 datatype loc 
    11 datatype loc 
    12   = XcptRef xcpt -- "special locations for pre-allocated system exceptions"
    12   = XcptRef xcpt \<comment> "special locations for pre-allocated system exceptions"
    13   | Loc loc'     -- "usual locations (references on objects)"
    13   | Loc loc'     \<comment> "usual locations (references on objects)"
    14 
    14 
    15 datatype val
    15 datatype val
    16   = Unit        -- "dummy result value of void methods"
    16   = Unit        \<comment> "dummy result value of void methods"
    17   | Null        -- "null reference"
    17   | Null        \<comment> "null reference"
    18   | Bool bool   -- "Boolean value"
    18   | Bool bool   \<comment> "Boolean value"
    19   | Intg int    -- "integer value, name Intg instead of Int because
    19   | Intg int    \<comment> "integer value, name Intg instead of Int because
    20                    of clash with HOL/Set.thy" 
    20                    of clash with HOL/Set.thy" 
    21   | Addr loc    -- "addresses, i.e. locations of objects "
    21   | Addr loc    \<comment> "addresses, i.e. locations of objects "
    22 
    22 
    23 primrec the_Bool :: "val => bool" where
    23 primrec the_Bool :: "val => bool" where
    24   "the_Bool (Bool b) = b"
    24   "the_Bool (Bool b) = b"
    25 
    25 
    26 primrec the_Intg :: "val => int" where
    26 primrec the_Intg :: "val => int" where
    27   "the_Intg (Intg i) = i"
    27   "the_Intg (Intg i) = i"
    28 
    28 
    29 primrec the_Addr :: "val => loc" where
    29 primrec the_Addr :: "val => loc" where
    30   "the_Addr (Addr a) = a"
    30   "the_Addr (Addr a) = a"
    31 
    31 
    32 primrec defpval :: "prim_ty => val"  -- "default value for primitive types" where
    32 primrec defpval :: "prim_ty => val"  \<comment> "default value for primitive types" where
    33   "defpval Void    = Unit"
    33   "defpval Void    = Unit"
    34 | "defpval Boolean = Bool False"
    34 | "defpval Boolean = Bool False"
    35 | "defpval Integer = Intg 0"
    35 | "defpval Integer = Intg 0"
    36 
    36 
    37 primrec default_val :: "ty => val"   -- "default value for all types" where
    37 primrec default_val :: "ty => val"   \<comment> "default value for all types" where
    38   "default_val (PrimT pt) = defpval pt"
    38   "default_val (PrimT pt) = defpval pt"
    39 | "default_val (RefT  r ) = Null"
    39 | "default_val (RefT  r ) = Null"
    40 
    40 
    41 end
    41 end