示例#1
0
 /** @see jaskell.compiler.JaskellVisitor#visit(Conditional) */
 public Object visit(Conditional conditional) {
   Type iff = (Type) conditional.getIfFalse().visit(this);
   Type ift = (Type) conditional.getIfTrue().visit(this);
   Type tcond = (Type) conditional.getCondition().visit(this);
   tcond = tu.unify(tcond, Primitives.BOOL, typeVariablesMap);
   if (!(tcond.equals(Primitives.BOOL)))
     throw new TypeError("Conditional expression is not of type Bool : " + tcond);
   /* unify false and true parts */
   Type uni = tu.unify(iff, ift, typeVariablesMap);
   conditional.setType(uni);
   return uni;
 }
示例#2
0
 /*
  * (non-Javadoc)
  *
  * @see jaskell.compiler.JaskellVisitor#visit(jaskell.compiler.core.Conditional)
  */
 public Object visit(Conditional conditional) {
   conditional.setCondition((Expression) conditional.getCondition().visit(this));
   conditional.setIfFalse((Expression) conditional.getIfFalse().visit(this));
   conditional.setIfTrue((Expression) conditional.getIfTrue().visit(this));
   return conditional;
 }