X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java index 85bf3c3..436c102 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StringLiteral.java @@ -1,105 +1,115 @@ /******************************************************************************* * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v05.html - * + * * Contributors: * IBM Corporation - initial API and implementation ******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; -import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream; -import net.sourceforge.phpdt.internal.compiler.impl.Constant; -import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; -import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding; +import java.util.List; +import java.util.ArrayList; + +//import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; +//import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream; +//import net.sourceforge.phpdt.internal.compiler.impl.Constant; +//import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; +//import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding; public class StringLiteral extends Literal { - char[] source; + char[] source; -public StringLiteral(char[] token, int s, int e) { - this(s,e); - source = token; -} -public StringLiteral(int s, int e) { - super(s,e); -} -public void computeConstant() { + public StringLiteral(final char[] token, final int s) { + super(s, s + token.length); + source = token; + } - constant = Constant.fromValue(String.valueOf(source));} -public ExtendedStringLiteral extendWith(CharLiteral lit){ - //add the lit source to mine, just as if it was mine + /** + * Create a new StringLiteral + * @param token the token + * @param s sourcestart + * @param e sourceend + * @deprecated + */ + public StringLiteral(final char[] token, final int s, final int e) { + super(s, e); + source = token; + } - return new ExtendedStringLiteral(this,lit); -} -public ExtendedStringLiteral extendWith(StringLiteral lit){ - //add the lit source to mine, just as if it was mine + public StringLiteral(final int s, final int e) { + super(s, e); + } - return new ExtendedStringLiteral(this,lit); -} -/** - * Code generation for string literal - * - * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope - * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream - * @param valueRequired boolean - */ -public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { - int pc = codeStream.position; - if (valueRequired) - codeStream.ldc(constant.stringValue()); - codeStream.recordPositionsFrom(pc, this.sourceStart); -} -public TypeBinding literalType(BlockScope scope) { - return scope.getJavaLangString(); -} -/** - * source method comment. - */ -public char[] source() { - return source; -} -public String toStringExpression() { + /** + * source method comment. + */ + public char[] source() { + return source; + } - // handle some special char..... - StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$ - for (int i = 0; i < source.length; i++) { - switch (source[i]) { - case '\b' : - result.append("\\b"); //$NON-NLS-1$ - break; - case '\t' : - result.append("\\t"); //$NON-NLS-1$ - break; - case '\n' : - result.append("\\n"); //$NON-NLS-1$ - break; - case '\f' : - result.append("\\f"); //$NON-NLS-1$ - break; - case '\r' : - result.append("\\r"); //$NON-NLS-1$ - break; - case '\"' : - result.append("\\\""); //$NON-NLS-1$ - break; - case '\'' : - result.append("\\'"); //$NON-NLS-1$ - break; - case '\\' : //take care not to display the escape as a potential real char - result.append("\\\\"); //$NON-NLS-1$ - break; - default : - result.append(source[i]); - } - } - result.append("\""); //$NON-NLS-1$ - return result.toString(); -} -public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) { - visitor.visit(this, scope); - visitor.endVisit(this, scope); -} + /** + * Return the expression as String. + * @return the expression + */ + /* public String toStringExpression() { + // handle some special char..... + StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$ + for (int i = 0; i < source.length; i++) { + switch (source[i]) { + case '\b': + result.append("\\b"); //$NON-NLS-1$ + break; + case '\t': + result.append("\\t"); //$NON-NLS-1$ + break; + case '\n': + result.append("\\n"); //$NON-NLS-1$ + break; + case '\f': + result.append("\\f"); //$NON-NLS-1$ + break; + case '\r': + result.append("\\r"); //$NON-NLS-1$ + break; + case '\"': + result.append("\\\""); //$NON-NLS-1$ + break; + case '\'': + result.append("\\'"); //$NON-NLS-1$ + break; + case '\\': //take care not to display the escape as a potential real char + result.append("\\\\"); //$NON-NLS-1$ + break; + default : + result.append(source[i]); + } + } + result.append("\""); //$NON-NLS-1$ + return result.toString(); + } */ + + /** + * Return the expression as String. + * @return the expression + */ + public String toStringExpression() { + return new String(source); + } + + /** + * @deprecated - use field instead + */ + public int sourceEnd() { + return getSourceEnd(); + } + + /** + * @deprecated - use field instead + */ + public int sourceStart() { + return getSourceStart(); + } }