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 FloatLiteral extends NumberLiteral {
21 final static float Float_MIN_VALUE = Float.intBitsToFloat(1); // work-around
26 public FloatLiteral(char[] token, int s, int e) {
30 public void computeConstant() {
32 // the source is correctly formated so the exception should never occurs
36 computedValue = Float.valueOf(String.valueOf(source));
37 } catch (NumberFormatException e) {
41 if (computedValue.doubleValue() > Float.MAX_VALUE) {
42 return; // may be Infinity
44 if (computedValue.floatValue() < Float_MIN_VALUE) {
46 // only a true 0 can be made of zeros
47 // 1.00000000e-46f is illegal ....
48 label: for (int i = 0; i < source.length; i++) {
57 break label; // exposant are valid !....
64 constant = Constant.fromValue(value = computedValue.floatValue());
68 * Code generation for float literal
71 * net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
73 * net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
74 * @param valueRequired
77 // public void generateCode(BlockScope currentScope, CodeStream codeStream,
78 // boolean valueRequired) {
79 // int pc = codeStream.position;
81 // if ((implicitConversion >> 4) == T_float)
82 // codeStream.generateInlinedValue(value);
84 // codeStream.generateConstant(constant, implicitConversion);
85 // codeStream.recordPositionsFrom(pc, this.sourceStart);
87 public TypeBinding literalType(BlockScope scope) {
91 public void traverse(IAbstractSyntaxTreeVisitor visitor,
92 BlockScope blockScope) {
93 visitor.visit(this, blockScope);
94 visitor.endVisit(this, blockScope);