Re: [Jastadd] [Q] unknown type ?

From: Jesper Öqvist <jesper.oqvist_at_cs.lth.se>
Date: Wed, 21 Dec 2011 12:38:18 +0100

Hello Hyunik,
I think the reason AssignExpr.sourceType() is the unkown type unless
it's a primitive type is to handle arithmetic assign expressions such as
AssignAddExpr with reference operands. The AssignSimpleExpr has the
following equation for sourceType:

   syn TypeDecl AssignSimpleExpr.sourceType() = getSource().type();

which always returns the actual type of the source operand.
AssignSimpleExpr, I think, is the only assignment expression that works
with reference operands.

/Jesper

On 12/21/2011 10:36 AM, Na, Hyunik wrote:
> Hello JastAddJ developers,
>
> In Java1.4Frontend/TypeCheck.jrag, the following line exists:
>
> syn TypeDecl AssignExpr.sourceType() =
> getSource().type().isPrimitive() ? getSource().type() : unknownType();
>
> which means the source type of an assign expression is the unknown type
> unless it is a primitive type.
> Why should it be?
>
> and the AssignSimpleExpr.typeCheck() is written as follows:
>
> public void AssignSimpleExpr.typeCheck() {
> if(!getDest().isVariable())
> error("left hand side is not a variable");
> else if(!sourceType().assignConversionTo(getDest().type(), getSource())
> && !sourceType().isUnknown())
> error("can not assign " + getDest() + " of type " +
> getDest().type().typeName() +
> " a value of type " + sourceType().typeName());
> }
>
> This means that, if the source type is unknown, it is not an error even when
> the source type is not assign-compatible
> with the destination type for a simple assignment.
> It is hard for me to figure out what's going on here.
>
> Why do you introduce the unknown type during the type checking process?
>
>
> - Hyunik
>
> _______________________________________________
> JastAdd mailing list
> JastAdd_at_cs.lth.se
> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
>
Received on Wed Dec 21 2011 - 12:38:29 CET

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST