正在加载图片...
Now let s consider what needs to be done to deal with arrays(note the TAC code below doesn 't do array bounds checking, that will be your job to implement ky (int[ arr)i arr[1]=arr[0]*2 BeginfuncWithParams arri Var t2 t2=t1*t0; Var t t3= arr t2: Var t6: t5 arr t61 Var t87 t8=*(t7) Var t9 Var t10: t8*t9 t10; EndFunc: Before we deal with classes, we should look at how function calls are implemented This will facilitate our study of methods as they are used in classes. a program with a simple function call nt foo (int a, int b)i return a+ b void main() int d: foo(c, d) BeginfuncWithParams a, biNow let’s consider what needs to be done to deal with arrays (note the TAC code below doesn't do array bounds checking, that will be your job to implement!) void Binky(int[] arr) { arr[1] = arr[0] * 2; } _Binky: BeginFuncWithParams arr; Var _t0; _t0 = 1; Var _t1; _t1 = 4; Var _t2; _t2 = _t1 * _t0; Var _t3; _t3 = arr + _t2; Var _t4; _t4 = 0; Var _t5; _t5 = 4; Var _t6; _t6 = _t5 * _t4; Var _t7; _t7 = arr + _t6; Var _t8; _t8 = *(_t7); Var _t9; _t9 = 2; Var _t10; _t10 = _t8 * _t9; *(_t3) = _t10; EndFunc; Before we deal with classes, we should look at how function calls are implemented. This will facilitate our study of methods as they are used in classes. A program with a simple function call: int foo(int a, int b) { return a + b; } void main() { int c; int d; foo(c, d); } _foo: BeginFuncWithParams a, b;
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有