.. (לתיקייה המכילה) | ||
For a function with an array parameter of size X, what should the offset of the array be? | |
The offset should be -X if it is the first parameter, or the offset of the previous parameter - X, otherwise. For the above example, arr's offset should be -8 and arr2's offset should be -11. |
Is a byte array assignable to an int array? | |
No. Assignment between two arrays is legal only if they have the same type, meaning they are of the same size and were declared with the same type exactly. |
Can two functions with the same name be redefined? Two parameters? | |
The shadowing rule that appears for variables holds for all identifiers: an identifier cannot be declared if another identifier of the same name already exists in scope or in one of the parent scopes. |
In the case of an error, should we print anything but the error? | |
You should print the content of any scopes that have been successfully reduced. See t2.{in,out} for an example. |
When a missing main is identified, is the error to be printed before or after endScope is called? | |
In general, endScope and the rest of the prints are to be called after a scope has been reduced and deemed to be valid. So as a general rule, printouts should be the last thing that happens in the handling of a scope. This means that for the global scope (when reducing Program) identification of no main of the correct prototype should happen before the prints, and in the case of an error, no printouts for the scope will occur. |
If during parsing I see a main function with parameters or with a return type other than void should I exit with an errorMainMissing? | |
No. Checking that there exists a main function with the correct parameters should only be done after parsing the entire program. |
Do we have to check that a function has a return statement? | |
No. you should only check that if a return statement exists then it has the right type. |
For an if/while statement followed by a block {} how many scopes should we open? | |
Two scopes. One for the if/while and one for the block. Notice that in this case the if/while scope will be empty. The test t2.in/out shows such an example. |