6 public class SemanticCheck {
10 public SemanticCheck(State state, TypeUtil tu) {
15 public void semanticCheck() {
16 SymbolTable classtable=state.getClassSymbolTable();
17 Iterator it=classtable.getDescriptorsIterator();
18 // Do descriptors first
20 ClassDescriptor cd=(ClassDescriptor)it.next();
21 System.out.println("Checking class: "+cd);
22 //Set superclass link up
23 if (cd.getSuper()!=null) {
24 cd.setSuper(typeutil.getClass(cd.getSuper()));
25 // Link together Field, Method, and Flag tables so classes
26 // inherit these from their superclasses
27 cd.getFieldTable().setParent(cd.getSuperDesc().getFieldTable());
28 cd.getMethodTable().setParent(cd.getSuperDesc().getMethodTable());
29 cd.getFlagTable().setParent(cd.getSuperDesc().getFlagTable());
32 /* Check to see that fields are well typed */
33 for(Iterator field_it=cd.getFields();field_it.hasNext();) {
34 FieldDescriptor fd=(FieldDescriptor)field_it.next();
35 System.out.println("Checking field: "+fd);
39 for(Iterator method_it=cd.getMethods();method_it.hasNext();) {
40 MethodDescriptor md=(MethodDescriptor)method_it.next();
45 it=classtable.getDescriptorsIterator();
46 // Do descriptors first
48 ClassDescriptor cd=(ClassDescriptor)it.next();
49 for(Iterator method_it=cd.getMethods();method_it.hasNext();) {
50 MethodDescriptor md=(MethodDescriptor)method_it.next();
51 checkMethodBody(cd,md);
55 for(Iterator task_it=state.getTaskSymbolTable().getDescriptorsIterator();task_it.hasNext();) {
56 TaskDescriptor td=(TaskDescriptor)task_it.next();
63 public void checkTypeDescriptor(TypeDescriptor td) {
67 String name=td.toString();
68 ClassDescriptor field_cd=(ClassDescriptor)state.getClassSymbolTable().get(name);
70 throw new Error("Undefined class "+name);
71 td.setClassDescriptor(field_cd);
77 public void checkField(ClassDescriptor cd, FieldDescriptor fd) {
78 checkTypeDescriptor(fd.getType());
81 public void checkTask(TaskDescriptor td) {
82 for(int i=0;i<td.numParameters();i++) {
83 /* Check that parameter is well typed */
84 TypeDescriptor param_type=td.getParamType(i);
85 checkTypeDescriptor(param_type);
87 /* Check the parameter's flag expression is well formed */
88 FlagExpressionNode fen=td.getFlag(td.getParameter(i));
89 if (!param_type.isClass())
90 throw new Error("Cannot have non-object argument to a task");
91 ClassDescriptor cd=param_type.getClassDesc();
92 checkFlagExpressionNode(cd, fen);
96 public void checkFlagExpressionNode(ClassDescriptor cd, FlagExpressionNode fen) {
100 FlagOpNode fon=(FlagOpNode)fen;
101 checkFlagExpressionNode(cd, fon.getLeft());
102 if (fon.getRight()!=null)
103 checkFlagExpressionNode(cd, fon.getRight());
108 FlagNode fn=(FlagNode)fen;
109 String name=fn.getFlagName();
110 FlagDescriptor fd=(FlagDescriptor)cd.getFlagTable().get(name);
112 throw new Error("Undeclared flag: "+name);
117 throw new Error("Unrecognized FlagExpressionNode");
121 public void checkMethod(ClassDescriptor cd, MethodDescriptor md) {
122 /* Check return type */
123 if (!md.isConstructor())
124 if (!md.getReturnType().isVoid())
125 checkTypeDescriptor(md.getReturnType());
127 for(int i=0;i<md.numParameters();i++) {
128 TypeDescriptor param_type=md.getParamType(i);
129 checkTypeDescriptor(param_type);
131 /* Link the naming environments */
132 if (!md.isStatic()) /* Fields aren't accessible directly in a static method, so don't link in this table */
133 md.getParameterTable().setParent(cd.getFieldTable());
135 if (!md.isStatic()) {
136 VarDescriptor thisvd=new VarDescriptor(new TypeDescriptor(cd),"this");
141 public void checkMethodBody(ClassDescriptor cd, MethodDescriptor md) {
142 System.out.println("Processing method:"+md);
143 BlockNode bn=state.getMethodBody(md);
144 checkBlockNode(md, md.getParameterTable(),bn);
147 public void checkBlockNode(MethodDescriptor md, SymbolTable nametable, BlockNode bn) {
148 /* Link in the naming environment */
149 bn.getVarTable().setParent(nametable);
150 for(int i=0;i<bn.size();i++) {
151 BlockStatementNode bsn=bn.get(i);
152 checkBlockStatementNode(md, bn.getVarTable(),bsn);
156 public void checkBlockStatementNode(MethodDescriptor md, SymbolTable nametable, BlockStatementNode bsn) {
158 case Kind.BlockExpressionNode:
159 checkBlockExpressionNode(md, nametable,(BlockExpressionNode)bsn);
162 case Kind.DeclarationNode:
163 checkDeclarationNode(md, nametable, (DeclarationNode)bsn);
166 case Kind.IfStatementNode:
167 checkIfStatementNode(md, nametable, (IfStatementNode)bsn);
171 checkLoopNode(md, nametable, (LoopNode)bsn);
174 case Kind.ReturnNode:
175 checkReturnNode(md, nametable, (ReturnNode)bsn);
178 case Kind.SubBlockNode:
179 checkSubBlockNode(md, nametable, (SubBlockNode)bsn);
185 void checkBlockExpressionNode(MethodDescriptor md, SymbolTable nametable, BlockExpressionNode ben) {
186 checkExpressionNode(md, nametable, ben.getExpression(), null);
189 void checkDeclarationNode(MethodDescriptor md, SymbolTable nametable, DeclarationNode dn) {
190 VarDescriptor vd=dn.getVarDescriptor();
191 checkTypeDescriptor(vd.getType());
192 Descriptor d=nametable.get(vd.getSymbol());
194 (d instanceof FieldDescriptor)) {
197 throw new Error(vd.getSymbol()+" defined a second time");
198 if (dn.getExpression()!=null)
199 checkExpressionNode(md, nametable, dn.getExpression(), vd.getType());
202 void checkSubBlockNode(MethodDescriptor md, SymbolTable nametable, SubBlockNode sbn) {
203 checkBlockNode(md, nametable, sbn.getBlockNode());
206 void checkReturnNode(MethodDescriptor md, SymbolTable nametable, ReturnNode rn) {
207 if (rn.getReturnExpression()!=null)
208 checkExpressionNode(md, nametable, rn.getReturnExpression(), md.getReturnType());
210 if (md.getReturnType()!=null&&!md.getReturnType().isVoid())
211 throw new Error("Need to return something for "+md);
214 void checkIfStatementNode(MethodDescriptor md, SymbolTable nametable, IfStatementNode isn) {
215 checkExpressionNode(md, nametable, isn.getCondition(), new TypeDescriptor(TypeDescriptor.BOOLEAN));
216 checkBlockNode(md, nametable, isn.getTrueBlock());
217 if (isn.getFalseBlock()!=null)
218 checkBlockNode(md, nametable, isn.getFalseBlock());
221 void checkExpressionNode(MethodDescriptor md, SymbolTable nametable, ExpressionNode en, TypeDescriptor td) {
223 case Kind.AssignmentNode:
224 checkAssignmentNode(md,nametable,(AssignmentNode)en,td);
227 checkCastNode(md,nametable,(CastNode)en,td);
229 case Kind.CreateObjectNode:
230 checkCreateObjectNode(md,nametable,(CreateObjectNode)en,td);
232 case Kind.FieldAccessNode:
233 checkFieldAccessNode(md,nametable,(FieldAccessNode)en,td);
235 case Kind.ArrayAccessNode:
236 checkArrayAccessNode(md,nametable,(ArrayAccessNode)en,td);
238 case Kind.LiteralNode:
239 checkLiteralNode(md,nametable,(LiteralNode)en,td);
241 case Kind.MethodInvokeNode:
242 checkMethodInvokeNode(md,nametable,(MethodInvokeNode)en,td);
245 checkNameNode(md,nametable,(NameNode)en,td);
248 checkOpNode(md,nametable,(OpNode)en,td);
254 void checkCastNode(MethodDescriptor md, SymbolTable nametable, CastNode cn, TypeDescriptor td) {
255 /* Get type descriptor */
256 if (cn.getType()==null) {
257 NameDescriptor typenamed=cn.getTypeName().getName();
258 String typename=typenamed.toString();
259 TypeDescriptor ntd=new TypeDescriptor(typeutil.getClass(typename));
263 /* Check the type descriptor */
264 TypeDescriptor cast_type=cn.getType();
265 checkTypeDescriptor(cast_type);
269 if (!typeutil.isSuperorType(td,cast_type))
270 throw new Error("Cast node returns "+cast_type+", but need "+td);
273 ExpressionNode en=cn.getExpression();
274 checkExpressionNode(md, nametable, en, null);
275 TypeDescriptor etd=en.getType();
276 if (typeutil.isSuperorType(cast_type,etd)) /* Cast trivially succeeds */
279 if (typeutil.isSuperorType(etd,cast_type)) /* Cast may succeed */
282 /* Different branches */
283 /* TODO: change if add interfaces */
284 throw new Error("Cast will always fail\n"+cn.printNode(0));
287 void checkFieldAccessNode(MethodDescriptor md, SymbolTable nametable, FieldAccessNode fan, TypeDescriptor td) {
288 ExpressionNode left=fan.getExpression();
289 checkExpressionNode(md,nametable,left,null);
290 TypeDescriptor ltd=left.getType();
291 String fieldname=fan.getFieldName();
293 FieldDescriptor fd=null;
294 if (ltd.isArray()&&fieldname.equals("length"))
295 fd=FieldDescriptor.arrayLength;
297 fd=(FieldDescriptor) ltd.getClassDesc().getFieldTable().get(fieldname);
299 throw new Error("Unknown field "+fieldname);
302 if (!typeutil.isSuperorType(td,fan.getType()))
303 throw new Error("Field node returns "+fan.getType()+", but need "+td);
306 void checkArrayAccessNode(MethodDescriptor md, SymbolTable nametable, ArrayAccessNode aan, TypeDescriptor td) {
307 ExpressionNode left=aan.getExpression();
308 checkExpressionNode(md,nametable,left,null);
310 checkExpressionNode(md,nametable,aan.getIndex(),new TypeDescriptor(TypeDescriptor.INT));
311 TypeDescriptor ltd=left.getType();
314 if (!typeutil.isSuperorType(td,aan.getType()))
315 throw new Error("Field node returns "+aan.getType()+", but need "+td);
318 void checkLiteralNode(MethodDescriptor md, SymbolTable nametable, LiteralNode ln, TypeDescriptor td) {
319 /* Resolve the type */
320 Object o=ln.getValue();
321 if (ln.getTypeString().equals("null")) {
322 ln.setType(new TypeDescriptor(TypeDescriptor.NULL));
323 } else if (o instanceof Integer) {
324 ln.setType(new TypeDescriptor(TypeDescriptor.INT));
325 } else if (o instanceof Long) {
326 ln.setType(new TypeDescriptor(TypeDescriptor.LONG));
327 } else if (o instanceof Float) {
328 ln.setType(new TypeDescriptor(TypeDescriptor.FLOAT));
329 } else if (o instanceof Boolean) {
330 ln.setType(new TypeDescriptor(TypeDescriptor.BOOLEAN));
331 } else if (o instanceof Double) {
332 ln.setType(new TypeDescriptor(TypeDescriptor.DOUBLE));
333 } else if (o instanceof Character) {
334 ln.setType(new TypeDescriptor(TypeDescriptor.CHAR));
335 } else if (o instanceof String) {
336 ln.setType(new TypeDescriptor(typeutil.getClass(TypeUtil.StringClass)));
340 if (!typeutil.isSuperorType(td,ln.getType()))
341 throw new Error("Field node returns "+ln.getType()+", but need "+td);
344 void checkNameNode(MethodDescriptor md, SymbolTable nametable, NameNode nn, TypeDescriptor td) {
345 NameDescriptor nd=nn.getName();
346 if (nd.getBase()!=null) {
348 /* Rewrite NameNode */
349 ExpressionNode en=translateNameDescriptorintoExpression(nd);
350 nn.setExpression(en);
351 checkExpressionNode(md,nametable,en,td);
353 String varname=nd.toString();
354 Descriptor d=(Descriptor)nametable.get(varname);
356 throw new Error("Name "+varname+" undefined");
358 if (d instanceof VarDescriptor) {
359 nn.setVar((VarDescriptor)d);
360 } else if (d instanceof FieldDescriptor) {
361 nn.setField((FieldDescriptor)d);
362 nn.setVar((VarDescriptor)nametable.get("this")); /* Need a pointer to this */
365 if (!typeutil.isSuperorType(td,nn.getType()))
366 throw new Error("Field node returns "+nn.getType()+", but need "+td);
370 void checkAssignmentNode(MethodDescriptor md, SymbolTable nametable, AssignmentNode an, TypeDescriptor td) {
371 checkExpressionNode(md, nametable, an.getSrc() ,td);
372 //TODO: Need check on validity of operation here
373 if (!((an.getDest() instanceof FieldAccessNode)||
374 (an.getDest() instanceof ArrayAccessNode)||
375 (an.getDest() instanceof NameNode)))
376 throw new Error("Bad lside in "+an.printNode(0));
377 checkExpressionNode(md, nametable, an.getDest(), null);
378 if (!typeutil.isSuperorType(an.getDest().getType(),an.getSrc().getType())) {
379 throw new Error("Type of rside ("+an.getSrc().getType()+") not compatible with type of lside ("+an.getDest().getType()+")"+an.printNode(0));
383 void checkLoopNode(MethodDescriptor md, SymbolTable nametable, LoopNode ln) {
384 if (ln.getType()==LoopNode.WHILELOOP||ln.getType()==LoopNode.DOWHILELOOP) {
385 checkExpressionNode(md, nametable, ln.getCondition(), new TypeDescriptor(TypeDescriptor.BOOLEAN));
386 checkBlockNode(md, nametable, ln.getBody());
389 /* Link in the initializer naming environment */
390 BlockNode bn=ln.getInitializer();
391 bn.getVarTable().setParent(nametable);
392 for(int i=0;i<bn.size();i++) {
393 BlockStatementNode bsn=bn.get(i);
394 checkBlockStatementNode(md, bn.getVarTable(),bsn);
396 //check the condition
397 checkExpressionNode(md, bn.getVarTable(), ln.getCondition(), new TypeDescriptor(TypeDescriptor.BOOLEAN));
398 checkBlockNode(md, bn.getVarTable(), ln.getBody());
399 checkBlockNode(md, bn.getVarTable(), ln.getUpdate());
404 void checkCreateObjectNode(MethodDescriptor md, SymbolTable nametable, CreateObjectNode con, TypeDescriptor td) {
405 TypeDescriptor[] tdarray=new TypeDescriptor[con.numArgs()];
406 for(int i=0;i<con.numArgs();i++) {
407 ExpressionNode en=con.getArg(i);
408 checkExpressionNode(md,nametable,en,null);
409 tdarray[i]=en.getType();
412 TypeDescriptor typetolookin=con.getType();
413 checkTypeDescriptor(typetolookin);
414 if ((!typetolookin.isClass())&&(!typetolookin.isArray()))
415 throw new Error("Can't allocate primitive type:"+con.printNode(0));
417 if (!typetolookin.isArray()) {
418 //Array's don't need constructor calls
419 ClassDescriptor classtolookin=typetolookin.getClassDesc();
420 System.out.println("Looking for "+typetolookin.getSymbol());
421 System.out.println(classtolookin.getMethodTable());
423 Set methoddescriptorset=classtolookin.getMethodTable().getSet(typetolookin.getSymbol());
424 MethodDescriptor bestmd=null;
426 for(Iterator methodit=methoddescriptorset.iterator();methodit.hasNext();) {
427 MethodDescriptor currmd=(MethodDescriptor)methodit.next();
428 /* Need correct number of parameters */
429 System.out.println("Examining: "+currmd);
430 if (con.numArgs()!=currmd.numParameters())
432 for(int i=0;i<con.numArgs();i++) {
433 if (!typeutil.isSuperorType(currmd.getParamType(i),tdarray[i]))
436 /* Method okay so far */
440 if (isMoreSpecific(currmd,bestmd)) {
442 } else if (!isMoreSpecific(bestmd, currmd))
443 throw new Error("No method is most specific");
445 /* Is this more specific than bestmd */
449 throw new Error("No method found for "+con.printNode(0));
450 con.setConstructor(bestmd);
455 /** Check to see if md1 is more specific than md2... Informally
456 if md2 could always be called given the arguments passed into
459 boolean isMoreSpecific(MethodDescriptor md1, MethodDescriptor md2) {
460 /* Checks if md1 is more specific than md2 */
461 if (md1.numParameters()!=md2.numParameters())
463 for(int i=0;i<md1.numParameters();i++) {
464 if (!typeutil.isSuperorType(md2.getParamType(i), md1.getParamType(i)))
467 if (!typeutil.isSuperorType(md2.getReturnType(), md1.getReturnType()))
472 ExpressionNode translateNameDescriptorintoExpression(NameDescriptor nd) {
473 String id=nd.getIdentifier();
474 NameDescriptor base=nd.getBase();
476 return new NameNode(nd);
478 return new FieldAccessNode(translateNameDescriptorintoExpression(base),id);
482 void checkMethodInvokeNode(MethodDescriptor md, SymbolTable nametable, MethodInvokeNode min, TypeDescriptor td) {
483 /*Typecheck subexpressions
484 and get types for expressions*/
486 TypeDescriptor[] tdarray=new TypeDescriptor[min.numArgs()];
487 for(int i=0;i<min.numArgs();i++) {
488 ExpressionNode en=min.getArg(i);
489 checkExpressionNode(md,nametable,en,null);
490 tdarray[i]=en.getType();
492 TypeDescriptor typetolookin=null;
493 if (min.getExpression()!=null) {
494 checkExpressionNode(md,nametable,min.getExpression(),null);
495 typetolookin=min.getExpression().getType();
496 } else if (min.getBaseName()!=null) {
497 String rootname=min.getBaseName().getRoot();
498 if (nametable.get(rootname)!=null) {
499 //we have an expression
500 min.setExpression(translateNameDescriptorintoExpression(min.getBaseName()));
501 checkExpressionNode(md, nametable, min.getExpression(), null);
502 typetolookin=min.getExpression().getType();
505 ClassDescriptor cd=typeutil.getClass(min.getBaseName().getSymbol());
507 throw new Error(min.getBaseName()+" undefined");
508 typetolookin=new TypeDescriptor(cd);
511 typetolookin=new TypeDescriptor(md.getClassDesc());
513 if (!typetolookin.isClass())
515 ClassDescriptor classtolookin=typetolookin.getClassDesc();
516 System.out.println("Method name="+min.getMethodName());
517 Set methoddescriptorset=classtolookin.getMethodTable().getSet(min.getMethodName());
518 MethodDescriptor bestmd=null;
520 for(Iterator methodit=methoddescriptorset.iterator();methodit.hasNext();) {
521 MethodDescriptor currmd=(MethodDescriptor)methodit.next();
522 /* Need correct number of parameters */
523 if (min.numArgs()!=currmd.numParameters())
525 for(int i=0;i<min.numArgs();i++) {
526 if (!typeutil.isSuperorType(currmd.getParamType(i),tdarray[i]))
529 /* Method okay so far */
533 if (isMoreSpecific(currmd,bestmd)) {
535 } else if (!isMoreSpecific(bestmd, currmd))
536 throw new Error("No method is most specific");
538 /* Is this more specific than bestmd */
542 throw new Error("No method found for :"+min.printNode(0));
543 min.setMethod(bestmd);
544 /* Check whether we need to set this parameter to implied this */
545 if (!bestmd.isStatic()) {
546 if (min.getExpression()==null) {
547 ExpressionNode en=new NameNode(new NameDescriptor("this"));
548 min.setExpression(en);
549 checkExpressionNode(md, nametable, min.getExpression(), null);
556 void checkOpNode(MethodDescriptor md, SymbolTable nametable, OpNode on, TypeDescriptor td) {
557 checkExpressionNode(md, nametable, on.getLeft(), null);
558 if (on.getRight()!=null)
559 checkExpressionNode(md, nametable, on.getRight(), null);
560 TypeDescriptor ltd=on.getLeft().getType();
561 TypeDescriptor rtd=on.getRight()!=null?on.getRight().getType():null;
562 TypeDescriptor lefttype=null;
563 TypeDescriptor righttype=null;
564 Operation op=on.getOp();
567 case Operation.LOGIC_OR:
568 case Operation.LOGIC_AND:
569 if (!(ltd.isBoolean()&&rtd.isBoolean()))
573 on.setRightType(rtd);
574 on.setType(new TypeDescriptor(TypeDescriptor.BOOLEAN));
577 case Operation.BIT_OR:
578 case Operation.BIT_XOR:
579 case Operation.BIT_AND:
580 // 5.6.2 Binary Numeric Promotion
581 //TODO unboxing of reference objects
582 if (ltd.isDouble()||rtd.isDouble())
584 else if (ltd.isFloat()||rtd.isFloat())
586 else if (ltd.isLong()||rtd.isLong())
587 lefttype=new TypeDescriptor(TypeDescriptor.LONG);
589 lefttype=new TypeDescriptor(TypeDescriptor.INT);
592 on.setLeftType(lefttype);
593 on.setRightType(righttype);
594 on.setType(lefttype);
597 case Operation.EQUAL:
598 case Operation.NOTEQUAL:
599 // 5.6.2 Binary Numeric Promotion
600 //TODO unboxing of reference objects
601 if (ltd.isBoolean()||rtd.isBoolean()) {
602 if (!(ltd.isBoolean()&&rtd.isBoolean()))
604 righttype=lefttype=new TypeDescriptor(TypeDescriptor.BOOLEAN);
605 } else if (ltd.isPtr()||rtd.isPtr()) {
606 if (!(ltd.isPtr()&&rtd.isPtr()))
610 } else if (ltd.isDouble()||rtd.isDouble())
611 righttype=lefttype=new TypeDescriptor(TypeDescriptor.DOUBLE);
612 else if (ltd.isFloat()||rtd.isFloat())
613 righttype=lefttype=new TypeDescriptor(TypeDescriptor.FLOAT);
614 else if (ltd.isLong()||rtd.isLong())
615 righttype=lefttype=new TypeDescriptor(TypeDescriptor.LONG);
617 righttype=lefttype=new TypeDescriptor(TypeDescriptor.INT);
619 on.setLeftType(lefttype);
620 on.setRightType(righttype);
621 on.setType(new TypeDescriptor(TypeDescriptor.BOOLEAN));
630 // 5.6.2 Binary Numeric Promotion
631 //TODO unboxing of reference objects
632 if (!ltd.isNumber()||!rtd.isNumber())
635 if (ltd.isDouble()||rtd.isDouble())
636 lefttype=new TypeDescriptor(TypeDescriptor.DOUBLE);
637 else if (ltd.isFloat()||rtd.isFloat())
638 lefttype=new TypeDescriptor(TypeDescriptor.FLOAT);
639 else if (ltd.isLong()||rtd.isLong())
640 lefttype=new TypeDescriptor(TypeDescriptor.LONG);
642 lefttype=new TypeDescriptor(TypeDescriptor.INT);
644 on.setLeftType(lefttype);
645 on.setRightType(righttype);
646 on.setType(new TypeDescriptor(TypeDescriptor.BOOLEAN));
650 //TODO: Need special case for strings eventually
657 // 5.6.2 Binary Numeric Promotion
658 //TODO unboxing of reference objects
659 if (!ltd.isNumber()||!rtd.isNumber())
660 throw new Error("Error in "+on.printNode(0));
662 if (ltd.isDouble()||rtd.isDouble())
663 lefttype=new TypeDescriptor(TypeDescriptor.DOUBLE);
664 else if (ltd.isFloat()||rtd.isFloat())
665 lefttype=new TypeDescriptor(TypeDescriptor.FLOAT);
666 else if (ltd.isLong()||rtd.isLong())
667 lefttype=new TypeDescriptor(TypeDescriptor.LONG);
669 lefttype=new TypeDescriptor(TypeDescriptor.INT);
671 on.setLeftType(lefttype);
672 on.setRightType(righttype);
673 on.setType(lefttype);
676 case Operation.LEFTSHIFT:
677 case Operation.RIGHTSHIFT:
678 if (!rtd.isIntegerType())
680 //5.6.1 Unary Numeric Promotion
681 if (rtd.isByte()||rtd.isShort()||rtd.isInt())
682 righttype=new TypeDescriptor(TypeDescriptor.INT);
686 on.setRightType(righttype);
687 if (!ltd.isIntegerType())
689 case Operation.UNARYPLUS:
690 case Operation.UNARYMINUS:
691 case Operation.POSTINC:
692 case Operation.POSTDEC:
693 case Operation.PREINC:
694 case Operation.PREDEC:
697 //5.6.1 Unary Numeric Promotion
698 if (ltd.isByte()||ltd.isShort()||ltd.isInt())
699 lefttype=new TypeDescriptor(TypeDescriptor.INT);
702 on.setLeftType(lefttype);
703 on.setType(lefttype);
712 if (!typeutil.isSuperorType(td, on.getType())) {
713 System.out.println(td);
714 System.out.println(on.getType());
715 throw new Error("Type of rside not compatible with type of lside"+on.printNode(0));