dis9 - CMPSC 160 Translation of Programming Languages...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CMPSC 160 Translation of Programming Languages Project 5: Code Generation Plan for today Go over project 4 results Talk about project 5 TA evaluation Project 5 Lexer Parser Proj 2 Proj 3 Abstract Syntax Tree Type Checking Proj 4 Code Generation Proj 5 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 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 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 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 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 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 x86 Assembly We'll use 32bit registers and operations only eax, ebp...eax, ebp....
View Full Document

This note was uploaded on 02/19/2012 for the course ENGR 361 taught by Professor Drexel during the Spring '12 term at Bloomsburg.

Page1 / 27

dis9 - CMPSC 160 Translation of Programming Languages...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online