Operational Semantics Program Testing and Analysis · 1 Program Testing and Analysis: Operational...

Post on 09-Jul-2020

18 views 0 download

Transcript of Operational Semantics Program Testing and Analysis · 1 Program Testing and Analysis: Operational...

1

Program Testing and Analysis:

Operational Semantics

Dr. Michael Pradel

Software Lab, TU Darmstadt

2

Warm-up Quiz

var e = eval;

(function f() {var x = 5;e("x=7")console.log(x);

})();

What does the following code print?

Options: 5, 7, or something else

3

Warm-up Quiz

var e = eval;

(function f() {var x = 5;e("x=7")console.log(x);

})();

Correct answer: 5

3

Warm-up Quiz

var e = eval;

(function f() {var x = 5;e("x=7")console.log(x);

})();

Correct answer: 5

eval() evaluatesJavaScript codegiven as a string

3

Warm-up Quiz

var e = eval;

(function f() {var x = 5;e("x=7")console.log(x);

})();

Correct answer: 5

Store function into variable(functions are first-classobjects)

3

Warm-up Quiz

var e = eval;

(function f() {var x = 5;e("x=7")console.log(x);

})();

Correct answer: 5

Define a function andcall it immediately

3

Warm-up Quiz

var e = eval;

(function f() {var x = 5;e("x=7")console.log(x);

})();

Correct answer: 5

Indirect eval():Works in globalscope rather thanlocal scope

4

Follow Up on Last Week

(Hand-written notes)

5

Big Picture

Last lecture:� Syntax of languages

� Representations of programs

This lecture:� Assign meaning (= semantics) to programs

� Focus: Operational semantics of imperativelanguages

� Formal foundation for specifying languages andfor describing dynamic analyses

6

Plan for Today

� Motivation & preliminaries

� Abstract syntax of SIMP

� An abstract machine for SIMP

� Structural operation semantics forSIMP� Small-step semantics

� Big-step semantics

1

2

3

4

6

5

7

Plan for Today

� Motivation & preliminaries

� Abstract syntax of SIMP

� An abstract machine for SIMP

� Structural operation semantics forSIMP� Small-step semantics

� Big-step semantics

7

8

9

10

11

8

Plan for Today

� Motivation & preliminaries

� Abstract syntax of SIMP

� An abstract machine for SIMP

� Structural operation semantics forSIMP� Small-step semantics

� Big-step semantics

12

13

14

15