Theory Type

Up to index of Isabelle/HOL/arrays

theory Type = JBasis:
(*  Title:      HOL/MicroJava/J/Type.thy
    ID:         $Id: Type.html,v 1.1 2002/11/28 16:11:18 kleing Exp $
    Author:     David von Oheimb, Gerwin Klein
    Copyright   1999 Technische Universitaet Muenchen
*)

header {* \isaheader{Java types} *}

theory Type = JBasis:

typedecl cnam 

 -- "exceptions"
datatype 
  xcpt   
  = NullPointer
  | ClassCast
  | OutOfMemory
  | ArrayIndexOutOfBounds
  | NegativeArraySize
  | ArrayStore
  

-- "class names"
datatype cname  
  = Object 
  | Xcpt xcpt 
  | Cname cnam 

typedecl vnam   -- "variable or field name"
typedecl mname  -- "method name"

-- "names for @{text This} pointer and local/field variables"
datatype vname 
  = This
  | VName vnam

-- "primitive type, cf. 4.2"
datatype prim_ty 
  = Void          -- "'result type' of void methods"
  | Boolean
  | Integer
  | RetA nat      -- "bytecode return addresses"

datatype  
  ref_ty          -- "reference type, cf. 4.3"
  = NullT         -- "null type, cf. 4.1"
  | ClassT cname  -- "class type"
  | ArrayT ty     -- "array type"
and   
  ty              -- "any type, cf. 4.1"
  = PrimT prim_ty -- "primitive type"
  | RefT  ref_ty  -- "reference type"

syntax
  NT    :: "ty"
  Class :: "cname  => ty"
  RA    :: "nat => ty"
  Array :: "ty \<Rightarrow> ty" ("_.[]" [90] 90)

translations
  "NT"      == "RefT NullT"
  "Class C" == "RefT (ClassT C)"
  "T.[]"    == "RefT (ArrayT T)"
  "RA pc"   == "PrimT (RetA pc)"

consts
  the_Class :: "ty \<Rightarrow> cname"
  isArray :: "ty \<Rightarrow> bool"

recdef the_Class "{}"
  "the_Class (Class C) = C"
  "the_Class (T.[]) = Object"

recdef isArray "{}"
  "isArray (T.[]) = True"
  "isArray T      = False"

end