ps4-sol - ECE 468 Problem Set 4 Symbol Tables Declarations...

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

View Full Document Right Arrow Icon
ECE 468 Problem Set 4: Symbol Tables, Declarations and Expressions 1. Write out the symbol table(s) (including any attributes that you think are important) for the following piece of code: int x; float y; string z = "hello"; void foo() { int x; float z; } void main() { int q; string p = "goodbye"; } Answer: Symbol table for GLOBAL: Type Name Value Offset int x 0 float y 4 string z “hello” 8 Symbol table for MAIN: Type Name Value Offset int q 0 string p “goodbye” 4 Symbol table for FOO: Type Name Value Offset int x 0 float z 4 2. Explain the difference between an L-value and an R-value Answer: An L-value is an address that can be stored to ( i.e. , a value that can 1
Background image of page 1

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

View Full Document Right Arrow Icon
appear on the left-hand side of an assignment statement). An R-value is an actual data value ( i.e. , a value that can appear on the right-hand side of an assignment statement). 3. ECE 468 student Cam Piler has come up with a code generation strategy for his project: while walking his Abstract Syntax Tree, whenever he sees a variable, he will
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 3

ps4-sol - ECE 468 Problem Set 4 Symbol Tables Declarations...

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

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