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.phpdt.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;
18 public class DoubleLiteral extends NumberLiteral {
21 public DoubleLiteral(char[] token, int s, int e) {
25 public void computeConstant() {
27 // the source is correctly formated so the exception should never occurs
31 computedValue = Double.valueOf(String.valueOf(source));
32 } catch (NumberFormatException e) {
34 } // how can it happen ????
36 if (computedValue.doubleValue() > Double.MAX_VALUE)
37 return; // may be Infinity
38 if (computedValue.doubleValue() < Double.MIN_VALUE) { // only a true 0
41 // 2.00000000000000000e-324 is illegal ....
42 label: for (int i = 0; i < source.length; i++) { // it is welled
56 break label; // exposant are valid....!
63 constant = Constant.fromValue(value = computedValue.doubleValue());
67 * Code generation for the double literak
70 * net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
72 * net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
73 * @param valueRequired
76 // public void generateCode(BlockScope currentScope, CodeStream codeStream,
77 // boolean valueRequired) {
78 // int pc = codeStream.position;
80 // if ((implicitConversion >> 4) == T_double)
81 // codeStream.generateInlinedValue(value);
83 // codeStream.generateConstant(constant, implicitConversion);
84 // codeStream.recordPositionsFrom(pc, this.sourceStart);
86 public TypeBinding literalType(BlockScope scope) {
90 public void traverse(IAbstractSyntaxTreeVisitor visitor,
91 BlockScope blockScope) {
92 visitor.visit(this, blockScope);
93 visitor.endVisit(this, blockScope);