# Theory JVMState

Up to index of Isabelle/HOL/MicroJava

theory JVMState
imports Conform
begin

    (*  Title:      HOL/MicroJava/JVM/JVMState.thy
        ID:         $Id: JVMState.thy,v 1.12 2005/04/27 14:39:45 paulson Exp $
        Author:     Cornelia Pusch, Gerwin Klein
        Copyright   1999 Technische Universitaet Muenchen
    *)

    header {*
      \chapter{Java Virtual Machine}\label{cha:jvm}
      \isaheader{State of the JVM}
    *}

    theory JVMState
    imports "../J/Conform"
    begin

    section {* Frame Stack *}
    types
     opstack   = "val list"
     locvars   = "val list"
     p_count   = nat

     frame = "opstack ×
              locvars ×
              cname ×
              sig ×
              p_count"

      -- "operand stack"
      -- "local variables (including this pointer and method parameters)"
      -- "name of class where current method is defined"
      -- "method name + parameter types"
      -- "program counter within frame"

    section {* Exceptions *}
    constdefs
      raise_system_xcpt :: "bool => xcpt => val option"
      "raise_system_xcpt b x ≡ raise_if b x None"

    section {* Runtime State *}
    types
      jvm_state = "val option × aheap × frame list"  -- "exception flag, heap, frames"

    section {* Lemmas *}

    lemma new_Addr_OutOfMemory:
      "snd (new_Addr hp) = Some xcp ==> xcp = Addr (XcptRef OutOfMemory)"
    proof -
      obtain ref xp where "new_Addr hp = (ref, xp)" by (cases "new_Addr hp")
      moreover
      assume "snd (new_Addr hp) = Some xcp"
      ultimately
      show ?thesis by (auto dest: new_AddrD)
    qed

    end

## Frame Stack

## Exceptions

## Runtime State

## Lemmas

lemma new_Addr_OutOfMemory:

      snd (new_Addr hp) = Some xcp ==> xcp = Addr (XcptRef OutOfMemory)