Java Reference
In-Depth Information
procedure
visit
(ArrayReferencing ar )
call
visit
C
hildren
( ar )
if ar . arrayName . type = errorType
then ar . type errorType
else
72
if ar . arrayName . kind arrayTypeDescriptor
then
call
73
error
( ar . arrayName ,
is not an array ”)
ar . type errorType
else
ar . type ar . arrayName . type . elementType
if ar . indexExpr . type errorType and ar . indexExpr . type integer
then
74
call
error
(” Index expression is not an integer :”
, ar . indexExpr )
75
end
Figure 8.37: Type checking array references
procedure visit
(StructReferencing sr )
call sr . ob jectName . accept( this )
76
if sr . ob jectName . type = errorType
then sr . type errorType
else
77
if sr . ob jectName . type structTypeDescriptor
then
call
78
error
( sr . ob jectName ,
does not name a struct .
”)
sr . type errorType
else
st sr . ob jectName . type . fields
attributeRe f st . retrieveSymbol( fieldName . name )
if attributeRe f =
79
null
then
call
error
( fieldName . name ,
is not a f ield o f
, sr . ob jectName .
)
sr . type errorType
else
sr . type attributeRe f . f ieldType
end
Figure 8.38: Type checking structure references
 
Search WWH ::




Custom Search