KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > Literal


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.flow.FlowContext;
14 import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
15 import org.eclipse.jdt.internal.compiler.impl.*;
16 import org.eclipse.jdt.internal.compiler.lookup.*;
17
18 public abstract class Literal extends Expression {
19
20     public Literal(int s, int e) {
21
22         sourceStart = s;
23         sourceEnd = e;
24     }
25
26     public FlowInfo analyseCode(
27         BlockScope currentScope,
28         FlowContext flowContext,
29         FlowInfo flowInfo) {
30             
31         return flowInfo;
32     }
33
34     public abstract void computeConstant();
35
36     public abstract TypeBinding literalType(BlockScope scope);
37
38     public StringBuffer JavaDoc printExpression(int indent, StringBuffer JavaDoc output){
39     
40         return output.append(source());
41      }
42      
43     public TypeBinding resolveType(BlockScope scope) {
44         // compute the real value, which must range its type's range
45
this.resolvedType = literalType(scope);
46
47         // in case of error, constant did remain null
48
computeConstant();
49         if (constant == null) {
50             scope.problemReporter().constantOutOfRange(this, this.resolvedType);
51             constant = Constant.NotAConstant;
52         }
53         return this.resolvedType;
54     }
55
56     public abstract char[] source();
57 }
58
Popular Tags