Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 117297 Details for
Bug 253690
[scalability] Parser needs a lot of memory parsing large initializer expressions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
further optimization for CDT 6.0
253690-3.txt (text/plain), 18.33 KB, created by
Markus Schorn
on 2008-11-07 04:55:20 EST
(
hide
)
Description:
further optimization for CDT 6.0
Filename:
MIME Type:
Creator:
Markus Schorn
Created:
2008-11-07 04:55:20 EST
Size:
18.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.core >Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java,v >retrieving revision 1.11 >diff -u -r1.11 CPPASTLiteralExpression.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java 15 Oct 2008 10:28:02 -0000 1.11 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTLiteralExpression.java 7 Nov 2008 09:53:50 -0000 >@@ -13,6 +13,7 @@ > import org.eclipse.cdt.core.dom.ast.ASTVisitor; > import org.eclipse.cdt.core.dom.ast.IType; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; >+import org.eclipse.cdt.core.parser.util.CharArrayUtils; > import org.eclipse.cdt.internal.core.dom.parser.ASTNode; > import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; > >@@ -23,13 +24,12 @@ > public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralExpression { > > private int kind; >- private String value = ""; //$NON-NLS-1$ >+ private char[] value = CharArrayUtils.EMPTY; > >- > public CPPASTLiteralExpression() { > } > >- public CPPASTLiteralExpression(int kind, String value) { >+ public CPPASTLiteralExpression(int kind, char[] value) { > this.kind = kind; > this.value = value; > } >@@ -39,16 +39,20 @@ > } > > public void setKind(int value) { >- this.kind = value; >+ kind = value; > } > >- public void setValue(String value) { >- this.value = value; >+ public char[] getValue() { >+ return value; >+ } >+ >+ public void setValue(char[] value) { >+ this.value= value; > } > > @Override > public String toString() { >- return value; >+ return new String(value); > } > > @Override >@@ -74,4 +78,20 @@ > return CPPVisitor.getExpressionType(this); > } > >+ /** >+ * @deprecated, use {@link #setValue(char[])}, instead. >+ */ >+ @Deprecated >+ public void setValue(String value) { >+ this.value = value.toCharArray(); >+ } >+ >+ >+ /** >+ * @deprecated use {@link #CPPASTLiteralExpression(int, char[])}, instead. >+ */ >+ @Deprecated >+ public CPPASTLiteralExpression(int kind, String value) { >+ this(kind, value.toCharArray()); >+ } > } >Index: parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java,v >retrieving revision 1.3 >diff -u -r1.3 ICPPASTLiteralExpression.java >--- parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java 23 Jun 2005 16:02:11 -0000 1.3 >+++ parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTLiteralExpression.java 7 Nov 2008 09:53:50 -0000 >@@ -1,12 +1,12 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * Copyright (c) 2004, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM - Initial API and implementation >+ * John Camelon (IBM) - Initial API and implementation > *******************************************************************************/ > package org.eclipse.cdt.core.dom.ast.cpp; > >@@ -15,24 +15,24 @@ > /** > * C++ adds additional literal types to primary expression. > * >- * @author jcamelon >+ * @noimplement This interface is not intended to be implemented by clients. > */ > public interface ICPPASTLiteralExpression extends IASTLiteralExpression { > > /** > * <code>lk_this</code> represents the 'this' keyword. > */ >- public static final int lk_this = IASTLiteralExpression.lk_last + 1; >+ public static final int lk_this = IASTLiteralExpression.lk_this; > > /** > * <code>lk_true</code> represents the 'true' keyword. > */ >- public static final int lk_true = IASTLiteralExpression.lk_last + 2; >+ public static final int lk_true = IASTLiteralExpression.lk_true; > > /** > * <code>lk_false</code> represents the 'false' keyword. > */ >- public static final int lk_false = IASTLiteralExpression.lk_last + 3; >+ public static final int lk_false = IASTLiteralExpression.lk_false; > > /** > * <code>lk_last</code> is maintained for future subinterfaces. >Index: parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java,v >retrieving revision 1.6 >diff -u -r1.6 IASTLiteralExpression.java >--- parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java 23 Jun 2005 16:02:12 -0000 1.6 >+++ parser/org/eclipse/cdt/core/dom/ast/IASTLiteralExpression.java 7 Nov 2008 09:53:50 -0000 >@@ -1,19 +1,20 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2005 IBM Corporation and others. >+ * Copyright (c) 2004, 2008 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM - Initial API and implementation >+ * Doug Schaefer (IBM) - Initial API and implementation >+ * Markus Schorn (Wind River Systems) > *******************************************************************************/ > package org.eclipse.cdt.core.dom.ast; > > /** > * This expression represents a literal in the program. > * >- * @author Doug Schaefer >+ * @noimplement This interface is not intended to be implemented by clients. > */ > public interface IASTLiteralExpression extends IASTExpression { > >@@ -28,39 +29,70 @@ > public static final int lk_float_constant = 1; > > /** >- * A char literal e.g. 'abc' >+ * A char literal e.g. 'a' > */ > public static final int lk_char_constant = 2; > > /** >- * A string literal e.g. "abcdefg" >+ * A string literal e.g. "a literal" > */ > public static final int lk_string_literal = 3; > > /** > * A constant defined for subclasses to extend from. >+ * @deprecated all possible values must be defined in {@link IASTLiteralExpression}. > */ >+ @Deprecated > public static final int lk_last = lk_string_literal; > > /** >+ * <code>lk_this</code> represents the 'this' keyword for c++ only. >+ * @since 5.1 >+ */ >+ public static final int lk_this = 4; >+ >+ /** >+ * <code>lk_true</code> represents the 'true' keyword. >+ * @since 5.1 >+ */ >+ public static final int lk_true = 5; >+ >+ /** >+ * <code>lk_false</code> represents the 'false' keyword. >+ * @since 5.1 >+ */ >+ public static final int lk_false = 6; >+ >+ /** > * Get the literal expression kind. >- * >- * @return int > */ > public int getKind(); > > /** >+ * Returns the value of the literal as char-array. >+ * @since 5.1 >+ */ >+ public char[] getValue(); >+ >+ /** >+ * Returns the value of the literal as string. >+ * @since 5.1 >+ */ >+ public String toString(); >+ >+ /** > * Set the literal expression kind. >- * >- * @param value >- * int > */ > public void setKind(int value); > > /** >- * Set the value of the literal expression. >- * >- * @param value >+ * Provide the value for the expression. >+ * @since 5.1 >+ */ >+ public void setValue(char[] value); >+ >+ /** >+ * @deprecated, use {@link #setValue(char[])}, instead. > */ > public void setValue(String value); > >Index: parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java,v >retrieving revision 1.11 >diff -u -r1.11 CASTLiteralExpression.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java 15 Oct 2008 10:28:01 -0000 1.11 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTLiteralExpression.java 7 Nov 2008 09:53:50 -0000 >@@ -6,30 +6,30 @@ > * http://www.eclipse.org/legal/epl-v10.html > * > * Contributors: >- * IBM Rational Software - Initial API and implementation >- * Yuan Zhang / Beth Tibbitts (IBM Research) >+ * John Camelon (IBM Rational Software) - Initial API and implementation >+ * Yuan Zhang / Beth Tibbitts (IBM Research) >+ * Markus Schorn (Wind River Systems) > *******************************************************************************/ > package org.eclipse.cdt.internal.core.dom.parser.c; > > import org.eclipse.cdt.core.dom.ast.ASTVisitor; > import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression; > import org.eclipse.cdt.core.dom.ast.IType; >+import org.eclipse.cdt.core.parser.util.CharArrayUtils; > import org.eclipse.cdt.internal.core.dom.parser.ASTNode; > > /** >- * @author jcamelon >+ * Represents a literal > */ > public class CASTLiteralExpression extends ASTNode implements IASTLiteralExpression { > > private int kind; >- private String value = ""; //$NON-NLS-1$ >+ private char[] value = CharArrayUtils.EMPTY; > >- >- > public CASTLiteralExpression() { > } > >- public CASTLiteralExpression(int kind, String value) { >+ public CASTLiteralExpression(int kind, char[] value) { > this.kind = kind; > this.value = value; > } >@@ -42,13 +42,17 @@ > kind = value; > } > >- public void setValue(String value) { >- this.value = value; >+ public char[] getValue() { >+ return value; >+ } >+ >+ public void setValue(char[] value) { >+ this.value= value; > } > > @Override > public String toString() { >- return value; >+ return new String(value); > } > > @Override >@@ -74,4 +78,19 @@ > return CVisitor.getExpressionType(this); > } > >+ /** >+ * @deprecated, use {@link #setValue(char[])}, instead. >+ */ >+ @Deprecated >+ public void setValue(String value) { >+ this.value = value.toCharArray(); >+ } >+ >+ /** >+ * @deprecated use {@link #CASTLiteralExpression(int, char[])}, instead. >+ */ >+ @Deprecated >+ public CASTLiteralExpression(int kind, String value) { >+ this(kind, value.toCharArray()); >+ } > } >Index: parser/org/eclipse/cdt/internal/core/dom/parser/Value.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java,v >retrieving revision 1.6 >diff -u -r1.6 Value.java >--- parser/org/eclipse/cdt/internal/core/dom/parser/Value.java 4 Nov 2008 08:55:42 -0000 1.6 >+++ parser/org/eclipse/cdt/internal/core/dom/parser/Value.java 7 Nov 2008 09:53:50 -0000 >@@ -24,7 +24,6 @@ > import org.eclipse.cdt.core.dom.ast.IEnumerator; > import org.eclipse.cdt.core.dom.ast.IValue; > import org.eclipse.cdt.core.dom.ast.IVariable; >-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; >@@ -229,19 +228,19 @@ > if (e instanceof IASTLiteralExpression) { > IASTLiteralExpression litEx= (IASTLiteralExpression) e; > switch (litEx.getKind()) { >- case ICPPASTLiteralExpression.lk_false: >+ case IASTLiteralExpression.lk_false: > return "0"; >- case ICPPASTLiteralExpression.lk_true: >+ case IASTLiteralExpression.lk_true: > return "1"; > case IASTLiteralExpression.lk_integer_constant: > try { >- return ExpressionEvaluator.getNumber(e.toString().toCharArray()); >+ return ExpressionEvaluator.getNumber(litEx.getValue()); > } catch (EvalException e1) { > throw UNKNOWN_EX; > } > case IASTLiteralExpression.lk_char_constant: > try { >- final char[] image= e.toString().toCharArray(); >+ final char[] image= litEx.getValue(); > if (image.length > 1) > if (image[0] == 'L') > return ExpressionEvaluator.getChar(image, 2); >#P org.eclipse.cdt.ui >Index: src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java,v >retrieving revision 1.5 >diff -u -r1.5 ExtractExpression.java >--- src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java 1 Oct 2008 10:32:17 -0000 1.5 >+++ src/org/eclipse/cdt/internal/ui/refactoring/extractfunction/ExtractExpression.java 7 Nov 2008 09:53:54 -0000 >@@ -29,7 +29,6 @@ > import org.eclipse.cdt.core.dom.ast.IBinding; > import org.eclipse.cdt.core.dom.ast.IType; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression; >-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; >@@ -61,13 +60,14 @@ > * > */ > public class ExtractExpression extends ExtractedFunctionConstructionHelper { >+ final static char[] ZERO= {'0'}; > > @Override > public void constructMethodBody(IASTCompoundStatement compound, > List<IASTNode> list, ASTRewrite rewrite, TextEditGroup group) { > > CPPASTReturnStatement statement = new CPPASTReturnStatement(); >- IASTExpression nullReturnExp = new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, "0"); //$NON-NLS-1$ >+ IASTExpression nullReturnExp = new CPPASTLiteralExpression(IASTLiteralExpression.lk_integer_constant, ZERO); > statement.setReturnValue(nullReturnExp); > ASTRewrite nestedRewrite = rewrite.insertBefore(compound, null, statement, group); > >@@ -112,9 +112,9 @@ > return createSimpleDeclSpecifier(IASTSimpleDeclSpecifier.t_int); > case IASTLiteralExpression.lk_string_literal: > return createSimpleDeclSpecifier(ICPPASTSimpleDeclSpecifier.t_wchar_t); >- case ICPPASTLiteralExpression.lk_false: >+ case IASTLiteralExpression.lk_false: > //Like lk_true a boolean type >- case ICPPASTLiteralExpression.lk_true: >+ case IASTLiteralExpression.lk_true: > return createSimpleDeclSpecifier(ICPPASTSimpleDeclSpecifier.t_bool); > default: > return null; >Index: src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java,v >retrieving revision 1.11 >diff -u -r1.11 ExtractConstantRefactoring.java >--- src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java 10 Sep 2008 14:36:21 -0000 1.11 >+++ src/org/eclipse/cdt/internal/ui/refactoring/extractconstant/ExtractConstantRefactoring.java 7 Nov 2008 09:53:54 -0000 >@@ -43,7 +43,6 @@ > import org.eclipse.cdt.core.dom.ast.IBinding; > import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; >-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTLiteralExpression; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; > import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier; > import org.eclipse.cdt.core.dom.rewrite.ASTRewrite; >@@ -328,12 +327,12 @@ > case IASTLiteralExpression.lk_string_literal: > declSpec.setType(ICPPASTSimpleDeclSpecifier.t_wchar_t); > break; >- case ICPPASTLiteralExpression.lk_false: >+ case IASTLiteralExpression.lk_false: > //Like lk_true a boolean type >- case ICPPASTLiteralExpression.lk_true: >+ case IASTLiteralExpression.lk_true: > declSpec.setType(ICPPASTSimpleDeclSpecifier.t_bool); > break; >- case ICPPASTLiteralExpression.lk_this: >+ case IASTLiteralExpression.lk_this: > break; > } > >@@ -348,7 +347,7 @@ > IASTUnaryExpression unary = (IASTUnaryExpression) target.getParent(); > init.setExpression(unary); > } else { >- CPPASTLiteralExpression expression = new CPPASTLiteralExpression(target.getKind(), target.toString()); >+ CPPASTLiteralExpression expression = new CPPASTLiteralExpression(target.getKind(), target.getValue()); > init.setExpression(expression); > } > decl.setInitializer(init); >Index: src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java,v >retrieving revision 1.2 >diff -u -r1.2 FunctionFactory.java >--- src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java 15 May 2008 14:31:07 -0000 1.2 >+++ src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FunctionFactory.java 7 Nov 2008 09:53:54 -0000 >@@ -16,6 +16,7 @@ > import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; > import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; > import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; >+import org.eclipse.cdt.core.parser.Keywords; > > import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression; > import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement; >@@ -89,7 +90,7 @@ > CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression(); > CPPASTFieldReference fieldRef = new CPPASTFieldReference(); > CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression(); >- litExpr.setValue("this"); //$NON-NLS-1$ >+ litExpr.setValue(Keywords.cTHIS); > fieldRef.setFieldOwner(litExpr); > fieldRef.setFieldName(fieldDeclaration.getDeclarators()[0].getName()); > fieldRef.setIsPointerDereference(true);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253690
:
116932
|
117176
|
117193
|
117194
|
117293
| 117297 |
117439