Java and the Java Virtual Machine 3 The
- Slides: 12
Java and the Java Virtual Machine 3. The imperative Core Java. I of Java Pslab 오민경
Static semantics of Java. I n Primitive type ¡ Numeric type n n ¡ Conditional type n n Integral type : byte, short, int long, char Floating point type : float, double boolean Literal ¡ ¡ External representations of values of primitive type i. e. 11, 3. 14 f, true …
Static semantics of Java. I n Relation ‘⊆’ ¡ A⊆B n n n ¡ A is subtype of B ( A, B : Type) exist a widening primitive conversion from A to B Each value of A can used as a value of B, however, information may be lost. Relation ‘⊆’ n n n Byte ⊆ short ⊆ int ⊆ long ⊆ float ⊆ double, char ⊆ int Reflexive : A ⊆ A Transitive : if A ⊂ B and B ⊂ C, then A ⊂ C
Syntax of Java. I n Domain ¡ Domains (or universes) : words beginning with a capital letter n ¡ n i. e. Exp … expressions, Stm … statements Elements of ‘Dom’ : ‘dom’ Local variable ¡ ¡ Local variable declaration : ‘A loc; ’ The scope of loc consists of the statements following the variable declaration in the block.
Type checking of Java. I n Position ¡ Position : small Greek letters α, β, γ. n ¡ n i. e. αexp, βstm The universe of positions is called ‘Pos’. Compiler verification : type checking ¡ ¡ ¡ The compiler has to verify that a program is well-typed. As a result of pasing and elaboration the parse tree annotated with type information : T(α). During compilation and type checking explicit unary conversion operators (type cast) are inserted at places where they are necessary.
Transition rules for Java. I n exec. Java. I = exec. Java. Exp. I exec. Java Stm. I n exec. Java. Exp. I ¡ ¡ All expressions are evaluated from innermost to outermost. For this purpose, n n n the current control is transferred, by updating pos. from unevaluated expressions to the appropriate subexpressions. until an atom (a literal or a variable) is reached.
Transition rules for Java. I n exec. Java Stm. I ¡ ¡ The syntactical structure of the statement to be computed by transferring. For this purpose n n n through updates of pos, the current control from structured statements to the appropriate substatements until the current statement has been computed normally or abrupts the computation. Abruption : Jump statement (break, continue) ¡ ¡ ¡ Not a labeled phrase, not degree labeled phrase : Abruption is propagated upwards. Break(labb) : execution proceeds normally at the next phrase of the target Continue(labc) : execution proceeds with the next iteration of the corresponding while statement.
Derived language constructs n Java constructs that can be syntactically reduced to the core language ¡ ¡ ¡ n ++loc : loc=(A)(loc+1) --loc : loc=(A)(loc-1) If (exp) stm : if (exp) stm else; The ‘if statement without else’ suffers from the so-called ‘dangling else problem’ ¡ If (exp 1) if (exp 2) stm 1 else stm 2 n n If (exp 1) { if (exp 2) stm 1 else stm 2 } => O If (exp 1) { if (exp 2) stm 1 } else stm 2 => X
Syntax of Java Exp : = Lit | Loc | Uop Exp | Exp Bop Exp | Exp ? Exp : Exp | Asgn : = Loc = Exp Stm : = ; | Asgn; | Lab : Stm | break Lab; | continue Lab; | if (Exp) Stm else Stm | while (Exp) Stm | Block : = {Bstm 1 … Bstmn} Bstm : = Type Loc; | Stm Phrase : = Exp | Bstm | Val | Abr | Norm
Execution of Java. I expressions exec. Java. Exp. I = case context(pos) of lit → yield(JLS(lit)) loc → yield(locals(loc)) uop αexp → pos : = α uop ►val → yield. Up(JLS(uop, val)) αexp 1 bop βexp 2 → pos : = α ► val bop βexp → pos : = β αval 1 bop ► val 2 → if ¬(bop 2 div. Mod ∧ is. Zero(val 2)) then yield. Up(JLS(bop, val 1, val 2)) loc = αexp → pos : = α loc = ►val → locals : = locals + {(loc, val)} yield. Up(val) αexp 0 ? βexp 1 : γexp 2 → pos : = α ►val ? βexp 1 : γexp 2 → if val then pos : = β else pos : = γ αTrue ? ►val : γexp → yield. Up(val) αFalse ? βexp : ►val → yield. Up(val)
Execution of Java. I statements exec. Java. Stm. I = case context(pos) of ; → yield(Norm) αexp; → pos : = α ► val; → yield. Up(Norm) break lab; → yield(Break(lab)) continue lab; → yield(Continue(lab)) lab : αstm → pos : = α lab : ► Norm → yield. Up(Norm) lab : ► Break(labb) → if lab = labb then yield. Up(Norm) else yield. Up(Break(labb)) ► lab : Continue(labc) → if lab = labc then yield(body/pos) else yield. Up(Continue(labc)) phrase(► abr) → if pos ≠ first. Pos ∧propagates. Abr(restbody/up(pos)) then yield. Up(abr)
Execution of Java. I statements { } → yield(Norm) {α 1 stm 1 … αn stmn} → pos : = α 1 {α 1 Norm … ► Norm} → yield. Up(Norm) {α 1 Norm … ► Normαi+1 stmi+1 … αnstmn} → pos : = αi+1 if if (αexp) βstm 1 else γstm 2 → pos : = α (► val) βstm 1 else γstm 2 → if val then pos : = β else pos : = γ (αTrue) ► Norm else γstm → yield. Up(Norm) (αFalse) βstm else ► Norm → yield. Up(Norm) while (αexp) βstm → pos : = α while (► val) βstm → if val then pos : = β else yield. Up(Norm) while (αTrue) ► Norm → yield. Up(body/up(pos)) Type x ; → yield(Norm)
- Java virtual machine architecture diagram
- Has virtual functions and accessible non-virtual destructor
- Moore machine and mealy machine
- Chapter 10 energy work and simple machines answer key
- Microsoft virtual machine converter download
- Virtual anesthesia machine
- Gunadarma
- Virtual machine history
- Hadoop virtual machine download
- Install windows xp virtual machine
- Virtual machine scale sets
- System center - virtual machine manager
- Tiny virtual machine