1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
16 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
19 public class DoubleLiteral extends NumberLiteral {
21 public DoubleLiteral(char[] token, int s, int e) {
24 public void computeConstant() {
26 //the source is correctly formated so the exception should never occurs
29 try { computedValue = Double.valueOf(String.valueOf(source));}
30 catch(NumberFormatException e){return ;} //how can it happen ????
32 if (computedValue.doubleValue() > Double.MAX_VALUE) return ; //may be Infinity
33 if (computedValue.doubleValue() < Double.MIN_VALUE)
34 { //only a true 0 can be made of zeros
35 //2.00000000000000000e-324 is illegal ....
37 for (int i=0;i<source.length;i++)
38 { //it is welled formated so just test against '0' and potential . D d
45 case 'E' : break label ; //exposant are valid....!
46 default : return;}}} //error
48 constant = Constant.fromValue(value = computedValue.doubleValue());}
50 * Code generation for the double literak
52 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
53 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
54 * @param valueRequired boolean
56 //public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
57 // int pc = codeStream.position;
59 // if ((implicitConversion >> 4) == T_double)
60 // codeStream.generateInlinedValue(value);
62 // codeStream.generateConstant(constant, implicitConversion);
63 // codeStream.recordPositionsFrom(pc, this.sourceStart);
65 public TypeBinding literalType(BlockScope scope) {
68 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope blockScope) {
69 visitor.visit(this, blockScope);
70 visitor.endVisit(this, blockScope);