TypeCheck by while statement

for while statement there are fileds like Expression condition and statement body, which are necessary in every while statement
should i do

          condition.checktype(d, s);
          body.checktype(d,s) ;
         if(invariante != null)
           do invariante.checktype
        if(term != null)
           also do a typecheck for term

(invariante and term are Expression)

is it too simple?

since condition is a expression, its typeCheck methode will return a Type type or null with a printError() , but body is a statement, whose typecheck method does not return any type (void)
do I need to do something more to handle them differently?

You probably want to do something with the types as well, as in: Your condition, invariant and termination condition should have the proper types.

i think condition should have integerType? for c 0 and 1 represents true and false, which are for condition?

invariant and term are some kind of conditions? and they should also be integerType?

Conditions must have scalar type.

Termination functions must have integer type since they represent natural numbers

1 Like

thanks very much :slight_smile: