Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-patch] More performance modifications to the Scanner


Here is the patch without the complete delete and re-add of the Changelog....  (The patch seemed a lot larger than I expected).

        - Dave





David Daoust/Ottawa/IBM@IBMCA
Sent by: cdt-patch-admin@xxxxxxxxxxx

04/13/2004 08:48 PM

Please respond to
cdt-patch

To
cdt-patch@xxxxxxxxxxx
cc
Subject
[cdt-patch] More performance modifications to the Scanner






Here is a patch to reduce the number of objects created by the scanner and speed up the overall operation..


On my test of #include <windows.h> the object count dropped from


       total bytes         objs                time(ms)

orig        59905960        1455079        1593        

new        40868312         950355        1322


       - Dave

[attachment "scannerSpeedUp.txt" deleted by David Daoust/Ottawa/IBM]

Index: parser/ChangeLog-parser
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog-parser,v
retrieving revision 1.116
diff -u -r1.116 ChangeLog-parser
--- parser/ChangeLog-parser	13 Apr 2004 15:31:15 -0000	1.116
+++ parser/ChangeLog-parser	14 Apr 2004 10:48:45 -0000
@@ -1,3 +1,15 @@
+2004-04-13 David Daoust
+	Modified Scanner Performance by 
+		1. Moving ScannerContext sentinal to ContextStack
+		2. Delay Stringizing macro parameter until needed
+		
+		Effect on #include <windows.h>
+		
+						total bytes	 objs	time(ms)tokens
+	orig				59905960	1455079	1593	83812
+	move sentinel		53824616	1262428	1462	83812
+	delay stringizing	40868312	950355	1322	83812
+
 2004-04-13 Andrew Niefer
 	fixed https://bugs.eclipse.org/bugs/show_bug.cgi?id=46246
 	modified symbol table sorting to use a collator instead of String.compare()
Index: parser/org/eclipse/cdt/core/parser/IScanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java,v
retrieving revision 1.22
diff -u -r1.22 IScanner.java
--- parser/org/eclipse/cdt/core/parser/IScanner.java	3 Mar 2004 15:59:51 -0000	1.22
+++ parser/org/eclipse/cdt/core/parser/IScanner.java	14 Apr 2004 10:48:45 -0000
@@ -3,6 +3,7 @@
 import java.util.Map;
 
 import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.scanner.IScannerContext;
 
 /**
  * @author jcamelon
@@ -48,5 +49,6 @@
 	 * @return
 	 */
 	public boolean isOnTopContext();
+	public void setScannerContext(IScannerContext context);
 
 }
Index: parser/org/eclipse/cdt/internal/core/parser/scanner/ContextStack.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ContextStack.java,v
retrieving revision 1.6
diff -u -r1.6 ContextStack.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner/ContextStack.java	6 Apr 2004 21:31:15 -0000	1.6
+++ parser/org/eclipse/cdt/internal/core/parser/scanner/ContextStack.java	14 Apr 2004 10:48:50 -0000
@@ -13,16 +13,12 @@
 
 import java.io.IOException;
 import java.io.Reader;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.Stack;
 
 import org.eclipse.cdt.core.parser.IParserLogService;
 import org.eclipse.cdt.core.parser.IProblem;
+import org.eclipse.cdt.core.parser.IScanner;
 import org.eclipse.cdt.core.parser.ISourceElementRequestor;
 import org.eclipse.cdt.core.parser.ast.IASTInclusion;
-import org.eclipse.cdt.internal.core.parser.scanner.IScannerContext.ContextKind;
 import org.eclipse.cdt.internal.core.parser.util.TraceUtil;
 
 /**
@@ -33,34 +29,84 @@
  */
 public class ContextStack {
 
+	private static class SentinelContext implements IScannerContext {
+		public int read() throws IOException { return '\n'; }
+		public String getFilename() { return ""; }
+		public int getMacroOffset() { return -1; }
+		public int getMacroLength() { return -1; }
+		public int getOffset() { return 0; }
+		public int getRelativeOffset() { return 0; }
+		public Reader getReader() { return null; }
+		public void pushUndo(int undo) { }
+		public int getKind() { return IScannerContext.ContextKind.SENTINEL; }
+		public void setKind(int kind) { }
+		public IASTInclusion getExtension() { return null; }
+		public void setExtension(IASTInclusion ext) { }
+		public int getLine() { return -1; }
+		public int undoStackSize() { return 0; }  
+		public int popUndo() { return '\n'; }
+	}
 	private final IParserLogService log;
-	private Scanner scanner;
+	private int current_size = 12;
+
+	private IScannerContext [] cs = new IScannerContext[current_size];;
+	private int cs_pos = 0;
+	
+	
+	private static IScannerContext sentinel = new SentinelContext();
+	 
+	private IScanner scanner;
+
+	private final void cs_push(IScannerContext c) {
+		try {
+			cs[cs_pos++] = c;;
+		}
+		catch (ArrayIndexOutOfBoundsException a)
+		{
+			int new_size = current_size*2;
+			IScannerContext [] new_cs = new IScannerContext[new_size];
+			
+			for (int i = 0; i < current_size; i++) {
+				new_cs[i] = cs[i];
+			}
+			
+			new_cs[current_size] = c;
+			current_size = new_size;
+			cs = new_cs;
+		}
+		scanner.setScannerContext(c);
+	}
+	private final IScannerContext cs_pop() {
+		IScannerContext context = cs[--cs_pos];
+		scanner.setScannerContext((cs_pos == 0) ? sentinel : cs[cs_pos -1]);
+		return context;
+	}
 	
-	public ContextStack( Scanner s, IParserLogService l ) {
-		scanner = s;
+	public ContextStack( IScanner scanner, IParserLogService l ) {
 		log = l;
+		this.scanner = scanner;
+		scanner.setScannerContext(sentinel);
 	}
 
-    public void updateContext(Reader reader, String filename, ContextKind type, IASTInclusion inclusion, ISourceElementRequestor requestor) throws ContextException {
+    public void updateContext(Reader reader, String filename, int type, IASTInclusion inclusion, ISourceElementRequestor requestor) throws ContextException {
         updateContext(reader, filename, type, inclusion, requestor, -1, -1);
     }
   
-	public void updateContext(Reader reader, String filename, ContextKind type, IASTInclusion inclusion, ISourceElementRequestor requestor, int macroOffset, int macroLength) throws ContextException 
+	public void updateContext(Reader reader, String filename, int type, IASTInclusion inclusion, ISourceElementRequestor requestor, int macroOffset, int macroLength) throws ContextException 
     {
 		int startLine = 1;
 		
         // If we expand a macro within a macro, then keep offsets of the top-level one,
         // as only the top level macro identifier is properly positioned    
         if (type == IScannerContext.ContextKind.MACROEXPANSION) {
-            if (currentContext.getKind() == IScannerContext.ContextKind.MACROEXPANSION) {
-                macroOffset = currentContext.getMacroOffset();
-                macroLength = currentContext.getMacroLength();
+            if (getCurrentContext().getKind() == IScannerContext.ContextKind.MACROEXPANSION) {
+                macroOffset = getCurrentContext().getMacroOffset();
+                macroLength = getCurrentContext().getMacroLength();
             }
             
-			startLine = currentContext.getLine();
+			startLine = getCurrentContext().getLine();
         }
 
-		undoStack.clear();
 		IScannerContext context = new ScannerContext( reader, filename, type, null, macroOffset, macroLength, startLine );
 		context.setExtension(inclusion); 
 		push( context, requestor );	
@@ -68,70 +114,42 @@
 	
 	protected void push( IScannerContext context, ISourceElementRequestor requestor ) throws ContextException
 	{
-		if( context.getKind() == IScannerContext.ContextKind.INCLUSION )
-		{
-			if( !inclusions.add( context.getFilename() ) )
+		if( context.getKind() == IScannerContext.ContextKind.INCLUSION ) {
+			if( isCircularInclusion( context.getFilename() ) )
 				throw new ContextException( IProblem.PREPROCESSOR_CIRCULAR_INCLUSION );
 			
 			TraceUtil.outputTrace(log, "Scanner::ContextStack: entering inclusion ", null, context.getFilename(), null, null ); //$NON-NLS-1$
 			context.getExtension().enterScope( requestor );				
-
-		} else if( context.getKind() == IScannerContext.ContextKind.MACROEXPANSION )
-		{
-			if( !defines.add( context.getFilename() ) )
-				throw new ContextException( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN );
-		}
-		if( currentContext != null )
-			contextStack.push(currentContext);
-		
-		currentContext = context;
-		if( context.getKind() == IScannerContext.ContextKind.TOP )
-			topContext = context;
+		} 
+//		else if( context.getKind() == IScannerContext.ContextKind.MACROEXPANSION )
+//		{
+//			if( !defines.add( context.getFilename() ) )
+//				throw new ContextException( IProblem.PREPROCESSOR_INVALID_MACRO_DEFN );
+//		}
+		cs_push(context);
 	}
 	
 	public boolean rollbackContext(ISourceElementRequestor requestor) {
+		IScannerContext context = getCurrentContext();
 		try {
-			currentContext.getReader().close();
+			context.getReader().close();
 		} catch (IOException ie) {
 			TraceUtil.outputTrace( log, "ContextStack : Error closing reader "); //$NON-NLS-1$
 		}
 
-		if( currentContext.getKind() == IScannerContext.ContextKind.INCLUSION )
-		{
-			TraceUtil.outputTrace(log, "Scanner::ContextStack: ending inclusion ", null, currentContext.getFilename(), null, null); //$NON-NLS-1$
-			inclusions.remove( currentContext.getFilename() );
-			currentContext.getExtension().exitScope( requestor );
-		} else if( currentContext.getKind() == IScannerContext.ContextKind.MACROEXPANSION )
+		if( context.getKind() == IScannerContext.ContextKind.INCLUSION )
 		{
-			defines.remove( currentContext.getFilename() );
+			TraceUtil.outputTrace(log, "Scanner::ContextStack: ending inclusion ", null, context.getFilename(), null, null); //$NON-NLS-1$
+			context.getExtension().exitScope( requestor );
 		}
-		
-		undoStack.addFirst( currentContext );
-		
-		if (contextStack.isEmpty()) {
-			currentContext = null;
-			return false;
-		}
-
-		currentContext = (ScannerContext) contextStack.pop();
-		return true;
+		cs_pop();
+		return cs_pos != 0;
 	}
 	
-	public void undoRollback( IScannerContext undoTo, ISourceElementRequestor requestor ) throws ContextException {
-		if( currentContext == undoTo ){
-			return;
-		}
-		
-		int size = undoStack.size();
-		if( size > 0 )
-		{
-			for( int i = size; i > 0; i-- )
-			{
-				push( (IScannerContext) undoStack.removeFirst(), requestor );
-				
-				if( currentContext == undoTo )
-					break;
-			}	
+	public void undoRollback( IScannerContext undoTo, ISourceElementRequestor requestor ) {
+		while (getCurrentContext() != undoTo ) {
+			//cs_pos++;
+			scanner.setScannerContext(cs[cs_pos++]);
 		}
 	}
 	
@@ -147,58 +165,42 @@
 	 */
 	protected boolean shouldExpandDefinition( String symbol )
 	{
-		return !defines.contains( symbol );
+		for(int i = cs_pos-1; i >= 0; i--)
+			if (cs[i].getKind() == IScannerContext.ContextKind.MACROEXPANSION
+					&& cs[i].getFilename().equals(symbol))
+				return false;
+		return true;
 	}
 	
-	public IScannerContext getCurrentContext(){
-		return currentContext;
+	protected boolean isCircularInclusion( String symbol )
+	{
+		for(int i = cs_pos-1; i >= 0; i--)
+			if (cs[i].getKind() == IScannerContext.ContextKind.INCLUSION &&
+					cs[i].getFilename().equals(symbol))
+				return true;
+		return false;
 	}
 	
-	private IScannerContext currentContext, topContext;
-	private Stack contextStack = new Stack();
-	private LinkedList undoStack = new LinkedList();
-	private Set inclusions = new HashSet(); 
-	private Set defines = new HashSet();
-	
-	/**
-	 * @return
-	 */
-	public IScannerContext getTopContext() {
-		return topContext;
+	public final IScannerContext getCurrentContext(){
+		return (cs_pos == 0) ? sentinel : cs[cs_pos -1];
 	}
 
 	public IScannerContext getMostRelevantFileContext()
 	{
-		if( currentContext != null )
+		IScannerContext context = sentinel;
+		for( int i = cs_pos - 1; i > 0; --i )
 		{
-			if( currentContext.getKind() == IScannerContext.ContextKind.TOP ) return currentContext;
-			if( currentContext.getKind() == IScannerContext.ContextKind.INCLUSION ) return currentContext;
-		}
-				
-		IScannerContext context = null;
-		for( int i = contextStack.size() - 1; i >= 0; --i )
-		{
-			context = (IScannerContext)contextStack.get(i);
-			if( context.getKind() == IScannerContext.ContextKind.INCLUSION || context.getKind() == IScannerContext.ContextKind.TOP )
+			context = cs[i];
+			if( context.getKind() == IScannerContext.ContextKind.INCLUSION 
+					|| context.getKind() == IScannerContext.ContextKind.TOP )
 				break;
-			if( i == 0 ) context = null;
 		}
-		
 		return context;
 	}
 	
 	public int getCurrentLineNumber()
 	{
-		return getMostRelevantFileContext() != null ? getMostRelevantFileContext().getLine() : -1;
-	}
-	
-	public int getTopFileLineNumber()
-	{
-		return topContext.getLine();
-	}
-	
-	public Scanner getScanner()
-	{
-		return scanner;
+		return getMostRelevantFileContext().getLine();
 	}
+
 }
Index: parser/org/eclipse/cdt/internal/core/parser/scanner/IScannerContext.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IScannerContext.java,v
retrieving revision 1.1
diff -u -r1.1 IScannerContext.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner/IScannerContext.java	22 Jan 2004 20:15:26 -0000	1.1
+++ parser/org/eclipse/cdt/internal/core/parser/scanner/IScannerContext.java	14 Apr 2004 10:48:50 -0000
@@ -2,7 +2,6 @@
 import java.io.IOException;
 import java.io.Reader;
 
-import org.eclipse.cdt.core.parser.Enum;
 import org.eclipse.cdt.core.parser.ast.IASTInclusion;
 /**
  * @author jcamelon
@@ -11,20 +10,12 @@
 public interface IScannerContext {
 	
 	
-	public static class ContextKind extends Enum  
+	public static class ContextKind  
 	{
-		public static ContextKind SENTINEL = new ContextKind( 0 );
-		public static ContextKind TOP = new ContextKind( 1 ); 
-		public static ContextKind INCLUSION = new ContextKind( 2 ); 
-		public static ContextKind MACROEXPANSION = new ContextKind( 3 ); 
-		
-		/**
-		 * @param enumValue
-		 */
-		protected ContextKind(int enumValue) {
-			super(enumValue);
-			// 
-		}
+		public static int SENTINEL =  0;
+		public static int TOP = 1; 
+		public static int INCLUSION = 2; 
+		public static int MACROEXPANSION = 3; 
 	}
 
     /**
@@ -67,8 +58,8 @@
 	public int popUndo();
 	public void pushUndo(int undo);
 	
-	public ContextKind getKind(); 
-	public void setKind( ContextKind kind ); 
+	public int getKind(); 
+	public void setKind( int kind ); 
 
 	public IASTInclusion getExtension(); 
 	public void setExtension( IASTInclusion ext );
Index: parser/org/eclipse/cdt/internal/core/parser/scanner/LimitedScannerContext.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LimitedScannerContext.java,v
retrieving revision 1.2
diff -u -r1.2 LimitedScannerContext.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner/LimitedScannerContext.java	30 Jan 2004 18:28:07 -0000	1.2
+++ parser/org/eclipse/cdt/internal/core/parser/scanner/LimitedScannerContext.java	14 Apr 2004 10:48:50 -0000
@@ -30,7 +30,7 @@
 	 * @param object
 	 * @param offsetLimit
 	 */
-	public LimitedScannerContext(Scanner scanner, Reader reader, String string, ContextKind kind, int offsetLimit) {
+	public LimitedScannerContext(Scanner scanner, Reader reader, String string, int kind, int offsetLimit) {
 		super( reader, string, kind, null );
 		this.scanner = scanner;
 		limit = offsetLimit;
Index: parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java,v
retrieving revision 1.35
diff -u -r1.35 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java	12 Apr 2004 15:37:39 -0000	1.35
+++ parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java	14 Apr 2004 10:48:52 -0000
@@ -80,6 +80,11 @@
 	private static final int NO_OFFSET_LIMIT = -1;
 	private int offsetLimit = NO_OFFSET_LIMIT;
 	private boolean limitReached = false; 
+	private IScannerContext currentContext;
+	
+	public void setScannerContext(IScannerContext context) {
+		currentContext = context;
+	}
 	
 	protected void handleProblem( int problemID, String argument, int beginningOffset, boolean warning, boolean error ) throws ScannerException
 	{
@@ -546,7 +551,7 @@
 			}
 			else // local inclusion
 			{
-				duple = ScannerUtility.createReaderDuple( new File( scannerData.getContextStack().getCurrentContext().getFilename() ).getParentFile().getAbsolutePath(), fileName, scannerData.getClientRequestor(), scannerData.getWorkingCopies() );
+				duple = ScannerUtility.createReaderDuple( new File( currentContext.getFilename() ).getParentFile().getAbsolutePath(), fileName, scannerData.getClientRequestor(), scannerData.getWorkingCopies() );
 				if( duple != null )
 					break totalLoop;
 				useIncludePaths = true;
@@ -599,7 +604,7 @@
 		File includeFile = null;
 		
 		if( !useIncludePaths ) {  // local inclusion is checked first 			
-			String currentFilename = scannerData.getContextStack().getCurrentContext().getFilename(); 
+			String currentFilename = currentContext.getFilename(); 
 			File currentIncludeFile = new File( currentFilename );
 			String parentDirectory = currentIncludeFile.getParentFile().getAbsolutePath();
 			currentIncludeFile = null; 
@@ -723,9 +728,9 @@
 	private int getChar( boolean insideString ) throws ScannerException {	
 		int c = NOCHAR;
 		
-		lastContext = scannerData.getContextStack().getCurrentContext();
+		lastContext = currentContext;
 		
-		if (lastContext == null)
+		if (lastContext.getKind() == IScannerContext.ContextKind.SENTINEL)
 			// past the end of file
 			return c;
 
@@ -845,7 +850,7 @@
     {
     	int c;
     	try {
-    		c = scannerData.getContextStack().getCurrentContext().read();
+    		c = currentContext.read();
     	}
     	catch (IOException e) {
     		c = NOCHAR;
@@ -857,22 +862,16 @@
     	if (scannerData.getContextStack().rollbackContext(scannerData.getClientRequestor()) == false)
     		return NOCHAR;
     	
-    	if (scannerData.getContextStack().getCurrentContext().undoStackSize() != 0 )
-    		return scannerData.getContextStack().getCurrentContext().popUndo();
+    	if (currentContext.undoStackSize() != 0 )
+    		return currentContext.popUndo();
     	
     	return readFromStream();
     }
 
 	final void ungetChar(int c) throws ScannerException{
-		scannerData.getContextStack().getCurrentContext().pushUndo(c);
-		try
-		{
-			scannerData.getContextStack().undoRollback( lastContext, scannerData.getClientRequestor() );
-		}
-		catch (ContextException e)
-		{
-			handleProblem( e.getId(), scannerData.getContextStack().getCurrentContext().getFilename(), getCurrentOffset(), false, true );
-		}
+		currentContext.pushUndo(c);
+		scannerData.getContextStack().undoRollback( lastContext, scannerData.getClientRequestor() );
+
 	}
 
 	protected boolean lookAheadForTokenPasting() throws ScannerException
@@ -898,7 +897,7 @@
 
 	protected void consumeUntilOutOfMacroExpansion() throws ScannerException
 	{
-		while( scannerData.getContextStack().getCurrentContext().getKind() == IScannerContext.ContextKind.MACROEXPANSION )
+		while( currentContext.getKind() == IScannerContext.ContextKind.MACROEXPANSION )
 			getChar();
 	}
 
@@ -933,7 +932,7 @@
 			}
 			catch (ContextException e)
 			{
-				handleProblem( e.getId(), scannerData.getContextStack().getCurrentContext().getFilename(), getCurrentOffset(), false, true  );
+				handleProblem( e.getId(), currentContext.getFilename(), getCurrentOffset(), false, true  );
 			}
 			storageBuffer = null; 
 			return true;
@@ -1172,7 +1171,7 @@
 	public IToken processPreprocessor() throws ScannerException, EndOfFileException
 	{
 		int c;
-		int beginningOffset = scannerData.getContextStack().getCurrentContext().getOffset() - 1;
+		int beginningOffset = currentContext.getOffset() - 1;
 		int beginningLine = scannerData.getContextStack().getCurrentLineNumber();
 
 		// we are allowed arbitrary whitespace after the '#' and before the rest of the text
@@ -2679,7 +2678,7 @@
 	protected void poundDefine(int beginning, int beginningLine ) throws ScannerException, EndOfFileException {
 		// definition 
 		String key = getNextIdentifier();
-		int offset = scannerData.getContextStack().getCurrentContext().getOffset() - key.length() - scannerData.getContextStack().getCurrentContext().undoStackSize();
+		int offset = currentContext.getOffset() - key.length() - currentContext.undoStackSize();
 		int nameLine = scannerData.getContextStack().getCurrentLineNumber();
 
 		// store the previous definition to check against later
@@ -2819,7 +2818,7 @@
 		
 		try
         {
-			scannerData.getASTFactory().createMacro( key, beginning, beginningLine, offset, offset + key.length(), nameLine, scannerData.getContextStack().getCurrentContext().getOffset(), scannerData.getContextStack().getCurrentLineNumber(), descriptor ).acceptElement( scannerData.getClientRequestor() );
+			scannerData.getASTFactory().createMacro( key, beginning, beginningLine, offset, offset + key.length(), nameLine, currentContext.getOffset(), scannerData.getContextStack().getCurrentLineNumber(), descriptor ).acceptElement( scannerData.getClientRequestor() );
         }
         catch (Exception e)
         {
@@ -2952,7 +2951,7 @@
 			}
 			catch (ContextException e)
 			{
-				handleProblem( e.getId(), scannerData.getContextStack().getCurrentContext().getFilename(), getCurrentOffset(), false, true );
+				handleProblem( e.getId(), currentContext.getFilename(), getCurrentOffset(), false, true );
 				consumeUntilOutOfMacroExpansion();
 				return;
 			}
@@ -2983,7 +2982,7 @@
 				String betweenTheBrackets = buffer.toString().trim();
                 
                 Vector parameterValues = getMacroParameters(betweenTheBrackets, false);
-                Vector parameterValuesForStringizing = getMacroParameters(betweenTheBrackets, true);
+                Vector parameterValuesForStringizing = null;
                 SimpleToken t = null;
                 
 				// create a string that represents what needs to be tokenized
@@ -3018,6 +3017,8 @@
 					} else if (t.getType() == tPOUND) {
 						//next token should be a parameter which needs to be turned into
 						//a string literal
+						if( parameterValuesForStringizing == null)
+							parameterValuesForStringizing = getMacroParameters(betweenTheBrackets, true);
 						t = (SimpleToken) tokens.get( ++i );
 						int index = parameterNames.indexOf(t.getImage());
 						if( index == -1 ){
@@ -3102,7 +3103,7 @@
 				}
 				catch (ContextException e)
 				{
-					handleProblem( e.getId(), scannerData.getContextStack().getCurrentContext().getFilename(), getCurrentOffset(), false, true );
+					handleProblem( e.getId(), currentContext.getFilename(), getCurrentOffset(), false, true );
 					consumeUntilOutOfMacroExpansion();
 					return;
 				}
@@ -3192,7 +3193,7 @@
 	 * @see org.eclipse.cdt.core.parser.IScanner#isOnTopContext()
 	 */
 	public boolean isOnTopContext() {
-		return ( scannerData.getContextStack().getCurrentContext() == scannerData.getContextStack().getTopContext() );
+		return ( currentContext.getKind() == IScannerContext.ContextKind.TOP );
 	}	/* (non-Javadoc)
 	 * @see org.eclipse.cdt.core.parser.IFilenameProvider#getCurrentFilename()
 	 */
@@ -3208,8 +3209,8 @@
 	public String toString() {
 		StringBuffer buffer = new StringBuffer();
 		buffer.append( "Scanner @"); //$NON-NLS-1$
-		if( scannerData.getContextStack().getCurrentContext() != null )
-			buffer.append( scannerData.getContextStack().getCurrentContext().toString());
+		if( currentContext != null )
+			buffer.append( currentContext.toString());
 		else
 			buffer.append( "EOF"); //$NON-NLS-1$
 		return buffer.toString();
Index: parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java,v
retrieving revision 1.3
diff -u -r1.3 ScannerContext.java
--- parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java	12 Apr 2004 15:37:39 -0000	1.3
+++ parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java	14 Apr 2004 10:48:52 -0000
@@ -23,12 +23,12 @@
     private int macroLength = -1;
 	private int line = 1;
 	private int offset;
-	private ContextKind kind; 
+	private int kind; 
 				
     /* (non-Javadoc)
      * @see org.eclipse.cdt.internal.core.parser.IScannerContext#initialize(Reader, String, int, IASTInclusion, int, int, int)
      */
-	public ScannerContext(Reader r, String f, ContextKind k, IASTInclusion i, int mO, int mL, int l)
+	public ScannerContext(Reader r, String f, int k, IASTInclusion i, int mO, int mL, int l)
 	{
 		reader = r;
 		filename = f;
@@ -43,7 +43,7 @@
     /* (non-Javadoc)
      * @see org.eclipse.cdt.internal.core.parser.IScannerContext#initialize(Reader, String, int, IASTInclusion)
      */
-    public ScannerContext(Reader r, String f, ContextKind k, IASTInclusion i)
+    public ScannerContext(Reader r, String f, int k, IASTInclusion i)
     {
         this(r, f, k, i, -1, -1, 1);
     }
@@ -151,7 +151,7 @@
 	 * Returns the kind.
 	 * @return int
 	 */
-	public ContextKind getKind() {
+	public int getKind() {
 		return kind;
 	}
 
@@ -159,7 +159,7 @@
 	 * Sets the kind.
 	 * @param kind The kind to set
 	 */
-	public void setKind(ContextKind kind) {
+	public void setKind(int kind) {
 		this.kind = kind;
 	}
 	/* (non-Javadoc)

Back to the top