1. Fix #1589403 - wrap double/single quoted strings
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Literal.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
14 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
15 import net.sourceforge.phpdt.internal.compiler.impl.Constant;
16 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
18
19 public abstract class Literal extends Expression {
20
21         public Literal(int s, int e) {
22                 sourceStart = s;
23                 sourceEnd = e;
24         }
25
26         public FlowInfo analyseCode(BlockScope currentScope,
27                         FlowContext flowContext, FlowInfo flowInfo) {
28                 return flowInfo;
29         }
30
31         public abstract void computeConstant();
32
33         // ON ERROR constant STAYS NULL
34         public abstract TypeBinding literalType(BlockScope scope);
35
36         public StringBuffer printExpression(int indent, StringBuffer output) {
37
38                 return output.append(source());
39         }
40
41         public TypeBinding resolveType(BlockScope scope) {
42                 // compute the real value, which must range its type's range
43
44                 computeConstant();
45                 if (constant == null) {
46                         scope.problemReporter().constantOutOfRange(this);
47                         constant = Constant.NotAConstant;
48                         return null;
49                 }
50                 this.resolvedType = literalType(scope);
51                 return this.resolvedType;
52         }
53
54         public abstract char[] source();
55 }