예제 #1
0
 public void genConversionOperation(
     EGLClass type, Context ctx, TabbedWriter out, AsExpression arg) {
   if (arg.getConversionOperation() != null && !needsConversion(arg.getConversionOperation())) {
     ctx.invoke(genExpression, arg.getObjectExpr(), ctx, out);
   } else {
     // we need to invoke the logic in type template to call back to the other conversion
     // situations
     ctx.invokeSuper(this, genConversionOperation, type, ctx, out, arg);
   }
 }
예제 #2
0
 public void genTypeDependentOptions(
     ParameterizableType type, Context ctx, TabbedWriter out, AsExpression arg) {
   out.print(", ");
   // if we get here, then we have been given an integer literal, to be represented as a
   // FixedPrecisionType. So, we must
   // set the dependend options to be a list of nines
   if (arg.getObjectExpr() instanceof IntegerLiteral) {
     String value = ((IntegerLiteral) arg.getObjectExpr()).getValue();
     if (value.startsWith("-")) value = value.substring(1);
     if (value.length() > 4) out.print("egl.javascript.BigDecimal.prototype.NINES[8]");
     else out.print("egl.javascript.BigDecimal.prototype.NINES[3]");
   } else out.print("egl.javascript.BigDecimal.prototype.NINES[8]");
 }
예제 #3
0
 public void genConversionOperation(
     FixedPrecisionType type, Context ctx, TabbedWriter out, AsExpression arg) {
   Type toType = arg.getEType();
   Type fromType = arg.getObjectExpr().getType();
   if ((arg.getConversionOperation() != null) && TypeUtils.isNumericType(fromType)) {
     if (needsConversion(fromType, toType)
         && CommonUtilities.proceedWithConversion(ctx, arg.getConversionOperation())) {
       out.print(ctx.getNativeImplementationMapping(toType) + '.');
       out.print(CommonUtilities.getOpName(ctx, arg.getConversionOperation()));
       out.print("(");
       Expression objectExpr = arg.getObjectExpr();
       if (objectExpr instanceof BoxingExpression) {
         objectExpr = ((BoxingExpression) objectExpr).getExpr();
       }
       ctx.invoke(genExpression, objectExpr, ctx, out);
       ctx.invoke(genTypeDependentOptions, arg.getEType(), ctx, out, arg);
       out.print(")");
     } else {
       ctx.invoke(genExpression, arg.getObjectExpr(), ctx, out);
     }
   } else {
     // we need to invoke the logic in type template to call back to the other conversion
     // situations
     ctx.invokeSuper(this, genConversionOperation, type, ctx, out, arg);
   }
 }