正在加载图片...
Memory references t1=*(t2+8) *(t1+-4)=t2 (optional offset must be integer constant, can be positive or negative) Array indexing To access arr[5], add offset multiplied by elem size to base and deref Object fields, method dispatch To access ivars. add offset to base. deref To call method retrieve function address from vtable. use ACall Miscellaneous: (used for runtime errors) Data specification VTable ClassName Ll, L2, Here is an example of a simple Decaf program and its TAC translation void main(( c= a+ b Print(c) BeginFuncWithParams Var ci Var to Var t1 Var t2 t2=a + b LCall PrintInt(c)i What we have to do is figure out how to get from one to the other as we parse. This includes not only generating the TAC, but figuring out the use of temp variables,Memory references: t1 = *(t2); t1 = *(t2 + 8); *(t1) = t2; *(t1 + -4) = t2; (optional offset must be integer constant, can be positive or negative) Array indexing: To access arr[5], add offset multiplied by elem size to base and deref Object fields, method dispatch: To access ivars, add offset to base, deref To call method, retrieve function address from vtable, use ACall Miscellaneous: Halt; (used for runtime errors) Data specification: VTable ClassName = L1, L2, ...; Here is an example of a simple Decaf program and its TAC translation: void main() { int a; int b; int c; a = 1; b = 2; c = a + b; Print(c); } main: BeginFuncWithParams; Var a; Var b; Var c; Var _t0; _t0 = 1; a = _t0; Var _t1; _t1 = 2; b = _t1; Var _t2; _t2 = a + b; c = _t2; LCall _PrintInt(c); EndFunc; What we have to do is figure out how to get from one to the other as we parse. This includes not only generating the TAC, but figuring out the use of temp variables
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有