SLIDE 5 5
17
The What and Why of Compilers
Name and Type Linking Name and Type Linking
method printNumber type void args int number int base sequence decl type Strin g name ns const "" if == lvalue number const assign lvalue ns const "0" while > lvalue number const sequence assign assign lvalue ns + % lvalue number lvalue base lvalue ns lvalue number / lvalue number lvalue base System.out..print + lvalue ns const \n
18
The What and Why of Compilers
Type Checking Type Checking
method printNumber type void args int number int base sequence decl type String name ns const "" if == lvalue number const assign lvalue ns const "0" while > lvalue number const sequence assign assign lvalue ns concat % lvalue number lvalue base lvalue ns lvalue number / lvalue number lvalue base System.out..print concat lvalue ns const \n int int String int int int int int int int int int boolean boolean String String String String String String String String String int
19
The What and Why of Compilers
Type Checking Transformations Type Checking Transformations
method printNumber type void args int number int base sequence decl type String name ns const "" if == lvalue number const assign lvalue ns const "0" while > lvalue number const sequence assign assign lvalue ns % lvalue number lvalue base lvalue ns lvalue number / lvalue number lvalue base System.out..print lvalue ns const \n int int String int int int int int int int int int boolean boolean String String String String String String String String String int concat concat
Operator + is transformed into concat 20
The What and Why of Compilers
Resource Allocation Resource Allocation
method printNumber type void args int number int base sequence decl type String name ns const "" if == lvalue number const assign lvalue ns const "0" while > lvalue number const sequence assign assign lvalue ns concat % lvalue number lvalue base lvalue ns lvalue number / lvalue number lvalue base System.out..print concat+ lvalue ns const \n int int String int int int int int int int int int boolean boolean String String String String String String String String String int 1 2 3