001 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 002 // for details. All rights reserved. Use of this source code is governed by a 003 // BSD-style license that can be found in the LICENSE file. 004 005 package com.google.dart.compiler.backend.js.ast; 006 007 public abstract class JsNumberLiteral extends JsLiteral.JsValueLiteral { 008 public static final JsIntLiteral ZERO = new JsIntLiteral(0); 009 010 public static final class JsDoubleLiteral extends JsNumberLiteral { 011 public final double value; 012 013 JsDoubleLiteral(double value) { 014 this.value = value; 015 } 016 017 @Override 018 public void accept(JsVisitor v) { 019 v.visitDouble(this); 020 } 021 022 public String toString() { 023 return String.valueOf(value); 024 } 025 026 @Override 027 public void traverse(JsVisitorWithContext v, JsContext ctx) { 028 v.visit(this, ctx); 029 v.endVisit(this, ctx); 030 } 031 } 032 033 public static final class JsIntLiteral extends JsNumberLiteral { 034 public final int value; 035 036 JsIntLiteral(int value) { 037 this.value = value; 038 } 039 040 @Override 041 public void accept(JsVisitor v) { 042 v.visitInt(this); 043 } 044 045 public String toString() { 046 return String.valueOf(value); 047 } 048 049 @Override 050 public void traverse(JsVisitorWithContext v, JsContext ctx) { 051 v.visit(this, ctx); 052 v.endVisit(this, ctx); 053 } 054 } 055 }