01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
11:
12: import org.eclipse.jdt.internal.compiler.flow.FlowContext;
13: import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
14: import org.eclipse.jdt.internal.compiler.impl.*;
15: import org.eclipse.jdt.internal.compiler.lookup.*;
16:
17: public abstract class Literal extends Expression {
18:
19: public Literal(int s, int e) {
20:
21: sourceStart = s;
22: sourceEnd = e;
23: }
24:
25: public FlowInfo analyseCode(BlockScope currentScope,
26: FlowContext flowContext, FlowInfo flowInfo) {
27:
28: return flowInfo;
29: }
30:
31: public abstract void computeConstant();
32:
33: public abstract TypeBinding literalType(BlockScope scope);
34:
35: public StringBuffer printExpression(int indent, StringBuffer output) {
36:
37: return output.append(source());
38: }
39:
40: public TypeBinding resolveType(BlockScope scope) {
41: // compute the real value, which must range its type's range
42: this .resolvedType = literalType(scope);
43:
44: // in case of error, constant did remain null
45: computeConstant();
46: if (constant == null) {
47: scope.problemReporter().constantOutOfRange(this ,
48: this .resolvedType);
49: constant = Constant.NotAConstant;
50: }
51: return this .resolvedType;
52: }
53:
54: public abstract char[] source();
55: }
|