for the unary operator * the operand should be a pointer to complete type, like
*(*int) in form of
result should be object…are we supposed to return the type of int,
*int (return pointsTo.getType???) in these three cases respectly?
for the & operator, like if we have
&(*char), are we supposed to return a
**char type??? so in these cases , it makes sense to make a constructor for pointerType with the his property pointsTo (here should be intType and IntegerPointerType)?
Thanks in advance!
If you’re asking about result types, your examples for
* are correct.
&, what you wrote does not make any sense, syntactically.
Assuming, however, that you mean
a has type
cp has type
char*, it would be correct.
Keep in mind though that these are only positive examples and there are conditions that need to be satisfied before you can return anything.
yes, i mean the result types…
for the & operator, then we only need to check if the operand is a complete type and also if it is a L-Value (variable or pointer to a complete Type)…like &int, &char*, return types should be int and char* respectively…
so we do not need to consider the condition of the result that it should be pointer on page 16…just confused about it
condition of the result
the result is not a condition. If the conditions on the operand are met, then the result type is a pointer (in the case of
&), otherwise, the expression is ill-typed.