operational semantics program testing and analysis€¦ · representations of programs this...
TRANSCRIPT
![Page 1: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/1.jpg)
1
Program Testing and Analysis:
Operational Semantics
Prof. Dr. Michael Pradel
Software Lab, TU Darmstadt
![Page 2: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/2.jpg)
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
![Page 3: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/3.jpg)
3
Warm-up Quiz
var e = eval;
(function f() {var x = 5;e("x=7")console.log(x);
})();
Correct answer: 5
![Page 4: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/4.jpg)
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
![Page 5: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/5.jpg)
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)
![Page 6: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/6.jpg)
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
![Page 7: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/7.jpg)
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
![Page 8: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/8.jpg)
4
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
![Page 9: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/9.jpg)
5
Plan for Today
� Motivation & preliminaries
� Abstract syntax of SIMP
� An abstract machine for SIMP
� Structural operation semantics forSIMP� Small-step semantics
� Big-step semantics
![Page 10: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/10.jpg)
1
![Page 11: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/11.jpg)
2
![Page 12: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/12.jpg)
3
![Page 13: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/13.jpg)
4
![Page 14: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/14.jpg)
5
![Page 15: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/15.jpg)
6
![Page 16: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/16.jpg)
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
![Page 17: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/17.jpg)
7
![Page 18: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/18.jpg)
8
![Page 19: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/19.jpg)
9
![Page 20: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/20.jpg)
10
![Page 21: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/21.jpg)
11
![Page 22: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/22.jpg)
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
![Page 23: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/23.jpg)
12
![Page 24: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/24.jpg)
13
![Page 25: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/25.jpg)
14
![Page 26: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/26.jpg)
15
![Page 27: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/27.jpg)
16
![Page 28: Operational Semantics Program Testing and Analysis€¦ · Representations of programs This lecture: Assign meaning (= semantics) to programs Focus: Operational semantics of imperative](https://reader034.vdocuments.site/reader034/viewer/2022052016/602f5d1647e4dd14d4701ba0/html5/thumbnails/28.jpg)
17