{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

dis9 - CMPSC 160 Translation of Programming Languages...

Info icon This preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPSC 160 Translation of Programming Languages Project 5: Code Generation
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Plan for today Go over project 4 results Talk about project 5 TA evaluation
Image of page 2
Project 5 Lexer Parser Proj 2 Proj 3 Abstract Syntax Tree Type Checking Proj 4 Code Generation Proj 5
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Project 5 You need to generate x86 assembly Just fprintf assembly to m_outputfile It has to be be runnable: At least the Main() function Has to return a value, at least a constant Otherwise, not gradeable
Image of page 4
Project 5 – Important Note We're removing nested functions from Simple For example, this is no longer allowed: integer function Main() { integer function asd() { return 1; } return 1; } You don't need to modify your parser or anything; we'll just not use these inputs
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Project 5 – Important Note To visit a particular child call: m_child → accept (this); That will call the visit__ method of your visitor on that child You will need to use this, a lot
Image of page 6
Project 5 - Files to modify ast.cdef astbuilder.gawk ast.hpp ast.cpp primitive.hpp primitive.cpp symtab.hpp symtab.cpp lexer lexer.l flex parser parser.ypp bison main.cpp typecheck.cpp input.simple x86 asm codegen.cpp
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Project 5 - Files to modify main.cpp Uncomment the codegen line symtab.hpp You need to add array size info to symbols (e.g. add a new field to Symbol) typecheck.hpp Set size for IntArray Symbols codegen.cpp x86 generation using a Visitor
Image of page 8
Project plan - suggestion First step Make Main() executable, no variables or other functions Evaluate expressions Second step Variables and assignments; ints and bools only Control flow Third step Function calls, no arguments Once that is working, add arguments Fourth step IntArrays
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
x86 Assembly
Image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern