Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 536 Intro to Programming Languages and Compliers Spring 2009 Evan Driscoll.

Similar presentations


Presentation on theme: "CS 536 Intro to Programming Languages and Compliers Spring 2009 Evan Driscoll."— Presentation transcript:

1 CS 536 Intro to Programming Languages and Compliers Spring 2009 Evan Driscoll

2 Introduction to the theory and practice of compiler design. Comparison of features of several programming languages and their implications for implementation techniques. Several programming projects required. “ ”

3 CS 536 Intro to Programming Languages and Compliers Spring 2009 Evan Driscoll

4 CS 536 Introduction to Compiler Construction Spring 2009 Evan Driscoll

5 Not Charles Fischer

6

7 Class home page: http://cs.wisc.edu/~cs536-1/ http://cs.wisc.edu/~cs536-1/

8 What is a compiler? class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Compiler 10110101010101110000110 10101001010101010111010 10010110101010010010011 10001010101010101010111 01010101011010101010111 00001101010100101010101 01110101001011010101001 00100111000101010101010 10101110101010101101010 10101110000110101010010 10101010111010100101101 01010010010011100010101 Source code (e.g. C++) Target code (e.g. machine code)

9 class D : public C { public: int foo(std::string & s); }; int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); }; int D::foo(std::string & s) { return s.length(); } Compiler struct D { struct C; }; Int D__foo(std__string * s) { return std__string_length(s); } struct D { struct C; }; Int D__foo(std__string * s) { return std__string_length(s); } Source code (e.g. C++) Target code (e.g. C) What is a compiler?

10 class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Compiler 10110101010101110000110 10101001010101010111010 10010110101010010010011 10001010101010101010111 01010101011010101010111 00001101010100101010101 01110101001011010101001 00100111000101010101010 10101110101010101101010 10101110000110101010010 10101010111010100101101 01010010010011100010101

11 class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Compiler 10110101010101110000110 10101001010101010111010 10010110101010010010011 10001010101010101010111 01010101011010101010111 00001101010100101010101 01110101001011010101001 00100111000101010101010 10101110101010101101010 10101110000110101010010 10101010111010100101101 01010010010011100010101 Source code (e.g. C++) Target code (e.g. machine code)

12 class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Compiler 10110101010101110000110 10101001010101010111010 10010110101010010010011 10001010101010101010111 01010101011010101010111 00001101010100101010101 01110101001011010101001 00100111000101010101010 10101110101010101101010 10101110000110101010010 10101010111010100101101 01010010010011100010101 Command line args: ‘svn’, ‘stat’, ‘-u’ Results of system calls: readdir. -> foo.txt, bar.c stat foo.txt stat bar.c stat.svn/foo.txt stat.svn/bar.txt Results of network traffic: Communication w/ repo Command line args: ‘svn’, ‘stat’, ‘-u’ Results of system calls: readdir. -> foo.txt, bar.c stat foo.txt stat bar.c stat.svn/foo.txt stat.svn/bar.txt Results of network traffic: Communication w/ repo Output to stdout: M foo.txt ? bar.c Network traffic: Communication wi/ repo Output to stdout: M foo.txt ? bar.c Network traffic: Communication wi/ repo

13 class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Compiler 10110101010101110000110 10101001010101010111010 10010110101010010010011 10001010101010101010111 01010101011010101010111 00001101010100101010101 01110101001011010101001 00100111000101010101010 10101110101010101101010 10101110000110101010010 10101010111010100101101 01010010010011100010101 Command line args: ‘svn’, ‘stat’, ‘-u’ Results of system calls: readdir. -> foo.txt, bar.c stat foo.txt stat bar.c stat.svn/foo.txt stat.svn/bar.txt Results of network traffic: Communication w/ repo Command line args: ‘svn’, ‘stat’, ‘-u’ Results of system calls: readdir. -> foo.txt, bar.c stat foo.txt stat bar.c stat.svn/foo.txt stat.svn/bar.txt Results of network traffic: Communication w/ repo Output to stdout: M foo.txt ? bar.c Network traffic: Communication wi/ repo Output to stdout: M foo.txt ? bar.c Network traffic: Communication wi/ repo Runtime

14 class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Interpreter Command line args: ‘svn’, ‘stat’, ‘-u’ Results of system calls: readdir. -> foo.txt, bar.c stat foo.txt stat bar.c stat.svn/foo.txt stat.svn/bar.txt Results of network traffic: Communication w/ repo Command line args: ‘svn’, ‘stat’, ‘-u’ Results of system calls: readdir. -> foo.txt, bar.c stat foo.txt stat bar.c stat.svn/foo.txt stat.svn/bar.txt Results of network traffic: Communication w/ repo Output to stdout: M foo.txt ? bar.c Network traffic: Communication wi/ repo Output to stdout: M foo.txt ? bar.c Network traffic: Communication wi/ repo

15 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Compiler 1101010101010101 1001101111010101 0011010101011010 1011010001011011 0101010110101010 0101010110101010 1000101010001011 0110101010110101 1010101001010111 1010100101010100 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Interpreter Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files,

16 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Compiler push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar Interpreter Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files,

17 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Compiler push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar Virtual Machine Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files,

18 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Compiler push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files, Control Bytecode Interpreter JIT Compiler

19 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Compiler push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files, Control Bytecode Interpreter JIT Compiler class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Interpreter Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files, class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } Compiler 1011010101010111000011010101 0010101010101110101001011010 1010010010011100010101010101 0101011101010101011010101010 1110000110101010010101010101 1101010010110101010010010011 1000101010101010101011101010 1010110101010101110000110101 0100101010101011101010010110 101010010010011100010101 Runtime

20 class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar push 5 push add push z multi call bar Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files, Control Bytecode Interpreter class D : public C { public: int f( std::string&s); } class D : public C { public: int f( std::string&s); } Various input streams; files, network, command line args, system calls Various output methods: files, standard output, files, class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } class D : public C { public: int foo(std::string & s); } int D::foo(std::string & s) { return s.length(); } 1011010101010111000011010101 0010101010101110101001011010 1010010010011100010101010101 0101011101010101011010101010 1110000110101010010101010101 1101010010110101010010010011 1000101010101010101011101010 1010110101010101110000110101 0100101010101011101010010110 101010010010011100010101 Compiler JIT Compiler Interpreter Compiler Runtime


Download ppt "CS 536 Intro to Programming Languages and Compliers Spring 2009 Evan Driscoll."

Similar presentations


Ads by Google