[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Applied [HEAD] Parser_SymbolTable branch merged to HEAD
|
Major restructuring work includes:
-
introduction of public interfaces of parser for Search/Indexer teams
-
restructuring of parser architecture to deal with footprint issues
-
restructuring of parser logic so to not break outline view/quickParse while
we get full parse working.
We still have a long way to go to get
full parsing working.
JohnC
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/ChangeLog,v
retrieving revision 1.60
diff -u -r1.60 ChangeLog
--- ChangeLog 11 Jun 2003 19:14:01 -0000 1.60
+++ ChangeLog 13 Jun 2003 14:59:56 -0000
@@ -1,3 +1,12 @@
+2003-06-13 John Camelon
+ Merged ParserSymbolTable branch back into HEAD.
+
+2003-06-12 John Camelon
+ Get rest of JUnit tests working, will merge back to HEAD branch.
+
+2003-06-12 John Camelon
+ Introduction of ASTFactory strategy, some restructuring of packages and interfaces.
+
2003-06-11 Victor Mozgin
Old Java TestCase.txt and TestCase2.txt for partioning testing have been replaced with C/C++ files.
Modified AutomatedIntegrationSuite.java so it doesn't produce JUnit warning anymore.
@@ -11,9 +20,15 @@
Added TortureTest to test CDT C++ parser with GCC testsuites.
GCC testsuites are not included.
+2003-06-10 John Camelon
+ Futher pursuit of the golden hammer, symbol table integration.
+
2003-06-10 Brent Nicolle
Added some Interface tests of (IInclude, IMacro, IStructure).
Made sure all the Test Suites have names in the JUnit hierarchy.
+
+2003-06-09 John Camelon
+ First step in replacing IParserCallback with ISourceElementRequestor.
2003-06-09 Victor Mozgin
Moved testBug36769() from ACEFailedTest.java to DOMTests.java.
@@ -37,6 +52,26 @@
2003-06-05 John Camelon
Moved testBug23478A() & testBug23478B() from failed tests to TranslationUnitTests.java.
Removed TranslationUnitFailedTests.java as it was empty.
+
+2003-05-29 Andrew Niefer
+ Modified tests to support eType & PtrOp changes in core
+ Added ParserSymbolTableTest::testTemplateParameterAsParent
+ Added ParserSymbolTableTest::testTemplateInstanceAsParent
+ Added ParserSymbolTableTest::testTemplateParameterDefaults
+ Added ParserSymbolTableTest::testTemplateParameterAsFunctionArgument
+ started ParserSymbolTableTest::incompletetestTemplateSpecialization
+
+2003-05-26 John Camelon
+ Rollback PST/Parser integration.
+
+2003-05-13 Andrew Niefer
+ Modified ParserSymbolTableTest to use new interface
+
+2003-05-08 Andrew Niefer
+ Added ParserSymbolTableTest::testMarkRollback
+
+2003-05-06 John Camelon
+ Further integration of SymbolTable into Parser, some refactoring.
2003-05-05 John Camelon/Andrew Niefer
Added CrossReferenceTests to ParserTestSuite to test symbol-table/DOM interworking.
Index: failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java,v
retrieving revision 1.2
diff -u -r1.2 CModelElementsFailedTests.java
--- failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java 10 Jun 2003 22:57:05 -0000 1.2
+++ failures/org/eclipse/cdt/core/model/failedTests/CModelElementsFailedTests.java 13 Jun 2003 14:59:56 -0000
@@ -21,12 +21,12 @@
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.INamespace;
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.internal.core.model.CElement;
+import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.testplugin.CProjectHelper;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
Index: parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java,v
retrieving revision 1.7
diff -u -r1.7 AutomatedTest.java
--- parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java 24 Apr 2003 21:01:24 -0000 1.7
+++ parser/org/eclipse/cdt/core/parser/tests/AutomatedTest.java 13 Jun 2003 14:59:56 -0000
@@ -20,7 +20,7 @@
import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import org.eclipse.cdt.internal.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.core.runtime.Path;
Index: parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java,v
retrieving revision 1.2
diff -u -r1.2 BaseDOMTest.java
--- parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java 24 Apr 2003 21:01:24 -0000 1.2
+++ parser/org/eclipse/cdt/core/parser/tests/BaseDOMTest.java 13 Jun 2003 14:59:56 -0000
@@ -12,10 +12,9 @@
import junit.framework.TestCase;
+import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
-import org.eclipse.cdt.internal.core.dom.DOMFactory;
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
-import org.eclipse.cdt.internal.core.parser.IParser;
import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.core.parser.ParserException;
@@ -32,11 +31,11 @@
public TranslationUnit parse( String code ) throws Exception
{
- return parse( code, false, true );
+ return parse( code, true, true );
}
public TranslationUnit parse(String code, boolean quickParse, boolean throwOnError ) throws Exception {
- DOMBuilder domBuilder = DOMFactory.createDOMBuilder(false);
+ DOMBuilder domBuilder = new DOMBuilder();
IParser parser = new Parser(code, domBuilder, quickParse );
if( ! parser.parse() )
if( throwOnError ) throw new ParserException( "Parse failure" );
Index: parser/org/eclipse/cdt/core/parser/tests/CrossReferenceTests.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/tests/CrossReferenceTests.java
diff -N parser/org/eclipse/cdt/core/parser/tests/CrossReferenceTests.java
--- parser/org/eclipse/cdt/core/parser/tests/CrossReferenceTests.java 5 May 2003 20:51:07 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * 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 Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.core.parser.tests;
-
-import java.io.StringWriter;
-import java.io.Writer;
-
-import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
-import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
-import org.eclipse.cdt.internal.core.dom.TranslationUnit;
-
-/**
- * @author jcamelon
- *
- */
-public class CrossReferenceTests extends BaseDOMTest {
-
- public CrossReferenceTests( String arg )
- {
- super( arg );
- }
-
-
- public void testMultipleNamespaceDefinition() throws Exception
- {
- Writer code = new StringWriter();
- code.write( "namespace A { int a; }\n" );
- code.write( "namespace A { int k; }\n" );
- TranslationUnit tu = parse( code.toString() );
- assertEquals( tu.getDeclarations().size(), 1 );
- assertEquals( ((NamespaceDefinition)tu.getDeclarations().get(0)).getDeclarations().size(), 2 );
- }
-
- public void testElaboratedTypeReference() throws Exception
- {
- Writer code = new StringWriter();
- code.write( "class A { int x; }; \n");
- code.write( "class A myA;");
- TranslationUnit tu = parse( code.toString() );
- assertEquals( tu.getDeclarations().size(), 2 );
- SimpleDeclaration first = (SimpleDeclaration)tu.getDeclarations().get(0);
- SimpleDeclaration second = (SimpleDeclaration)tu.getDeclarations().get(1);
- }
-}
Index: parser/org/eclipse/cdt/core/parser/tests/DOMTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/DOMTests.java,v
retrieving revision 1.35
diff -u -r1.35 DOMTests.java
--- parser/org/eclipse/cdt/core/parser/tests/DOMTests.java 10 Jun 2003 14:41:42 -0000 1.35
+++ parser/org/eclipse/cdt/core/parser/tests/DOMTests.java 13 Jun 2003 14:59:57 -0000
@@ -27,7 +27,6 @@
import org.eclipse.cdt.internal.core.dom.Inclusion;
import org.eclipse.cdt.internal.core.dom.LinkageSpecification;
import org.eclipse.cdt.internal.core.dom.Macro;
-import org.eclipse.cdt.internal.core.dom.Name;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
@@ -39,6 +38,7 @@
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
import org.eclipse.cdt.internal.core.dom.UsingDeclaration;
import org.eclipse.cdt.internal.core.dom.UsingDirective;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.ParserException;
import org.eclipse.cdt.internal.core.parser.Token;
@@ -66,7 +66,7 @@
if( i == 0 )
assertEquals( namespace.getName().toString(), "KingJohn" );
else
- assertNull( namespace.getName() );
+ assertEquals( namespace.getName(), "" );
List namespaceDeclarations = namespace.getDeclarations();
assertEquals( namespaceDeclarations.size(), 1 );
SimpleDeclaration simpleDec = (SimpleDeclaration)namespaceDeclarations.get(0);
@@ -222,16 +222,16 @@
assertEquals( second.getNamespaceName().toString(), "C" );
third = (UsingDeclaration) declarations.get(2);
- assertEquals( third.getMappedName().toString(), "B::f" );
+ assertEquals( third.getMappedName(), "B::f" );
assertFalse( third.isTypename() );
fourth = (UsingDeclaration) declarations.get(3);
- assertEquals( fourth.getMappedName().toString(), "::f" );
+ assertEquals( fourth.getMappedName(), "::f" );
assertFalse( fourth.isTypename() );
fifth = (UsingDeclaration) declarations.get(4);
assertTrue( fifth.isTypename() );
- assertEquals( fifth.getMappedName().toString(), "crap::de::crap" );
+ assertEquals( fifth.getMappedName(), "crap::de::crap" );
}
public void testDeclSpecifier() throws Exception
@@ -899,7 +899,7 @@
public void testConstructorChain() throws Exception
{
- TranslationUnit tu = parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}" );
+ TranslationUnit tu = parse( "TrafficLight_Actor::TrafficLight_Actor( RTController * rtg_rts, RTActorRef * rtg_ref ) : RTActor( rtg_rts, rtg_ref ), myId( 0 ) {}", true, true);
List tuDeclarations = tu.getDeclarations();
assertEquals( tuDeclarations.size(), 1 );
SimpleDeclaration decl1 = (SimpleDeclaration)tuDeclarations.get(0);
Index: parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java,v
retrieving revision 1.5
diff -u -r1.5 ExprEvalTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java 16 Apr 2003 12:30:41 -0000 1.5
+++ parser/org/eclipse/cdt/core/parser/tests/ExprEvalTest.java 13 Jun 2003 14:59:57 -0000
@@ -4,8 +4,8 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.internal.core.parser.ExpressionEvaluator;
-import org.eclipse.cdt.internal.core.parser.IParser;
import org.eclipse.cdt.internal.core.parser.Parser;
public class ExprEvalTest extends TestCase {
Index: parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java,v
retrieving revision 1.4
diff -u -r1.4 LineNumberTest.java
--- parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java 21 Apr 2003 18:34:42 -0000 1.4
+++ parser/org/eclipse/cdt/core/parser/tests/LineNumberTest.java 13 Jun 2003 14:59:57 -0000
@@ -19,15 +19,14 @@
import junit.framework.TestCase;
+import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
-import org.eclipse.cdt.internal.core.dom.DOMFactory;
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
import org.eclipse.cdt.internal.core.dom.IOffsetable;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
-import org.eclipse.cdt.internal.core.parser.IParser;
import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.core.parser.Scanner;
import org.eclipse.cdt.internal.core.parser.Token;
@@ -92,7 +91,7 @@
public void testDOMLineNos() throws Exception
{
- DOMBuilder domBuilder = DOMFactory.createDOMBuilder( true );
+ DOMBuilder domBuilder = new DOMBuilder();
IParser parser = new Parser( fileIn, domBuilder, true );
parser.mapLineNumbers(true);
if( ! parser.parse() ) fail( "Parse of file failed");
Index: parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java,v
retrieving revision 1.13
diff -u -r1.13 ParserSymbolTableTest.java
--- parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java 5 May 2003 17:01:04 -0000 1.13
+++ parser/org/eclipse/cdt/core/parser/tests/ParserSymbolTableTest.java 13 Jun 2003 14:59:58 -0000
@@ -17,8 +17,22 @@
import junit.framework.TestCase;
-import org.eclipse.cdt.internal.core.parser.ParserSymbolTable;
-import org.eclipse.cdt.internal.core.parser.ParserSymbolTableException;
+import org.eclipse.cdt.core.parser.ast.AccessVisibility;
+import org.eclipse.cdt.internal.core.parser.ast.full.ASTCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.ast.full.IASTFCompilationUnit;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.IParameterizedSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Declaration;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.Mark;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo.PtrOp;
+
+
/**
* @author aniefer
@@ -51,15 +65,15 @@
public void testSimpleAdd() throws Exception{
newTable(); //create the symbol table
- ParserSymbolTable.Declaration x = table.new Declaration( "x" );
- ParserSymbolTable.Declaration compUnit = (ParserSymbolTable.Declaration) table.getCompilationUnit();
- compUnit.addDeclaration( x );
+ ISymbol x = table.newSymbol( "x" );
+ IContainerSymbol compUnit = table.getCompilationUnit();
+ compUnit.addSymbol( x );
- Map declarations = compUnit.getContainedDeclarations();
+ Map declarations = compUnit.getContainedSymbols();
assertEquals( 1, declarations.size() );
Iterator iter = declarations.values().iterator();
- ParserSymbolTable.Declaration contained = (ParserSymbolTable.Declaration) iter.next();
+ ISymbol contained = (ISymbol) iter.next();
assertEquals( false, iter.hasNext() );
assertEquals( x, contained );
@@ -74,10 +88,10 @@
public void testSimpleLookup() throws Exception{
newTable(); //new symbol table
- ParserSymbolTable.Declaration x = table.new Declaration( "x" );
- table.getCompilationUnit().addDeclaration( x );
+ ISymbol x = table.new Declaration( "x" );
+ table.getCompilationUnit().addSymbol( x );
- ParserSymbolTable.Declaration look = table.getCompilationUnit().Lookup( "x" );
+ ISymbol look = table.getCompilationUnit().Lookup( "x" );
assertEquals( x, look );
}
@@ -85,43 +99,23 @@
public void testLookupNonExistant() throws Exception{
newTable();
- ParserSymbolTable.Declaration look = table.getCompilationUnit().Lookup("boo");
+ ISymbol look = table.getCompilationUnit().Lookup("boo");
assertEquals( look, null );
}
- /**
- * testSimplePushPop
- * test pushing and popping
- * @throws Exception
- *//*
- public void testSimplePushPop() throws Exception{
- newTable();
-
- Declaration pushing = new Declaration( "class" );
- assertEquals( pushing.getContainingScope(), null );
-
- table.push( pushing );
- assertEquals( pushing, table.peek() );
- assertEquals( pushing.getContainingScope(), table.getCompilationUnit() );
-
- Declaration popped = table.pop();
- assertEquals( pushing, popped );
- assertEquals( table.peek(), table.getCompilationUnit() );
- }*/
-
public void testSimpleSetGetObject() throws Exception{
newTable();
- ParserSymbolTable.Declaration x = table.new Declaration("x");
+ IContainerSymbol x = table.new Declaration("x");
- Object obj = new Object();
- x.setObject( obj );
+ IASTFCompilationUnit obj = new ASTCompilationUnit( x );
+ x.setASTNode( obj );
- table.getCompilationUnit().addDeclaration( x );
+ table.getCompilationUnit().addSymbol( x );
- ParserSymbolTable.Declaration look = table.getCompilationUnit().Lookup( "x" );
+ ISymbol look = table.getCompilationUnit().Lookup( "x" );
- assertEquals( look.getObject(), obj );
+ assertEquals( look.getASTNode(), obj );
}
/**
@@ -133,18 +127,18 @@
public void testHide() throws Exception{
newTable();
- ParserSymbolTable.Declaration firstX = table.new Declaration("x");
- table.getCompilationUnit().addDeclaration( firstX );
+ ISymbol firstX = table.newSymbol("x");
+ table.getCompilationUnit().addSymbol( firstX );
- ParserSymbolTable.Declaration firstClass = table.new Declaration("class");
+ IDerivableContainerSymbol firstClass = table.newDerivableContainerSymbol("class");
firstClass.setType( ParserSymbolTable.TypeInfo.t_class );
- table.getCompilationUnit().addDeclaration( firstClass );
+ table.getCompilationUnit().addSymbol( firstClass );
- ParserSymbolTable.Declaration look = firstClass.Lookup( "x" );
+ ISymbol look = firstClass.Lookup( "x" );
assertEquals( look, firstX );
- ParserSymbolTable.Declaration secondX = table.new Declaration("x");
- firstClass.addDeclaration( secondX );
+ ISymbol secondX = table.newSymbol("x");
+ firstClass.addSymbol( secondX );
look = firstClass.Lookup( "x" );
assertEquals( look, secondX );
@@ -161,14 +155,14 @@
public void testContainingScopeLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration x = table.new Declaration("x");
- table.getCompilationUnit().addDeclaration( x );
+ ISymbol x = table.newSymbol("x");
+ table.getCompilationUnit().addSymbol( x );
- ParserSymbolTable.Declaration decl = table.new Declaration("class");
+ IDerivableContainerSymbol decl = table.newDerivableContainerSymbol("class");
decl.setType( ParserSymbolTable.TypeInfo.t_class );
- table.getCompilationUnit().addDeclaration( decl );
+ table.getCompilationUnit().addSymbol( decl );
- ParserSymbolTable.Declaration look = decl.Lookup( "x" );
+ ISymbol look = decl.Lookup( "x" );
assertEquals( x, look );
}
@@ -182,20 +176,20 @@
public void testParentLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration parent = table.new Declaration("parent");
+ IDerivableContainerSymbol parent = table.newDerivableContainerSymbol("parent");
parent.setType( ParserSymbolTable.TypeInfo.t_class );
- ParserSymbolTable.Declaration class1 = table.new Declaration("class");
+ IDerivableContainerSymbol class1 = table.newDerivableContainerSymbol("class");
class1.setType( ParserSymbolTable.TypeInfo.t_class );
class1.addParent( parent );
- ParserSymbolTable.Declaration decl = table.new Declaration("x");
- parent.addDeclaration( decl );
+ ISymbol decl = table.new Declaration("x");
+ parent.addSymbol( decl );
- table.getCompilationUnit().addDeclaration( parent );
- table.getCompilationUnit().addDeclaration( class1 );
+ table.getCompilationUnit().addSymbol( parent );
+ table.getCompilationUnit().addSymbol( class1 );
- ParserSymbolTable.Declaration look = class1.Lookup( "x" );
+ ISymbol look = class1.Lookup( "x" );
assertEquals( look, decl );
}
@@ -211,14 +205,14 @@
public void testAmbiguousParentLookup() throws Exception{
testParentLookup();
- ParserSymbolTable.Declaration parent2 = table.new Declaration("parent2");
- table.getCompilationUnit().addDeclaration( parent2 );
+ IDerivableContainerSymbol parent2 = table.newDerivableContainerSymbol("parent2");
+ table.getCompilationUnit().addSymbol( parent2 );
- ParserSymbolTable.Declaration class1 = table.getCompilationUnit().Lookup( "class" );
+ IDerivableContainerSymbol class1 = (IDerivableContainerSymbol) table.getCompilationUnit().Lookup( "class" );
class1.addParent( parent2 );
- ParserSymbolTable.Declaration decl = table.new Declaration("x");
- parent2.addDeclaration( decl );
+ ISymbol decl = table.new Declaration("x");
+ parent2.addSymbol( decl );
try{
class1.Lookup( "x" );
@@ -237,17 +231,17 @@
public void testCircularParentLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration a = table.new Declaration("a");
- table.getCompilationUnit().addDeclaration( a );
+ IDerivableContainerSymbol a = table.newDerivableContainerSymbol("a");
+ table.getCompilationUnit().addSymbol( a );
- ParserSymbolTable.Declaration b = table.new Declaration("b");
+ IDerivableContainerSymbol b = table.newDerivableContainerSymbol("b");
b.addParent( a );
- table.getCompilationUnit().addDeclaration( b );
+ table.getCompilationUnit().addSymbol( b );
a.addParent( b );
try{
- ParserSymbolTable.Declaration look = a.Lookup("foo");
+ ISymbol look = a.Lookup("foo");
assertTrue( false );
} catch ( ParserSymbolTableException e) {
assertEquals( e.reason, ParserSymbolTableException.r_CircularInheritance );
@@ -269,29 +263,29 @@
public void testVirtualParentLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration decl = table.new Declaration("class");
- ParserSymbolTable.Declaration c = table.new Declaration("C");
+ IDerivableContainerSymbol decl = table.newDerivableContainerSymbol("class");
+ IDerivableContainerSymbol c = table.newDerivableContainerSymbol("C");
- ParserSymbolTable.Declaration a = table.new Declaration("A");
- a.addParent( c, true );
+ IDerivableContainerSymbol a = table.newDerivableContainerSymbol("A");
+ a.addParent( c, true, AccessVisibility.v_public );
- ParserSymbolTable.Declaration b = table.new Declaration("B");
- b.addParent( c, true );
+ IDerivableContainerSymbol b = table.newDerivableContainerSymbol("B");
+ b.addParent( c, true, AccessVisibility.v_public );
decl.addParent( a );
decl.addParent( b );
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
- compUnit.addDeclaration( c );
+ IContainerSymbol compUnit = table.getCompilationUnit();
+ compUnit.addSymbol( c );
- ParserSymbolTable.Declaration x = table.new Declaration( "x" );
- c.addDeclaration( x );
+ ISymbol x = table.new Declaration( "x" );
+ c.addSymbol( x );
- compUnit.addDeclaration( decl );
- compUnit.addDeclaration( a );
- compUnit.addDeclaration( b );
+ compUnit.addSymbol( decl );
+ compUnit.addSymbol( a );
+ compUnit.addSymbol( b );
- ParserSymbolTable.Declaration look = decl.Lookup( "x" );
+ ISymbol look = decl.Lookup( "x" );
assertEquals( look, x );
}
@@ -310,15 +304,17 @@
public void testAmbiguousVirtualParentLookup() throws Exception{
testVirtualParentLookup();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration cls = compUnit.Lookup("class");
- ParserSymbolTable.Declaration c = compUnit.Lookup("C");
- ParserSymbolTable.Declaration d = table.new Declaration("D");
+ IDerivableContainerSymbol cls = (IDerivableContainerSymbol) compUnit.Lookup("class");
+ IDerivableContainerSymbol c = (IDerivableContainerSymbol) compUnit.Lookup("C");
+ IDerivableContainerSymbol d = table.newDerivableContainerSymbol("D");
d.addParent( c );
cls.addParent( d );
+ compUnit.addSymbol( d );
+
try{
cls.Lookup( "x" );
assertTrue( false );
@@ -344,34 +340,34 @@
public void testStaticEnumParentLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration a = table.new Declaration( "a" );
- ParserSymbolTable.Declaration b = table.new Declaration( "b" );
- ParserSymbolTable.Declaration c = table.new Declaration( "c" );
- ParserSymbolTable.Declaration d = table.new Declaration( "d" );
-
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
-
- compUnit.addDeclaration( a );
- compUnit.addDeclaration( b );
- compUnit.addDeclaration( c );
- compUnit.addDeclaration( d );
+ IDerivableContainerSymbol a = table.newDerivableContainerSymbol("a" );
+ IDerivableContainerSymbol b = table.newDerivableContainerSymbol( "b" );
+ IDerivableContainerSymbol c = table.newDerivableContainerSymbol( "c" );
+ IDerivableContainerSymbol d = table.newDerivableContainerSymbol( "d" );
+
+ IContainerSymbol compUnit = table.getCompilationUnit();
+
+ compUnit.addSymbol( a );
+ compUnit.addSymbol( b );
+ compUnit.addSymbol( c );
+ compUnit.addSymbol( d );
- ParserSymbolTable.Declaration enum = table.new Declaration("enum");
+ IContainerSymbol enum = table.new Declaration("enum");
enum.setType( ParserSymbolTable.TypeInfo.t_enumeration );
- ParserSymbolTable.Declaration enumerator = table.new Declaration( "enumerator" );
+ ISymbol enumerator = table.new Declaration( "enumerator" );
enumerator.setType( ParserSymbolTable.TypeInfo.t_enumerator );
- ParserSymbolTable.Declaration stat = table.new Declaration("static");
+ ISymbol stat = table.new Declaration("static");
stat.getTypeInfo().setBit( true, ParserSymbolTable.TypeInfo.isStatic );
- ParserSymbolTable.Declaration x = table.new Declaration("x");
+ ISymbol x = table.new Declaration("x");
- d.addDeclaration( enum );
- d.addDeclaration( stat );
- d.addDeclaration( x );
+ d.addSymbol( enum );
+ d.addSymbol( stat );
+ d.addSymbol( x );
- enum.addDeclaration( enumerator );
+ enum.addSymbol( enumerator );
a.addParent( b );
a.addParent( c );
@@ -411,33 +407,36 @@
public void testElaboratedLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration cls = table.new Declaration( "class" );
+ IDerivableContainerSymbol cls = table.newDerivableContainerSymbol( "class" );
cls.setType( ParserSymbolTable.TypeInfo.t_class );
- ParserSymbolTable.Declaration struct = table.new Declaration("struct");
+ IDerivableContainerSymbol struct = table.newDerivableContainerSymbol("struct");
struct.setType( ParserSymbolTable.TypeInfo.t_struct );
- ParserSymbolTable.Declaration union = table.new Declaration("union");
+ IContainerSymbol union = table.newContainerSymbol("union");
union.setType( ParserSymbolTable.TypeInfo.t_union );
- ParserSymbolTable.Declaration hideCls = table.new Declaration( "class" );
- ParserSymbolTable.Declaration hideStruct = table.new Declaration("struct");
- ParserSymbolTable.Declaration hideUnion = table.new Declaration("union");
-
- ParserSymbolTable.Declaration a = table.new Declaration("a");
- ParserSymbolTable.Declaration b = table.new Declaration("b");
-
- a.addDeclaration(hideCls);
- a.addDeclaration(hideStruct);
- a.addDeclaration(hideUnion);
+ IDerivableContainerSymbol hideCls = table.newDerivableContainerSymbol( "class" );
+ IDerivableContainerSymbol hideStruct = table.newDerivableContainerSymbol("struct");
+ IContainerSymbol hideUnion = table.newContainerSymbol("union");
+
+ IDerivableContainerSymbol a = table.newDerivableContainerSymbol("a");
+ IDerivableContainerSymbol b = table.newDerivableContainerSymbol("b");
+
+ a.addSymbol(hideCls);
+ a.addSymbol(hideStruct);
+ a.addSymbol(hideUnion);
a.addParent( b );
- b.addDeclaration(cls);
- b.addDeclaration(struct);
- b.addDeclaration(union);
+ b.addSymbol(cls);
+ b.addSymbol(struct);
+ b.addSymbol(union);
+
+ table.getCompilationUnit().addSymbol( a );
+ table.getCompilationUnit().addSymbol( b );
- ParserSymbolTable.Declaration look = a.ElaboratedLookup( ParserSymbolTable.TypeInfo.t_class, "class" );
+ ISymbol look = a.ElaboratedLookup( ParserSymbolTable.TypeInfo.t_class, "class" );
assertEquals( look, cls );
look = a.ElaboratedLookup( ParserSymbolTable.TypeInfo.t_struct, "struct" );
assertEquals( look, struct );
@@ -456,26 +455,26 @@
public void testDeclarationType() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
//pre-condition
- ParserSymbolTable.Declaration A = table.new Declaration("A");
- compUnit.addDeclaration(A);
+ IContainerSymbol A = table.newContainerSymbol("A");
+ compUnit.addSymbol(A);
- ParserSymbolTable.Declaration member = table.new Declaration("member");
- A.addDeclaration(member);
+ ISymbol member = table.newSymbol("member");
+ A.addSymbol(member);
//at time of "A a;"
- ParserSymbolTable.Declaration look = compUnit.Lookup("A");
+ ISymbol look = compUnit.Lookup("A");
assertEquals( look, A );
- ParserSymbolTable.Declaration a = table.new Declaration("a");
- a.setTypeDeclaration( look );
- compUnit.addDeclaration( a );
+ ISymbol a = table.newSymbol("a");
+ a.setTypeSymbol( look );
+ compUnit.addSymbol( a );
//later "a.member"
look = compUnit.Lookup("a");
assertEquals( look, a );
- ParserSymbolTable.Declaration type = look.getTypeDeclaration();
+ IContainerSymbol type = (IContainerSymbol) look.getTypeSymbol();
assertEquals( type, A );
look = type.Lookup("member");
@@ -499,21 +498,21 @@
public void testFunctionHidesClass() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration struct = table.new Declaration( "stat");
+ IDerivableContainerSymbol struct = table.newDerivableContainerSymbol("stat");
struct.setType( ParserSymbolTable.TypeInfo.t_struct );
- compUnit.addDeclaration( struct );
+ compUnit.addSymbol( struct );
- ParserSymbolTable.Declaration function = table.new Declaration( "stat" );
+ IParameterizedSymbol function = table.newParameterizedSymbol( "stat" );
function.setType( ParserSymbolTable.TypeInfo.t_function );
- compUnit.addDeclaration( function );
+ compUnit.addSymbol( function );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
f.setType( ParserSymbolTable.TypeInfo.t_function );
- compUnit.addDeclaration( f );
+ compUnit.addSymbol( f );
- ParserSymbolTable.Declaration look = f.ElaboratedLookup( ParserSymbolTable.TypeInfo.t_struct, "stat" );
+ ISymbol look = f.ElaboratedLookup( ParserSymbolTable.TypeInfo.t_struct, "stat" );
assertEquals( look, struct );
look = f.Lookup( "stat" );
@@ -554,50 +553,51 @@
public void testUsingDirectives_1() throws Exception{
newTable();
- ParserSymbolTable.Declaration nsA = table.new Declaration("A");
+ IContainerSymbol nsA = table.newContainerSymbol("A");
nsA.setType( ParserSymbolTable.TypeInfo.t_namespace );
- table.getCompilationUnit().addDeclaration( nsA );
+ table.getCompilationUnit().addSymbol( nsA );
- ParserSymbolTable.Declaration nsA_i = table.new Declaration("i");
- nsA.addDeclaration( nsA_i );
+ ISymbol nsA_i = table.newSymbol("i");
+ nsA.addSymbol( nsA_i );
- ParserSymbolTable.Declaration nsB = table.new Declaration("B");
+ IContainerSymbol nsB = table.newContainerSymbol("B");
nsB.setType( ParserSymbolTable.TypeInfo.t_namespace );
- nsA.addDeclaration( nsB );
+ nsA.addSymbol( nsB );
- ParserSymbolTable.Declaration nsC = table.new Declaration("C");
+ IContainerSymbol nsC = table.newContainerSymbol("C");
nsC.setType( ParserSymbolTable.TypeInfo.t_namespace );
- nsB.addDeclaration( nsC );
+ nsB.addSymbol( nsC );
- ParserSymbolTable.Declaration nsC_i = table.new Declaration("i");
- nsC.addDeclaration( nsC_i );
+ ISymbol nsC_i = table.newSymbol("i");
+ nsC.addSymbol( nsC_i );
- ParserSymbolTable.Declaration look = nsB.Lookup("C");
- nsB.addUsingDirective( look );
+ ISymbol look = nsB.Lookup("C");
+ assertEquals( look, nsC );
+ nsB.addUsingDirective( nsC );
- ParserSymbolTable.Declaration f1 = table.new Declaration("f");
+ IParameterizedSymbol f1 = table.newParameterizedSymbol("f");
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- nsB.addDeclaration( f1 );
+ nsB.addSymbol( f1 );
look = f1.Lookup( "i" );
assertEquals( look, nsC_i ); //C::i visible and hides A::i
- ParserSymbolTable.Declaration nsD = table.new Declaration("D");
+ IContainerSymbol nsD = table.newContainerSymbol("D");
nsD.setType( ParserSymbolTable.TypeInfo.t_namespace );
- nsA.addDeclaration( nsD );
+ nsA.addSymbol( nsD );
look = nsD.Lookup("B");
assertEquals( look, nsB );
- nsD.addUsingDirective( look );
+ nsD.addUsingDirective( nsB );
look = nsD.Lookup("C");
assertEquals( look, nsC );
- nsD.addUsingDirective( look );
+ nsD.addUsingDirective( nsC );
- ParserSymbolTable.Declaration f2 = table.new Declaration( "f2" );
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f2" );
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- nsD.addDeclaration( f2 );
+ nsD.addSymbol( f2 );
try
{
@@ -610,16 +610,16 @@
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
}
- ParserSymbolTable.Declaration f3 = table.new Declaration ("f3");
+ IParameterizedSymbol f3 = table.newParameterizedSymbol("f3");
f3.setType( ParserSymbolTable.TypeInfo.t_function );
- nsA.addDeclaration( f3 );
+ nsA.addSymbol( f3 );
look = f3.Lookup("i");
assertEquals( look, nsA_i ); //uses A::i
- ParserSymbolTable.Declaration f4 = table.new Declaration ("f4");
+ IParameterizedSymbol f4 = table.newParameterizedSymbol("f4");
f4.setType( ParserSymbolTable.TypeInfo.t_function );
- table.getCompilationUnit().addDeclaration( f4 );
+ table.getCompilationUnit().addSymbol( f4 );
look = f4.Lookup("i");
assertEquals( look, null );//neither i is visible here.
@@ -648,31 +648,31 @@
{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration nsM = table.new Declaration( "M" );
+ IContainerSymbol nsM = table.newContainerSymbol( "M" );
nsM.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsM );
+ compUnit.addSymbol( nsM );
- ParserSymbolTable.Declaration nsM_i = table.new Declaration("i");
- nsM.addDeclaration( nsM_i );
+ ISymbol nsM_i = table.newSymbol("i");
+ nsM.addSymbol( nsM_i );
- ParserSymbolTable.Declaration nsN = table.new Declaration( "N" );
+ IContainerSymbol nsN = table.newContainerSymbol( "N" );
nsN.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsN );
+ compUnit.addSymbol( nsN );
- ParserSymbolTable.Declaration nsN_i = table.new Declaration("i");
- nsN.addDeclaration( nsN_i );
+ ISymbol nsN_i = table.newSymbol("i");
+ nsN.addSymbol( nsN_i );
nsN.addUsingDirective( nsM );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
- compUnit.addDeclaration( f );
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
+ compUnit.addSymbol( f );
f.addUsingDirective( nsN );
- ParserSymbolTable.Declaration look = null;
+ ISymbol look = null;
try
{
look = f.Lookup( "i" );
@@ -685,7 +685,7 @@
}
look = f.LookupNestedNameSpecifier("N");
- look = look.QualifiedLookup("i"); //ok
+ look = ((IContainerSymbol) look).QualifiedLookup("i"); //ok
assertEquals( look, nsN_i );
}
@@ -716,38 +716,38 @@
{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration nsA = table.new Declaration("A");
+ IContainerSymbol nsA = table.newContainerSymbol("A");
nsA.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsA );
+ compUnit.addSymbol( nsA );
- ParserSymbolTable.Declaration a = table.new Declaration("a");
- nsA.addDeclaration( a );
+ ISymbol a = table.newSymbol("a");
+ nsA.addSymbol( a );
- ParserSymbolTable.Declaration nsB = table.new Declaration("B");
+ IContainerSymbol nsB = table.newContainerSymbol("B");
nsB.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsB );
+ compUnit.addSymbol( nsB );
nsB.addUsingDirective( nsA );
- ParserSymbolTable.Declaration nsC = table.new Declaration("C");
+ IContainerSymbol nsC = table.newContainerSymbol("C");
nsC.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsC );
+ compUnit.addSymbol( nsC );
nsC.addUsingDirective( nsA );
- ParserSymbolTable.Declaration nsBC = table.new Declaration("BC");
+ IContainerSymbol nsBC = table.newContainerSymbol("BC");
nsBC.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsBC );
+ compUnit.addSymbol( nsBC );
nsBC.addUsingDirective( nsB );
nsBC.addUsingDirective( nsC );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
f.setType(ParserSymbolTable.TypeInfo.t_function);
- compUnit.addDeclaration( f );
+ compUnit.addSymbol( f );
- ParserSymbolTable.Declaration look = f.LookupNestedNameSpecifier("BC");
+ ISymbol look = f.LookupNestedNameSpecifier("BC");
assertEquals( look, nsBC );
- look = look.QualifiedLookup("a");
+ look = ((IContainerSymbol)look).QualifiedLookup("a");
assertEquals( look, a );
}
@@ -777,37 +777,37 @@
{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration nsB = table.new Declaration( "B" );
+ IContainerSymbol nsB = table.newContainerSymbol( "B" );
nsB.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsB );
+ compUnit.addSymbol( nsB );
- ParserSymbolTable.Declaration b = table.new Declaration("b");
- nsB.addDeclaration( b );
+ ISymbol b = table.newSymbol("b");
+ nsB.addSymbol( b );
- ParserSymbolTable.Declaration nsA = table.new Declaration( "A" );
+ IContainerSymbol nsA = table.newContainerSymbol( "A" );
nsA.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsA );
+ compUnit.addSymbol( nsA );
nsA.addUsingDirective( nsB );
- ParserSymbolTable.Declaration a = table.new Declaration("a");
- nsA.addDeclaration( a );
+ ISymbol a = table.newSymbol("a");
+ nsA.addSymbol( a );
nsB.addUsingDirective( nsA );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
- compUnit.addDeclaration(f);
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
+ compUnit.addSymbol(f);
- ParserSymbolTable.Declaration lookA = f.LookupNestedNameSpecifier("A");
- ParserSymbolTable.Declaration look = lookA.QualifiedLookup("a");
+ IContainerSymbol lookA = f.LookupNestedNameSpecifier("A");
+ ISymbol look = lookA.QualifiedLookup("a");
assertEquals( look, a );
look = lookA.QualifiedLookup("b");
assertEquals( look, b );
- ParserSymbolTable.Declaration lookB = f.LookupNestedNameSpecifier("B");
+ IContainerSymbol lookB = f.LookupNestedNameSpecifier("B");
look = lookB.QualifiedLookup("a");
assertEquals( look, a );
@@ -840,25 +840,25 @@
{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration nsA = table.new Declaration( "A" );
+ IContainerSymbol nsA = table.newContainerSymbol( "A" );
nsA.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsA );
+ compUnit.addSymbol( nsA );
- ParserSymbolTable.Declaration nsB = table.new Declaration( "B" );
+ IContainerSymbol nsB = table.newContainerSymbol( "B" );
nsB.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsB );
+ compUnit.addSymbol( nsB );
nsB.addUsingDirective( nsA );
nsA.addUsingDirective( nsB );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
- compUnit.addDeclaration(f);
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
+ compUnit.addSymbol(f);
f.addUsingDirective(nsA);
f.addUsingDirective(nsB);
- ParserSymbolTable.Declaration look = f.Lookup("i");
+ ISymbol look = f.Lookup("i");
assertEquals( look, null );
}
@@ -889,49 +889,49 @@
public void testNamespaceMemberHiding() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration nsA = table.new Declaration("A");
+ IContainerSymbol nsA = table.newContainerSymbol("A");
nsA.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsA );
+ compUnit.addSymbol( nsA );
- ParserSymbolTable.Declaration structX = table.new Declaration("x");
+ IContainerSymbol structX = table.newContainerSymbol("x");
structX.setType( ParserSymbolTable.TypeInfo.t_struct );
- nsA.addDeclaration( structX );
+ nsA.addSymbol( structX );
- ParserSymbolTable.Declaration intX = table.new Declaration("x");
+ ISymbol intX = table.newSymbol("x");
intX.setType( ParserSymbolTable.TypeInfo.t_int );
- nsA.addDeclaration( intX );
+ nsA.addSymbol( intX );
- ParserSymbolTable.Declaration intY = table.new Declaration("y");
+ ISymbol intY = table.newSymbol("y");
intY.setType( ParserSymbolTable.TypeInfo.t_int );
- nsA.addDeclaration( intY );
+ nsA.addSymbol( intY );
- ParserSymbolTable.Declaration nsB = table.new Declaration("B");
+ IContainerSymbol nsB = table.newContainerSymbol("B");
nsB.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsB );
- ParserSymbolTable.Declaration structY = table.new Declaration("y");
+ compUnit.addSymbol( nsB );
+ IContainerSymbol structY = table.newContainerSymbol("y");
structY.setType( ParserSymbolTable.TypeInfo.t_struct );
- nsB.addDeclaration( structY );
+ nsB.addSymbol( structY );
- ParserSymbolTable.Declaration nsC = table.new Declaration("C");
+ IContainerSymbol nsC = table.newContainerSymbol("C");
nsC.setType( ParserSymbolTable.TypeInfo.t_namespace);
- compUnit.addDeclaration( nsC );
+ compUnit.addSymbol( nsC );
- ParserSymbolTable.Declaration look = nsC.Lookup("A");
+ ISymbol look = nsC.Lookup("A");
assertEquals( look, nsA );
- nsC.addUsingDirective( look );
+ nsC.addUsingDirective( nsA );
look = nsC.Lookup("B");
assertEquals( look, nsB );
- nsC.addUsingDirective( look );
+ nsC.addUsingDirective( nsB );
//lookup C::x
look = nsC.LookupNestedNameSpecifier("C");
assertEquals( look, nsC );
- look = look.QualifiedLookup( "x" );
+ look = ((IContainerSymbol)look).QualifiedLookup( "x" );
assertEquals( look, intX );
//lookup C::y
@@ -939,7 +939,7 @@
assertEquals( look, nsC );
try{
- look = look.QualifiedLookup( "y" );
+ look = ((IContainerSymbol)look).QualifiedLookup( "y" );
assertTrue(false);
} catch ( ParserSymbolTableException e ) {
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
@@ -963,26 +963,26 @@
public void testLookupMemberForDefinition() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration nsA = table.new Declaration( "A" );
+ IContainerSymbol nsA = table.newContainerSymbol( "A" );
nsA.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( nsA );
+ compUnit.addSymbol( nsA );
- ParserSymbolTable.Declaration nsB = table.new Declaration( "B" );
+ IContainerSymbol nsB = table.newContainerSymbol( "B" );
nsB.setType( ParserSymbolTable.TypeInfo.t_namespace );
- nsA.addDeclaration( nsB );
+ nsA.addSymbol( nsB );
- ParserSymbolTable.Declaration f1 = table.new Declaration("f1");
+ IParameterizedSymbol f1 = table.newParameterizedSymbol("f1");
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- nsB.addDeclaration( f1 );
+ nsB.addSymbol( f1 );
nsA.addUsingDirective( nsB );
- ParserSymbolTable.Declaration lookA = compUnit.LookupNestedNameSpecifier( "A" );
+ IContainerSymbol lookA = compUnit.LookupNestedNameSpecifier( "A" );
assertEquals( nsA, lookA );
- ParserSymbolTable.Declaration look = lookA.LookupMemberForDefinition( "f1" );
+ ISymbol look = lookA.LookupMemberForDefinition( "f1" );
assertEquals( look, null );
//but notice if you wanted to do A::f1 as a function call, it is ok
@@ -1017,45 +1017,45 @@
public void testUsingDeclaration() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration B = table.new Declaration("B");
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B");
B.setType( ParserSymbolTable.TypeInfo.t_struct );
- compUnit.addDeclaration( B );
+ compUnit.addSymbol( B );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
f.setType( ParserSymbolTable.TypeInfo.t_function );
- B.addDeclaration( f );
+ B.addSymbol( f );
- ParserSymbolTable.Declaration E = table.new Declaration( "E" );
+ IContainerSymbol E = table.newContainerSymbol( "E" );
E.setType( ParserSymbolTable.TypeInfo.t_enumeration );
- B.addDeclaration( E );
+ B.addSymbol( E );
- ParserSymbolTable.Declaration e = table.new Declaration( "e" );
+ ISymbol e = table.newSymbol( "e" );
e.setType( ParserSymbolTable.TypeInfo.t_enumerator );
- E.addDeclaration( e );
+ E.addSymbol( e );
/**
* TBD: Anonymous unions are not yet implemented
*/
- ParserSymbolTable.Declaration C = table.new Declaration( "C" );
+ IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C" );
C.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( C );
+ compUnit.addSymbol( C );
- ParserSymbolTable.Declaration g = table.new Declaration( "g" );
+ IParameterizedSymbol g = table.newParameterizedSymbol( "g" );
g.setType( ParserSymbolTable.TypeInfo.t_function );
- C.addDeclaration( g );
+ C.addSymbol( g );
- ParserSymbolTable.Declaration D = table.new Declaration( "D" );
+ IDerivableContainerSymbol D = table.newDerivableContainerSymbol( "D" );
D.setType( ParserSymbolTable.TypeInfo.t_struct );
- ParserSymbolTable.Declaration look = compUnit.Lookup( "B" );
+ ISymbol look = compUnit.Lookup( "B" );
assertEquals( look, B );
- D.addParent( look );
+ D.addParent( B );
- compUnit.addDeclaration( D );
+ compUnit.addSymbol( D );
- ParserSymbolTable.Declaration lookB = D.LookupNestedNameSpecifier("B");
+ IContainerSymbol lookB = D.LookupNestedNameSpecifier("B");
assertEquals( lookB, B );
D.addUsingDeclaration( "f", lookB );
@@ -1068,7 +1068,7 @@
assertEquals( look, C );
try{
- D.addUsingDeclaration( "g", look );
+ D.addUsingDeclaration( "g", C );
assertTrue( false );
}
catch ( ParserSymbolTableException exception ){
@@ -1103,49 +1103,49 @@
public void testUsingDeclaration_2() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
ParserSymbolTable.Declaration A = table.new Declaration( "A" );
A.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( A );
+ compUnit.addSymbol( A );
ParserSymbolTable.Declaration f1 = table.new Declaration( "f" );
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, "", false );
- A.addDeclaration( f1 );
+ f1.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, null, false );
+ A.addSymbol( f1 );
- ParserSymbolTable.Declaration look = compUnit.LookupNestedNameSpecifier("A");
+ ISymbol look = compUnit.LookupNestedNameSpecifier("A");
assertEquals( look, A );
- ParserSymbolTable.Declaration usingF = compUnit.addUsingDeclaration( "f", look );
+ IParameterizedSymbol usingF = (IParameterizedSymbol) compUnit.addUsingDeclaration( "f", A );
look = compUnit.Lookup("A");
assertEquals( look, A );
- ParserSymbolTable.Declaration f2 = table.new Declaration("f");
+ IParameterizedSymbol f2 = table.newParameterizedSymbol("f");
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f2.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, "", false );
+ f2.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f2.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, null, false );
- look.addDeclaration( f2 );
+ A.addSymbol( f2 );
- ParserSymbolTable.Declaration foo = table.new Declaration("foo");
+ IParameterizedSymbol foo = table.newParameterizedSymbol("foo");
foo.setType( ParserSymbolTable.TypeInfo.t_function );
- compUnit.addDeclaration( foo );
+ compUnit.addSymbol( foo );
LinkedList paramList = new LinkedList();
- ParserSymbolTable.TypeInfo param = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, null );
+ ParserSymbolTable.TypeInfo param = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, 0, null );
paramList.add( param );
look = foo.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, usingF );
- assertTrue( look.hasSameParameters( f1 ) );
+ assertTrue( usingF.hasSameParameters( f1 ) );
- ParserSymbolTable.Declaration bar = table.new Declaration( "bar" );
+ IParameterizedSymbol bar = table.newParameterizedSymbol( "bar" );
bar.setType( ParserSymbolTable.TypeInfo.t_function );
bar.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, null, false );
- compUnit.addDeclaration( bar );
+ compUnit.addSymbol( bar );
look = bar.LookupNestedNameSpecifier( "A" );
assertEquals( look, A );
@@ -1153,7 +1153,7 @@
look = bar.UnqualifiedFunctionLookup( "f", paramList );
assertTrue( look != null );
- assertTrue( look.hasSameParameters( f2 ) );
+ assertTrue( ((IParameterizedSymbol) look).hasSameParameters( f2 ) );
}
/**
@@ -1167,24 +1167,25 @@
public void testThisPointer() throws Exception{
newTable();
- ParserSymbolTable.Declaration cls = table.new Declaration("class");
+ IContainerSymbol cls = table.newContainerSymbol("class");
cls.setType( ParserSymbolTable.TypeInfo.t_class );
- ParserSymbolTable.Declaration fn = table.new Declaration("function");
+ IParameterizedSymbol fn = table.newParameterizedSymbol("function");
fn.setType( ParserSymbolTable.TypeInfo.t_function );
- fn.setCVQualifier( ParserSymbolTable.TypeInfo.cvConst );
+ fn.getTypeInfo().addPtrOperator( new PtrOp( PtrOp.t_undef, true, false ) );
+ //fn.setCVQualifier( ParserSymbolTable.TypeInfo.cvConst );
- table.getCompilationUnit().addDeclaration( cls );
- cls.addDeclaration( fn );
+ table.getCompilationUnit().addSymbol( cls );
+ cls.addSymbol( fn );
- ParserSymbolTable.Declaration look = fn.Lookup("this");
+ ISymbol look = fn.Lookup("this");
assertTrue( look != null );
assertEquals( look.getType(), ParserSymbolTable.TypeInfo.t_type );
- assertEquals( look.getTypeDeclaration(), cls );
- assertEquals( look.getPtrOperator(), "*" );
- assertEquals( look.getCVQualifier(), fn.getCVQualifier() );
- assertEquals( look.getContainingScope(), fn );
+ assertEquals( look.getTypeSymbol(), cls );
+ assertEquals( ((PtrOp)look.getPtrOperators().getFirst()).getType(), TypeInfo.PtrOp.t_pointer );
+ assertTrue( ((PtrOp)look.getPtrOperators().getFirst()).isConst() );
+ assertEquals( look.getContainingSymbol(), fn );
}
/**
@@ -1198,23 +1199,23 @@
public void testEnumerator() throws Exception{
newTable();
- ParserSymbolTable.Declaration cls = table.new Declaration("class");
+ IContainerSymbol cls = table.newContainerSymbol("class");
cls.setType( ParserSymbolTable.TypeInfo.t_class );
- ParserSymbolTable.Declaration enumeration = table.new Declaration("enumeration");
+ IContainerSymbol enumeration = table.newContainerSymbol("enumeration");
enumeration.setType( ParserSymbolTable.TypeInfo.t_enumeration );
- table.getCompilationUnit().addDeclaration( cls );
- cls.addDeclaration( enumeration );
+ table.getCompilationUnit().addSymbol( cls );
+ cls.addSymbol( enumeration );
- ParserSymbolTable.Declaration enumerator = table.new Declaration( "enumerator" );
+ ISymbol enumerator = table.newSymbol( "enumerator" );
enumerator.setType( ParserSymbolTable.TypeInfo.t_enumerator );
- enumeration.addDeclaration( enumerator );
+ enumeration.addSymbol( enumerator );
- ParserSymbolTable.Declaration look = cls.Lookup( "enumerator" );
+ ISymbol look = cls.Lookup( "enumerator" );
assertEquals( look, enumerator );
- assertEquals( look.getContainingScope(), cls );
- assertEquals( look.getTypeDeclaration(), enumeration );
+ assertEquals( look.getContainingSymbol(), cls );
+ assertEquals( look.getTypeSymbol(), enumeration );
}
/**
@@ -1233,47 +1234,47 @@
public void testArgumentDependentLookup() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration NS = table.new Declaration("NS");
+ IContainerSymbol NS = table.newContainerSymbol("NS");
NS.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( NS );
+ compUnit.addSymbol( NS );
- ParserSymbolTable.Declaration T = table.new Declaration("T");
+ IDerivableContainerSymbol T = table.newDerivableContainerSymbol("T");
T.setType( ParserSymbolTable.TypeInfo.t_class );
- NS.addDeclaration( T );
+ NS.addSymbol( T );
- ParserSymbolTable.Declaration f = table.new Declaration("f");
+ IParameterizedSymbol f = table.newParameterizedSymbol("f");
f.setType( ParserSymbolTable.TypeInfo.t_function );
- f.setReturnType( ParserSymbolTable.TypeInfo.t_void );
+ f.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
- ParserSymbolTable.Declaration look = NS.Lookup( "T" );
+ ISymbol look = NS.Lookup( "T" );
assertEquals( look, T );
- f.addParameter( look, 0, "", false );
+ f.addParameter( look, null, false );
- NS.addDeclaration( f );
+ NS.addSymbol( f );
look = compUnit.LookupNestedNameSpecifier( "NS" );
assertEquals( look, NS );
- look = look.QualifiedLookup( "T" );
+ look = NS.QualifiedLookup( "T" );
assertEquals( look, T );
- ParserSymbolTable.Declaration param = table.new Declaration("parm");
+ ISymbol param = table.newSymbol("parm");
param.setType( ParserSymbolTable.TypeInfo.t_type );
- param.setTypeDeclaration( look );
- compUnit.addDeclaration( param );
+ param.setTypeSymbol( look );
+ compUnit.addSymbol( param );
- ParserSymbolTable.Declaration main = table.new Declaration("main");
+ IParameterizedSymbol main = table.newParameterizedSymbol("main");
main.setType( ParserSymbolTable.TypeInfo.t_function );
- main.setReturnType( ParserSymbolTable.TypeInfo.t_int );
- compUnit.addDeclaration( main );
+ main.setReturnType( table.newSymbol( "", TypeInfo.t_int ) );
+ compUnit.addSymbol( main );
LinkedList paramList = new LinkedList();
look = main.Lookup( "parm" );
assertEquals( look, param );
- ParserSymbolTable.TypeInfo p = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, look, 0, null, false );
+ ParserSymbolTable.TypeInfo p = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, look );
paramList.add( p );
look = main.UnqualifiedFunctionLookup( "f", paramList );
@@ -1306,60 +1307,60 @@
public void testArgumentDependentLookup_2() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration NS1 = table.new Declaration( "NS1" );
+ IContainerSymbol NS1 = table.newContainerSymbol( "NS1" );
NS1.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( NS1 );
+ compUnit.addSymbol( NS1 );
ParserSymbolTable.Declaration f1 = table.new Declaration( "f" );
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f1.addParameter( ParserSymbolTable.TypeInfo.t_void, 0, "*", false );
- NS1.addDeclaration( f1 );
+ f1.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f1.addParameter( ParserSymbolTable.TypeInfo.t_void, 0, new PtrOp( PtrOp.t_pointer ), false );
+ NS1.addSymbol( f1 );
- ParserSymbolTable.Declaration NS2 = table.new Declaration( "NS2" );
+ IContainerSymbol NS2 = table.newContainerSymbol( "NS2" );
NS2.setType( ParserSymbolTable.TypeInfo.t_namespace );
- compUnit.addDeclaration( NS2 );
+ compUnit.addSymbol( NS2 );
- ParserSymbolTable.Declaration look = NS2.Lookup( "NS1" );
+ ISymbol look = NS2.Lookup( "NS1" );
assertEquals( look, NS1 );
- NS2.addUsingDirective( look );
+ NS2.addUsingDirective( NS1 );
- ParserSymbolTable.Declaration B = table.new Declaration( "B" );
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" );
B.setType( ParserSymbolTable.TypeInfo.t_class );
- NS2.addDeclaration( B );
+ NS2.addSymbol( B );
- ParserSymbolTable.Declaration f2 = table.new Declaration( "f" );
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" );
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f2.addParameter( ParserSymbolTable.TypeInfo.t_void, 0, "*", false );
- NS2.addDeclaration( f2 );
+ f2.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f2.addParameter( ParserSymbolTable.TypeInfo.t_void, 0, new PtrOp( PtrOp.t_pointer ), false );
+ NS2.addSymbol( f2 );
- ParserSymbolTable.Declaration A = table.new Declaration( "A" );
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" );
A.setType( ParserSymbolTable.TypeInfo.t_class );
look = compUnit.LookupNestedNameSpecifier( "NS2" );
assertEquals( look, NS2 );
look = NS2.QualifiedLookup( "B" );
assertEquals( look, B );
- A.addParent( look );
+ A.addParent( B );
- compUnit.addDeclaration( A );
+ compUnit.addSymbol( A );
look = compUnit.Lookup( "A" );
assertEquals( look, A );
- ParserSymbolTable.Declaration a = table.new Declaration( "a" );
+ ISymbol a = table.newSymbol( "a" );
a.setType( ParserSymbolTable.TypeInfo.t_type );
- a.setTypeDeclaration( look );
- compUnit.addDeclaration( a );
+ a.setTypeSymbol( look );
+ compUnit.addSymbol( a );
LinkedList paramList = new LinkedList();
look = compUnit.Lookup( "a" );
assertEquals( look, a );
- ParserSymbolTable.TypeInfo param = new ParserSymbolTable.TypeInfo( look.getType(), look, 0, "&", false );
+ ParserSymbolTable.TypeInfo param = new ParserSymbolTable.TypeInfo( look.getType(), 0, look, new PtrOp( PtrOp.t_reference ), false );
paramList.add( param );
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
@@ -1389,50 +1390,51 @@
public void testFunctionOverloading() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration C = table.new Declaration( "C" );
+ IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C" );
C.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration(C);
+ compUnit.addSymbol(C);
- ParserSymbolTable.Declaration f1 = table.new Declaration("foo");
+ IParameterizedSymbol f1 = table.newParameterizedSymbol("foo");
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, "", false );
- C.addDeclaration( f1 );
+ f1.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, null, false );
+ C.addSymbol( f1 );
- ParserSymbolTable.Declaration f2 = table.new Declaration("foo");
+ IParameterizedSymbol f2 = table.newParameterizedSymbol("foo");
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f2.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, "", false );
- f2.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, "", false );
- C.addDeclaration( f2 );
+ f2.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f2.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, null, false );
+ f2.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, null, false );
+ C.addSymbol( f2 );
- ParserSymbolTable.Declaration f3 = table.new Declaration("foo");
+ IParameterizedSymbol f3 = table.newParameterizedSymbol("foo");
f3.setType( ParserSymbolTable.TypeInfo.t_function );
- f3.setReturnType( ParserSymbolTable.TypeInfo.t_void );
- f3.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, "", false );
- f3.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, "", false );
- f3.addParameter( C, 0, "*", false );
- C.addDeclaration( f3 );
+ f3.setReturnType( table.newSymbol( "", TypeInfo.t_void ) );
+ f3.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, null, false );
+ f3.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, null, false );
+ f3.addParameter( C, new PtrOp( PtrOp.t_pointer ), false );
+ C.addSymbol( f3 );
- ParserSymbolTable.Declaration look = compUnit.Lookup("C");
+ ISymbol look = compUnit.Lookup("C");
assertEquals( look, C );
- ParserSymbolTable.Declaration c = table.new Declaration("c");
+ ISymbol c = table.newSymbol("c");
c.setType( ParserSymbolTable.TypeInfo.t_type );
- c.setTypeDeclaration( look );
- c.setPtrOperator( "*" );
- compUnit.addDeclaration( c );
+ c.setTypeSymbol( look );
+ c.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
+ compUnit.addSymbol( c );
look = compUnit.Lookup( "c" );
assertEquals( look, c );
- assertEquals( look.getTypeDeclaration(), C );
+ assertEquals( look.getTypeSymbol(), C );
LinkedList paramList = new LinkedList();
- ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_int, null, 0, "", false);
- ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, null, 0, "", false);
- ParserSymbolTable.TypeInfo p3 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, c, 0, "", false);
+
+ ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_int, 0, null );
+ ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, 0, null );
+ ParserSymbolTable.TypeInfo p3 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, c );
paramList.add( p1 );
look = C.MemberFunctionLookup( "foo", paramList );
@@ -1462,33 +1464,33 @@
public void testFunctionResolution() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration f1 = table.new Declaration("f");
+ IParameterizedSymbol f1 = table.newParameterizedSymbol("f");
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, "", false );
- compUnit.addDeclaration( f1 );
+ f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, null, false );
+ compUnit.addSymbol( f1 );
- ParserSymbolTable.Declaration f2 = table.new Declaration("f");
+ IParameterizedSymbol f2 = table.newParameterizedSymbol("f");
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, "", true );
- compUnit.addDeclaration( f2 );
+ f2.addParameter( ParserSymbolTable.TypeInfo.t_char, 0, null, true );
+ compUnit.addSymbol( f2 );
LinkedList paramList = new LinkedList();
- ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_int, null, 0, "", false );
+ ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_int, 0, null );
paramList.add( p1 );
- ParserSymbolTable.Declaration look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
+ ISymbol look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f1 );
paramList.clear();
- ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, null, 0, "", false );
+ ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, 0, null );
paramList.add( p2 );
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f2 );
paramList.clear();
- ParserSymbolTable.TypeInfo p3 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_bool, null, 0, "", false );
+ ParserSymbolTable.TypeInfo p3 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_bool, 0, null );
paramList.add( p3 );
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f1 );
@@ -1517,50 +1519,50 @@
public void testFunctionResolution_PointersAndBaseClasses() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration A = table.new Declaration( "A" );
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" );
A.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( A );
+ compUnit.addSymbol( A );
- ParserSymbolTable.Declaration B = table.new Declaration( "B" );
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" );
B.setType( ParserSymbolTable.TypeInfo.t_class );
B.addParent( A );
- compUnit.addDeclaration( B );
+ compUnit.addSymbol( B );
- ParserSymbolTable.Declaration C = table.new Declaration( "C" );
+ IDerivableContainerSymbol C = table.newDerivableContainerSymbol( "C" );
C.setType( ParserSymbolTable.TypeInfo.t_class );
C.addParent( B );
- compUnit.addDeclaration( C );
+ compUnit.addSymbol( C );
- ParserSymbolTable.Declaration f1 = table.new Declaration( "f" );
+ IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" );
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.addParameter( A, 0, "*", false );
- compUnit.addDeclaration( f1 );
+ f1.addParameter( A, new PtrOp( PtrOp.t_pointer ), false );
+ compUnit.addSymbol( f1 );
- ParserSymbolTable.Declaration f2 = table.new Declaration( "f" );
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" );
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.addParameter( B, 0, "*", false );
- compUnit.addDeclaration( f2 );
+ f2.addParameter( B, new PtrOp( PtrOp.t_pointer ), false );
+ compUnit.addSymbol( f2 );
- ParserSymbolTable.Declaration a = table.new Declaration( "a" );
+ ISymbol a = table.newSymbol( "a" );
a.setType( ParserSymbolTable.TypeInfo.t_type );
- a.setTypeDeclaration( A );
- a.setPtrOperator( "*" );
+ a.setTypeSymbol( A );
+ a.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
- ParserSymbolTable.Declaration c = table.new Declaration( "c" );
+ ISymbol c = table.newSymbol( "c" );
c.setType( ParserSymbolTable.TypeInfo.t_type );
- c.setTypeDeclaration( C );
- c.setPtrOperator( "*" );
+ c.setTypeSymbol( C );
+ c.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
LinkedList paramList = new LinkedList();
- ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, a, 0, null, false );
+ ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, a );
paramList.add( p1 );
- ParserSymbolTable.Declaration look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
+ ISymbol look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f1 );
paramList.clear();
- ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, c, 0, "", false );
+ ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, c );
paramList.add( p2 );
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f2 );
@@ -1589,65 +1591,65 @@
public void testFunctionResolution_TypedefsAndPointers() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration A = table.new Declaration( "A" );
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" );
A.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( A );
+ compUnit.addSymbol( A );
- ParserSymbolTable.Declaration B = table.new Declaration( "B" );
+ ISymbol B = table.newSymbol( "B" );
B.setType( ParserSymbolTable.TypeInfo.t_type );
- B.setTypeDeclaration( A );
- B.setPtrOperator( "*" );
- compUnit.addDeclaration( B );
+ B.setTypeSymbol( A );
+ B.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
+ compUnit.addSymbol( B );
- ParserSymbolTable.Declaration f1 = table.new Declaration( "f" );
+ IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" );
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.addParameter( A, 0, "*", false );
- compUnit.addDeclaration( f1 );
+ f1.addParameter( A, new PtrOp( PtrOp.t_pointer ), false );
+ compUnit.addSymbol( f1 );
- ParserSymbolTable.Declaration f2 = table.new Declaration( "f" );
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" );
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.addParameter( A, 0, null, false );
- compUnit.addDeclaration( f2 );
+ f2.addParameter( A, null, false );
+ compUnit.addSymbol( f2 );
- ParserSymbolTable.Declaration a = table.new Declaration( "a" );
+ ISymbol a = table.newSymbol( "a" );
a.setType( ParserSymbolTable.TypeInfo.t_type );
- a.setTypeDeclaration( A );
- compUnit.addDeclaration( a );
+ a.setTypeSymbol( A );
+ compUnit.addSymbol( a );
- ParserSymbolTable.Declaration b = table.new Declaration( "b" );
+ ISymbol b = table.newSymbol( "b" );
b.setType( ParserSymbolTable.TypeInfo.t_type );
- b.setTypeDeclaration( B );
- compUnit.addDeclaration( b );
+ b.setTypeSymbol( B );
+ compUnit.addSymbol( b );
- ParserSymbolTable.Declaration array = table.new Declaration( "array" );
+ ISymbol array = table.newSymbol( "array" );
array.setType( ParserSymbolTable.TypeInfo.t_type );
- array.setTypeDeclaration( A );
- array.setPtrOperator( "[]" );
+ array.setTypeSymbol( A );
+ array.addPtrOperator( new PtrOp( PtrOp.t_array, false, false ) );
LinkedList paramList = new LinkedList();
- ParserSymbolTable.TypeInfo p = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, a, 0, null, false );
+ ParserSymbolTable.TypeInfo p = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, a );
paramList.add( p );
- ParserSymbolTable.Declaration look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
+ ISymbol look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f2 );
- p.setPtrOperator( "&" );
+ p.addPtrOperator( new PtrOp( PtrOp.t_reference, false, false ) );
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f1 );
- p.setTypeDeclaration( b );
- p.setPtrOperator( null );
+ p.setTypeSymbol( b );
+ p.getPtrOperators().clear();
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f1 );
- p.setPtrOperator( "*" );
+ p.addPtrOperator( new PtrOp( PtrOp.t_pointer, false, false ) );
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f2 );
- p.setTypeDeclaration( array );
- p.setPtrOperator( null );
+ p.setTypeSymbol( array );
+ p.getPtrOperators().clear();
look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f1 );
@@ -1672,37 +1674,37 @@
public void testUserDefinedConversionSequences() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration A = table.new Declaration( "A" );
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" );
A.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( A );
+ compUnit.addSymbol( A );
- ParserSymbolTable.Declaration B = table.new Declaration( "B" );
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" );
B.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( B );
+ compUnit.addSymbol( B );
//12.1-1 "Constructors do not have names"
- ParserSymbolTable.Declaration constructor = table.new Declaration("");
+ IParameterizedSymbol constructor = table.newParameterizedSymbol("");
constructor.setType( ParserSymbolTable.TypeInfo.t_function );
- constructor.addParameter( A, 0, null, false );
- B.addDeclaration( constructor );
+ constructor.addParameter( A, null, false );
+ B.addSymbol( constructor );
- ParserSymbolTable.Declaration f = table.new Declaration( "f" );
+ IParameterizedSymbol f = table.newParameterizedSymbol( "f" );
f.setType( ParserSymbolTable.TypeInfo.t_function );
- f.addParameter( B, 0, null, false );
- compUnit.addDeclaration( f );
+ f.addParameter( B, null, false );
+ compUnit.addSymbol( f );
- ParserSymbolTable.Declaration a = table.new Declaration( "a" );
+ ISymbol a = table.newSymbol( "a" );
a.setType( ParserSymbolTable.TypeInfo.t_type );
- a.setTypeDeclaration( A );
- compUnit.addDeclaration( a );
+ a.setTypeSymbol( A );
+ compUnit.addSymbol( a );
LinkedList paramList = new LinkedList();
- ParserSymbolTable.TypeInfo p = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, a, 0, null, false );
+ ParserSymbolTable.TypeInfo p = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, a );
paramList.add( p );
- ParserSymbolTable.Declaration look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
+ ISymbol look = compUnit.UnqualifiedFunctionLookup( "f", paramList );
assertEquals( look, f );
}
@@ -1730,65 +1732,65 @@
public void testOverloadRanking() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration f1 = table.new Declaration( "f" );
+ IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" );
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.addParameter( ParserSymbolTable.TypeInfo.t_int, ParserSymbolTable.TypeInfo.cvConst, "*", false );
- f1.addParameter( ParserSymbolTable.TypeInfo.t_int | ParserSymbolTable.TypeInfo.isShort, 0, null, false );
+ f1.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, new PtrOp( PtrOp.t_pointer, true, false ), false );
+ f1.addParameter( ParserSymbolTable.TypeInfo.t_int, ParserSymbolTable.TypeInfo.isShort, null, false );
- compUnit.addDeclaration( f1 );
+ compUnit.addSymbol( f1 );
- ParserSymbolTable.Declaration f2 = table.new Declaration( "f" );
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" );
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, "*", false );
+ f2.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, new PtrOp( PtrOp.t_pointer ), false );
f2.addParameter( ParserSymbolTable.TypeInfo.t_int, 0, null, false );
- compUnit.addDeclaration( f2 );
+ compUnit.addSymbol( f2 );
- ParserSymbolTable.Declaration i = table.new Declaration( "i" );
+ ISymbol i = table.newSymbol( "i" );
i.setType( ParserSymbolTable.TypeInfo.t_int );
- compUnit.addDeclaration( i );
+ compUnit.addSymbol( i );
- ParserSymbolTable.Declaration s = table.new Declaration( "s" );
+ ISymbol s = table.newSymbol( "s" );
s.setType( ParserSymbolTable.TypeInfo.t_int );
s.getTypeInfo().setBit( true, ParserSymbolTable.TypeInfo.isShort );
- compUnit.addDeclaration( s );
+ compUnit.addSymbol( s );
- ParserSymbolTable.Declaration main = table.new Declaration( "main" );
+ IParameterizedSymbol main = table.newParameterizedSymbol( "main" );
main.setType( ParserSymbolTable.TypeInfo.t_function );
- compUnit.addDeclaration( main );
+ compUnit.addSymbol( main );
LinkedList params = new LinkedList();
- ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, i, 0, "&", false );
- ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, s, 0, null, false );
+ ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, i, new PtrOp( PtrOp.t_reference ), false );
+ ParserSymbolTable.TypeInfo p2 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, s );
params.add( p1 );
params.add( p2 );
- ParserSymbolTable.Declaration look = null;
+ ISymbol look = null;
try{
- main = main.UnqualifiedFunctionLookup( "f", params );
+ look = main.UnqualifiedFunctionLookup( "f", params );
assertTrue( false );
} catch ( ParserSymbolTableException e ){
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
}
params.clear();
- ParserSymbolTable.TypeInfo p3 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_int | ParserSymbolTable.TypeInfo.isLong, null, 0, null, false );
+ ParserSymbolTable.TypeInfo p3 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_int, ParserSymbolTable.TypeInfo.isLong, null );
params.add( p1 );
params.add( p3 );
look = main.UnqualifiedFunctionLookup( "f", params );
assertEquals( look, f2 );
params.clear();
- ParserSymbolTable.TypeInfo p4 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, null, 0, null, false );
+ ParserSymbolTable.TypeInfo p4 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_char, 0, null );
params.add( p1 );
params.add( p4 );
look = main.UnqualifiedFunctionLookup( "f", params );
assertEquals( look, f2 );
params.clear();
- p1.setCVQualifier( ParserSymbolTable.TypeInfo.cvConst );
+ ((PtrOp)p1.getPtrOperators().getFirst()).setConst( true );
params.add( p1 );
params.add( p3 );
look = main.UnqualifiedFunctionLookup( "f", params );
@@ -1823,40 +1825,40 @@
public void testUserDefinedConversionByOperator() throws Exception{
newTable();
- ParserSymbolTable.Declaration compUnit = table.getCompilationUnit();
+ IContainerSymbol compUnit = table.getCompilationUnit();
- ParserSymbolTable.Declaration B = table.new Declaration( "B" );
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B" );
B.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( B );
+ compUnit.addSymbol( B );
- ParserSymbolTable.Declaration A = table.new Declaration( "A" );
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A" );
A.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( A );
+ compUnit.addSymbol( A );
- ParserSymbolTable.Declaration constructA = table.new Declaration( "" );
+ IParameterizedSymbol constructA = table.newParameterizedSymbol( "" );
constructA.setType( ParserSymbolTable.TypeInfo.t_function );
- constructA.addParameter( B, 0, "&", false );
- A.addDeclaration( constructA );
+ constructA.addParameter( B, new PtrOp( PtrOp.t_reference ), false );
+ A.addSymbol( constructA );
- ParserSymbolTable.Declaration operator = table.new Declaration( "operator A" );
+ IParameterizedSymbol operator = table.newParameterizedSymbol( "operator A" );
operator.setType( ParserSymbolTable.TypeInfo.t_function );
- B.addDeclaration( operator );
+ B.addSymbol( operator );
- ParserSymbolTable.Declaration f1 = table.new Declaration( "f" );
+ IParameterizedSymbol f1 = table.newParameterizedSymbol( "f" );
f1.setType( ParserSymbolTable.TypeInfo.t_function );
- f1.addParameter( A, 0, null, false );
- compUnit.addDeclaration( f1 );
+ f1.addParameter( A, null, false );
+ compUnit.addSymbol( f1 );
- ParserSymbolTable.Declaration b = table.new Declaration( "b" );
+ ISymbol b = table.newSymbol( "b" );
b.setType( ParserSymbolTable.TypeInfo.t_type );
- b.setTypeDeclaration( B );
+ b.setTypeSymbol( B );
LinkedList params = new LinkedList();
- ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, b, 0, null, false );
+ ParserSymbolTable.TypeInfo p1 = new ParserSymbolTable.TypeInfo( ParserSymbolTable.TypeInfo.t_type, 0, b );
params.add( p1 );
- ParserSymbolTable.Declaration look = null;
+ ISymbol look = null;
try{
look = compUnit.UnqualifiedFunctionLookup( "f", params );
@@ -1865,19 +1867,19 @@
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
}
- ParserSymbolTable.Declaration C = table.new Declaration("C");
+ IDerivableContainerSymbol C = table.newDerivableContainerSymbol("C");
C.setType( ParserSymbolTable.TypeInfo.t_class );
- compUnit.addDeclaration( C );
+ compUnit.addSymbol( C );
- ParserSymbolTable.Declaration constructC = table.new Declaration("");
+ IParameterizedSymbol constructC = table.newParameterizedSymbol("");
constructC.setType( ParserSymbolTable.TypeInfo.t_function );
- constructC.addParameter( B, 0, "&", false );
- C.addDeclaration( constructC );
+ constructC.addParameter( B, new PtrOp( PtrOp.t_reference ), false );
+ C.addSymbol( constructC );
- ParserSymbolTable.Declaration f2 = table.new Declaration( "f" );
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f" );
f2.setType( ParserSymbolTable.TypeInfo.t_function );
- f2.addParameter( C, 0, null, false );
- compUnit.addDeclaration( f2 );
+ f2.addParameter( C, null, false );
+ compUnit.addSymbol( f2 );
try{
look = compUnit.UnqualifiedFunctionLookup( "f", params );
@@ -1886,13 +1888,448 @@
assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
}
- ParserSymbolTable.Declaration f3 = table.new Declaration( "f" );
+ IParameterizedSymbol f3 = table.newParameterizedSymbol( "f" );
f3.setType( ParserSymbolTable.TypeInfo.t_function );
- f3.addParameter( B, 0, null, false );
- compUnit.addDeclaration( f3 );
+ f3.addParameter( B, null, false );
+ compUnit.addSymbol( f3 );
look = compUnit.UnqualifiedFunctionLookup( "f", params );
assertEquals( look, f3 );
+ }
+
+ public void testMarkRollback() throws Exception{
+ newTable();
+
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol("A");
+ A.setType( TypeInfo.t_class );
+ table.getCompilationUnit().addSymbol( A );
+
+ Mark mark = table.setMark();
+
+ ISymbol f = table.newSymbol("f");
+ A.addSymbol( f );
+
+ ISymbol look = A.Lookup("f");
+ assertEquals( look, f );
+
+ assertTrue( table.rollBack( mark ) );
+
+ look = A.Lookup("f");
+ assertEquals( look, null );
+
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol("B");
+ B.setType( TypeInfo.t_class );
+
+ mark = table.setMark();
+ table.getCompilationUnit().addSymbol( B );
+ Mark mark2 = table.setMark();
+ A.addParent( B );
+ Mark mark3 = table.setMark();
+
+ IParameterizedSymbol C = table.newParameterizedSymbol("C");
+ C.addParameter( TypeInfo.t_class, 0, null, false );
+
+ assertEquals( C.getParameterList().size(), 1 );
+ table.rollBack( mark3 );
+ assertEquals( C.getParameterList().size(), 0 );
+ assertEquals( A.getParents().size(), 1 );
+ table.rollBack( mark2 );
+ assertEquals( A.getParents().size(), 0 );
+
+ assertFalse( table.commit( mark2 ) );
+ assertFalse( table.rollBack( mark2 ) );
+
+ B.setType( TypeInfo.t_namespace );
+
+ mark = table.setMark();
+ A.addUsingDirective( B );
+ assertEquals( A.getUsingDirectives().size(), 1 );
+ table.rollBack( mark );
+ assertEquals( A.getUsingDirectives().size(), 0 );
+ }
+
+ /**
+ *
+ * @throws Exception
+ *
+ * template < class T > class A : public T {};
+ *
+ * class B
+ * {
+ * int i;
+ * }
+ *
+ * A<B> a;
+ * a.i; //finds B::i;
+ */
+ public void testTemplateParameterAsParent() throws Exception{
+ newTable();
+
+ IParameterizedSymbol template = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol param = table.newSymbol( "T", TypeInfo.t_undef );
+ template.addParameter( param );
+
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ template.addSymbol( A );
+ A.addParent( param );
+
+ table.getCompilationUnit().addSymbol( template );
+
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class );
+ ISymbol i = table.newSymbol( "i", TypeInfo.t_int );
+ B.addSymbol( i );
+
+ TypeInfo type = new TypeInfo( TypeInfo.t_class, 0, B );
+ LinkedList args = new LinkedList();
+ args.add( type );
+
+ ParserSymbolTable.TemplateInstance instance = table.getCompilationUnit().TemplateLookup( "A", args );
+ assertEquals( instance.getInstantiatedSymbol(), A );
+
+ ISymbol a = table.newSymbol( "a", TypeInfo.t_type );
+ a.setTypeSymbol( instance );
+
+ table.getCompilationUnit().addSymbol( a );
+
+ ISymbol look = table.getCompilationUnit().Lookup( "a" );
+
+ assertEquals( look, a );
+
+ ISymbol symbol = a.getTypeSymbol();
+ assertEquals( symbol, instance );
+
+ look = ((IContainerSymbol)instance.getInstantiatedSymbol()).Lookup( "i" );
+ assertEquals( look, i );
+ }
+
+ /**
+ *
+ * @throws Exception
+ *
+ * template < class T > class A { T t; }
+ * class B : public A< int > { }
+ *
+ * B b;
+ * b.t; //finds A::t, will be type int
+ */
+ public void testTemplateInstanceAsParent() throws Exception{
+ newTable();
+
+ IParameterizedSymbol template = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol param = table.newSymbol( "T", TypeInfo.t_undef );
+ template.addParameter( param );
+
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ ISymbol t = table.newSymbol( "t", TypeInfo.t_type );
+
+ ISymbol look = template.Lookup( "T" );
+ assertEquals( look, param );
+
+ t.setTypeSymbol( param );
+
+ template.addSymbol( A );
+ A.addSymbol( t );
+ table.getCompilationUnit().addSymbol( template );
+
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class );
+
+ TypeInfo type = new TypeInfo( TypeInfo.t_int, 0 , null );
+ LinkedList args = new LinkedList();
+ args.add( type );
+
+ look = table.getCompilationUnit().TemplateLookup( "A", args );
+ assertTrue( look instanceof ParserSymbolTable.TemplateInstance );
+
+ B.addParent( look );
+ table.getCompilationUnit().addSymbol( B );
+
+ ISymbol b = table.newSymbol( "b", TypeInfo.t_type );
+ b.setTypeSymbol( B );
+ table.getCompilationUnit().addSymbol( b );
+
+ look = table.getCompilationUnit().Lookup( "b" );
+ assertEquals( look, b );
+
+ look = ((IDerivableContainerSymbol) b.getTypeSymbol()).Lookup( "t" );
+ assertTrue( look instanceof TemplateInstance );
+
+ TemplateInstance instance = (TemplateInstance) look;
+ assertEquals( instance.getInstantiatedSymbol(), t );
+ assertTrue( instance.isType( TypeInfo.t_int ) );
+
+ }
+
+ /**
+ * The scope of a template-parameter extends from its point of declaration
+ * until the end of its template. In particular, a template parameter can be used
+ * in the declaration of a subsequent template-parameter and its default arguments.
+ * @throws Exception
+ *
+ * template< class T, class U = T > class X
+ * {
+ * T t;
+ * U u;
+ * };
+ *
+ * X< char > x;
+ * x.t;
+ * x.u;
+ */
+ public void testTemplateParameterDefaults() throws Exception{
+ newTable();
+
+ IParameterizedSymbol template = table.newParameterizedSymbol( "X", TypeInfo.t_template );
+
+ ISymbol paramT = table.newSymbol( "T", TypeInfo.t_undef );
+ template.addParameter( paramT );
+
+ ISymbol look = template.Lookup( "T" );
+ assertEquals( look, paramT );
+ ISymbol paramU = table.newSymbol( "U", TypeInfo.t_undef );
+ paramU.getTypeInfo().setDefault( new TypeInfo( TypeInfo.t_type, 0, look ) );
+ template.addParameter( paramU );
+
+ IDerivableContainerSymbol X = table.newDerivableContainerSymbol( "X", TypeInfo.t_class );
+ template.addSymbol( X );
+
+ look = X.Lookup( "T" );
+ assertEquals( look, paramT );
+ ISymbol t = table.newSymbol( "t", TypeInfo.t_type );
+ t.setTypeSymbol( look );
+ X.addSymbol( t );
+
+ look = X.Lookup( "U" );
+ assertEquals( look, paramU );
+ ISymbol u = table.newSymbol( "u", TypeInfo.t_type );
+ u.setTypeSymbol( look );
+ X.addSymbol( u );
+
+ table.getCompilationUnit().addSymbol( template );
+
+ TypeInfo type = new TypeInfo( TypeInfo.t_char, 0, null );
+ LinkedList args = new LinkedList();
+ args.add( type );
+ look = table.getCompilationUnit().TemplateLookup( "X", args );
+ assertTrue( look instanceof TemplateInstance );
+
+ TemplateInstance instance = (TemplateInstance) look;
+ look = ((IDerivableContainerSymbol) instance.getInstantiatedSymbol()).Lookup( "t" );
+
+ assertTrue( look instanceof TemplateInstance );
+ assertTrue( ((TemplateInstance) look).isType( TypeInfo.t_char ) );
+
+ look = ((IDerivableContainerSymbol) instance.getInstantiatedSymbol()).Lookup( "u" );
+ assertTrue( look instanceof TemplateInstance );
+ assertTrue( ((TemplateInstance) look).isType( TypeInfo.t_char ) );
+ }
+
+ /**
+ *
+ * @throws Exception
+ * template < class T > class A {
+ * T t;
+ * };
+ * class B {};
+ * void f( char c ) {}
+ * void f( A<B> b ) { ... }
+ * void f( int i ) {}
+ *
+ * A<B> a;
+ * f( a ); //calls f( A<B> )
+ *
+ */
+ public void testTemplateParameterAsFunctionArgument() throws Exception{
+ newTable();
+
+ IParameterizedSymbol template = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol paramT = table.newSymbol( "T", TypeInfo.t_undef );
+ template.addParameter( paramT );
+
+ IDerivableContainerSymbol A = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ template.addSymbol( A );
+
+ ISymbol t = table.newSymbol( "t", TypeInfo.t_type );
+ t.setTypeSymbol( paramT );
+ A.addSymbol( t );
+
+ table.getCompilationUnit().addSymbol( template );
+
+ IDerivableContainerSymbol B = table.newDerivableContainerSymbol( "B", TypeInfo.t_class );
+ table.getCompilationUnit().addSymbol( B );
+
+ IParameterizedSymbol temp = (IParameterizedSymbol) table.getCompilationUnit().Lookup( "A" );
+ assertEquals( temp, template );
+
+ LinkedList args = new LinkedList();
+ TypeInfo arg = new TypeInfo( TypeInfo.t_type, 0, B );
+ args.add( arg );
+
+ IParameterizedSymbol f1 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
+ f1.addParameter( TypeInfo.t_char, 0, null, false );
+ table.getCompilationUnit().addSymbol( f1 );
+
+ IParameterizedSymbol f2 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
+ f2.addParameter( temp.instantiate( args ), null, false );
+ table.getCompilationUnit().addSymbol( f2 );
+
+ IParameterizedSymbol f3 = table.newParameterizedSymbol( "f", TypeInfo.t_function );
+ f3.addParameter( TypeInfo.t_int, 0, null, false );
+ table.getCompilationUnit().addSymbol( f3 );
+
+ ISymbol a = table.newSymbol( "a", TypeInfo.t_type );
+ a.setTypeSymbol( temp.instantiate( args ) );
+ table.getCompilationUnit().addSymbol( a );
+
+ LinkedList params = new LinkedList();
+ params.add( new TypeInfo( TypeInfo.t_type, 0, a ) );
+
+ ISymbol look = table.getCompilationUnit().UnqualifiedFunctionLookup( "f", params );
+ assertEquals( look, f2 );
+
+ }
+
+ /**
+ *
+ * template < class T1, class T2, int I > class A {} //#1
+ * template < class T, int I > class A < T, T*, I > {} //#2
+ * template < class T1, class T2, int I > class A < T1*, T2, I > {} //#3
+ * template < class T > class A < int, T*, 5 > {} //#4
+ * template < class T1, class T2, int I > class A < T1, T2*, I > {} //#5
+ *
+ * A <int, int, 1> a1; //uses #1
+ * A <int, int*, 1> a2; //uses #2, T is int, I is 1
+ * A <int, char*, 5> a3; //uses #4, T is char
+ * A <int, char*, 1> a4; //uses #5, T is int, T2 is char, I is1
+ * A <int*, int*, 2> a5; //ambiguous, matches #3 & #5.
+ *
+ * @throws Exception
+ */
+ public void incompletetestTemplateSpecialization() throws Exception{
+ newTable();
+
+ IDerivableContainerSymbol cls1 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ IDerivableContainerSymbol cls2 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ IDerivableContainerSymbol cls3 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ IDerivableContainerSymbol cls4 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+ IDerivableContainerSymbol cls5 = table.newDerivableContainerSymbol( "A", TypeInfo.t_class );
+
+ IParameterizedSymbol template1 = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol T1p1 = table.newSymbol( "T1", TypeInfo.t_undef );
+ ISymbol T1p2 = table.newSymbol( "T2", TypeInfo.t_undef );
+ ISymbol T1p3 = table.newSymbol( "I", TypeInfo.t_int );
+ template1.addParameter( T1p1 );
+ template1.addParameter( T1p2 );
+ template1.addParameter( T1p3 );
+ template1.addSymbol( cls1 );
+ table.getCompilationUnit().addSymbol( template1 );
+
+ IParameterizedSymbol template2 = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol T2p1 = table.newSymbol( "T", TypeInfo.t_undef );
+ ISymbol T2p2 = table.newSymbol( "I", TypeInfo.t_int );
+ template2.addParameter( T2p1 );
+ template2.addParameter( T2p2 );
+ ISymbol T2a1 = table.newSymbol( "T", TypeInfo.t_undef );
+ ISymbol T2a2 = table.newSymbol( "T", TypeInfo.t_undef );
+ T2a2.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
+ ISymbol T2a3 = table.newSymbol( "I", TypeInfo.t_int );
+ template2.addArgument( T2a1 );
+ template2.addArgument( T2a2 );
+ template2.addArgument( T2a3 );
+ template2.addSymbol( cls2 );
+ template1.addSpecialization( template2 );
+
+ IParameterizedSymbol template3 = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol T3p1 = table.newSymbol( "T1", TypeInfo.t_undef );
+ ISymbol T3p2 = table.newSymbol( "T2", TypeInfo.t_undef );
+ ISymbol T3p3 = table.newSymbol( "I", TypeInfo.t_int );
+ template3.addParameter( T3p1 );
+ template3.addParameter( T3p2 );
+ template3.addParameter( T3p3 );
+ ISymbol T3a1 = table.newSymbol( "T1", TypeInfo.t_undef );
+ T3a1.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
+ ISymbol T3a2 = table.newSymbol( "T2", TypeInfo.t_undef );
+ ISymbol T3a3 = table.newSymbol( "I", TypeInfo.t_int );
+ template3.addArgument( T3a1 );
+ template3.addArgument( T3a2 );
+ template3.addArgument( T3a3 );
+ template3.addSymbol( cls3 );
+ template1.addSpecialization( template3 );
+
+ IParameterizedSymbol template4 = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol T4p1 = table.newSymbol( "T", TypeInfo.t_undef );
+ template4.addParameter( T4p1 );
+
+ ISymbol T4a1 = table.newSymbol( "", TypeInfo.t_int );
+ ISymbol T4a2 = table.newSymbol( "T", TypeInfo.t_undef );
+ T4a2.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
+ ISymbol T4a3 = table.newSymbol( "", TypeInfo.t_int );
+ T4a3.getTypeInfo().setDefault( new Integer(5) );
+ template4.addArgument( T4a1 );
+ template4.addArgument( T4a2 );
+ template4.addArgument( T4a3 );
+ template4.addSymbol( cls4 );
+ template1.addSpecialization( template4 );
+
+ IParameterizedSymbol template5 = table.newParameterizedSymbol( "A", TypeInfo.t_template );
+ ISymbol T5p1 = table.newSymbol( "T1", TypeInfo.t_undef );
+ ISymbol T5p2 = table.newSymbol( "T2", TypeInfo.t_undef );
+ ISymbol T5p3 = table.newSymbol( "I", TypeInfo.t_int );
+ template5.addParameter( T5p1 );
+ template5.addParameter( T5p2 );
+ template5.addParameter( T5p3 );
+ ISymbol T5a1 = table.newSymbol( "T1", TypeInfo.t_undef );
+ ISymbol T5a2 = table.newSymbol( "T2", TypeInfo.t_undef );
+ T5a1.addPtrOperator( new PtrOp( PtrOp.t_pointer ) );
+ ISymbol T5a3 = table.newSymbol( "I", TypeInfo.t_int );
+ template5.addArgument( T5a1 );
+ template5.addArgument( T5a2 );
+ template5.addArgument( T5a3 );
+ template5.addSymbol( cls5 );
+ template1.addSpecialization( template5 );
+
+ IParameterizedSymbol a = (IParameterizedSymbol) table.getCompilationUnit().Lookup( "A" );
+
+ LinkedList args = new LinkedList();
+
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(1) ) );
+
+ TemplateInstance a1 = a.instantiate( args );
+ assertEquals( a1.getInstantiatedSymbol(), cls1 );
+
+ args.clear();
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(1) ) );
+
+ TemplateInstance a2 = a.instantiate( args );
+ assertEquals( a2.getInstantiatedSymbol(), cls2 );
+
+ args.clear();
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
+ args.add( new TypeInfo( TypeInfo.t_char, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(5) ) );
+ TemplateInstance a3 = a.instantiate( args );
+ assertEquals( a3.getInstantiatedSymbol(), cls4 );
+
+ args.clear();
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null ) );
+ args.add( new TypeInfo( TypeInfo.t_char, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(1) ) );
+ TemplateInstance a4 = a.instantiate( args );
+ assertEquals( a4.getInstantiatedSymbol(), cls5 );
+
+ args.clear();
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, new PtrOp( PtrOp.t_pointer ), false ) );
+ args.add( new TypeInfo( TypeInfo.t_int, 0, null, null, new Integer(2) ) );
+
+ try{
+ TemplateInstance a5 = a.instantiate( args );
+ } catch ( ParserSymbolTableException e ){
+ assertEquals( e.reason, ParserSymbolTableException.r_Ambiguous );
+ }
}
}
Index: parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java,v
retrieving revision 1.5
diff -u -r1.5 ParserTestSuite.java
--- parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java 10 Jun 2003 22:57:05 -0000 1.5
+++ parser/org/eclipse/cdt/core/parser/tests/ParserTestSuite.java 13 Jun 2003 14:59:58 -0000
@@ -15,6 +15,7 @@
import junit.framework.TestSuite;
import org.eclipse.cdt.core.model.tests.CModelElementsTests;
+import org.eclipse.cdt.core.parser.failedTests.*;
/**
* @author jcamelon
@@ -30,9 +31,7 @@
suite.addTestSuite(ExprEvalTest.class);
suite.addTestSuite(DOMTests.class);
suite.addTestSuite(ParserSymbolTableTest.class);
- suite.addTestSuite(LineNumberTest.class);
suite.addTestSuite(CModelElementsTests.class);
- suite.addTestSuite(CrossReferenceTests.class);
return suite;
}
Index: parser/org/eclipse/cdt/core/parser/tests/TortureTest.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui.tests/parser/org/eclipse/cdt/core/parser/tests/TortureTest.java,v
retrieving revision 1.1
diff -u -r1.1 TortureTest.java
--- parser/org/eclipse/cdt/core/parser/tests/TortureTest.java 11 Jun 2003 19:14:01 -0000 1.1
+++ parser/org/eclipse/cdt/core/parser/tests/TortureTest.java 13 Jun 2003 14:59:58 -0000
@@ -18,15 +18,13 @@
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
+import junit.framework.AssertionFailedError;
import junit.framework.Test;
-import org.eclipse.core.runtime.Path;
-
+import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
-import org.eclipse.cdt.internal.core.dom.DOMFactory;
-import org.eclipse.cdt.internal.core.parser.IParser;
import org.eclipse.cdt.internal.core.parser.Parser;
-import junit.framework.AssertionFailedError;
+import org.eclipse.core.runtime.Path;
/**
@@ -201,7 +199,7 @@
public void run(){
try {
- DOMBuilder domBuilder = DOMFactory.createDOMBuilder(true);
+ DOMBuilder domBuilder = new DOMBuilder();
parser = new Parser(code.toString(), domBuilder, quickParse);
parser.setCppNature(cppNature);
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.104
diff -u -r1.104 ChangeLog
--- ChangeLog 13 Jun 2003 02:44:02 -0000 1.104
+++ ChangeLog 13 Jun 2003 14:58:54 -0000
@@ -1,3 +1,6 @@
+2003-06-13 John Camelon
+ Merged ParserSymbolTable branch back into HEAD.
+
2003-06-12 Alain Magloire
Patch from Thomas Fletcher
@@ -112,6 +115,13 @@
Fixed the inclusion problem on May 28th
Fixed the non-cmodel selection problem May 30th.
+
+2003-05-06 John Camelon
+ Further integration of SymbolTable into Parser, some refactoring.
+
+ * src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java
+ moved some imports around.
+
2003-04-27 Alain Magloire
PR 36759, the outline does not update
Index: src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java,v
retrieving revision 1.3
diff -u -r1.3 ComparatorModelBuilder.java
--- src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java 26 Apr 2003 23:39:33 -0000 1.3
+++ src/org/eclipse/cdt/internal/ui/compare/ComparatorModelBuilder.java 13 Jun 2003 14:58:54 -0000
@@ -18,20 +18,19 @@
import org.eclipse.cdt.internal.core.dom.ClassKey;
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
-import org.eclipse.cdt.internal.core.dom.DOMFactory;
import org.eclipse.cdt.internal.core.dom.Declaration;
import org.eclipse.cdt.internal.core.dom.Declarator;
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
import org.eclipse.cdt.internal.core.dom.IOffsetable;
import org.eclipse.cdt.internal.core.dom.Inclusion;
import org.eclipse.cdt.internal.core.dom.Macro;
-import org.eclipse.cdt.internal.core.dom.Name;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
import org.eclipse.cdt.internal.core.dom.TemplateDeclaration;
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.cdt.internal.parser.IStructurizerCallback;
@@ -53,7 +52,7 @@
}
public void parse() {
- DOMBuilder domBuilder = DOMFactory.createDOMBuilder(false);
+ DOMBuilder domBuilder = new DOMBuilder();
try {
Parser parser = new Parser(code, domBuilder, true);
Index: dom/org/eclipse/cdt/internal/core/dom/BaseSpecifier.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/BaseSpecifier.java,v
retrieving revision 1.6
diff -u -r1.6 BaseSpecifier.java
--- dom/org/eclipse/cdt/internal/core/dom/BaseSpecifier.java 9 Apr 2003 21:11:59 -0000 1.6
+++ dom/org/eclipse/cdt/internal/core/dom/BaseSpecifier.java 13 Jun 2003 14:58:05 -0000
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.dom;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author dschaefe
Index: dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java,v
retrieving revision 1.10
diff -u -r1.10 ClassSpecifier.java
--- dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java 16 Apr 2003 12:30:47 -0000 1.10
+++ dom/org/eclipse/cdt/internal/core/dom/ClassSpecifier.java 13 Jun 2003 14:58:05 -0000
@@ -4,6 +4,7 @@
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Token;
public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable, IAccessable {
Index: dom/org/eclipse/cdt/internal/core/dom/ConstructorChainElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ConstructorChainElement.java,v
retrieving revision 1.2
diff -u -r1.2 ConstructorChainElement.java
--- dom/org/eclipse/cdt/internal/core/dom/ConstructorChainElement.java 9 Apr 2003 21:11:59 -0000 1.2
+++ dom/org/eclipse/cdt/internal/core/dom/ConstructorChainElement.java 13 Jun 2003 14:58:05 -0000
@@ -16,6 +16,8 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author jcamelon
Index: dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java,v
retrieving revision 1.32
diff -u -r1.32 DOMBuilder.java
--- dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java 5 Jun 2003 20:01:54 -0000 1.32
+++ dom/org/eclipse/cdt/internal/core/dom/DOMBuilder.java 13 Jun 2003 14:58:05 -0000
@@ -1,16 +1,39 @@
package org.eclipse.cdt.internal.core.dom;
-import org.eclipse.cdt.internal.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IProblem;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTConstructor;
+import org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
+import org.eclipse.cdt.core.parser.ast.IASTField;
+import org.eclipse.cdt.core.parser.ast.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTMacro;
+import org.eclipse.cdt.core.parser.ast.IASTMethod;
+import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
+import org.eclipse.cdt.core.parser.ast.IASTTypedef;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.internal.core.parser.IParserCallback;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Token;
/**
* This is the parser callback that creates objects in the DOM.
*/
-public class DOMBuilder implements IParserCallback
+public class DOMBuilder implements IParserCallback, ISourceElementRequestor
{
- protected DOMBuilder()
+ public DOMBuilder()
{
}
@@ -61,6 +84,7 @@
classSpecifier.setClassKeyToken( classKey );
decl.setTypeSpecifier(classSpecifier);
+ domScopes.push( classSpecifier );
return classSpecifier;
}
@@ -77,6 +101,7 @@
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
ClassSpecifier c = (ClassSpecifier)classSpecifier;
c.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - c.getStartingOffset() );
+ domScopes.pop();
}
/**
@@ -162,14 +187,15 @@
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#inclusionBegin(java.lang.String)
*/
public Object inclusionBegin(String includeFile, int offset, int inclusionBeginOffset, boolean local) {
- Inclusion inclusion = new Inclusion(
- includeFile,
- offset,
- inclusionBeginOffset,
- offset - inclusionBeginOffset + includeFile.length() + 1,
- local );
- translationUnit.addInclusion( inclusion );
- return inclusion;
+// Inclusion inclusion = new Inclusion(
+// includeFile,
+// offset,
+// inclusionBeginOffset,
+// offset - inclusionBeginOffset + includeFile.length() + 1,
+// local );
+// translationUnit.addInclusion( inclusion );
+// return inclusion;
+ return null;
}
/**
@@ -182,18 +208,18 @@
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#macro(java.lang.String)
*/
public Object macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
- Macro macro = new Macro( macroName, offset, macroBeginOffset, macroEndOffset - macroBeginOffset);
- translationUnit.addMacro( macro );
- return macro;
+// Macro macro = new Macro( macroName, offset, macroBeginOffset, macroEndOffset - macroBeginOffset);
+// translationUnit.addMacro( macro );
+ return null;
}
/**
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationBegin(org.eclipse.cdt.internal.core.newparser.Token)
*/
public Object simpleDeclarationBegin(Object container, Token firstToken) {
- SimpleDeclaration decl = new SimpleDeclaration((IScope)container);
- if( container instanceof IAccessable )
- decl.setAccessSpecifier(new AccessSpecifier( ((IAccessable)container).getVisibility() ));
+ SimpleDeclaration decl = new SimpleDeclaration( getCurrentDOMScope() );
+ if( getCurrentDOMScope() instanceof IAccessable )
+ decl.setAccessSpecifier(new AccessSpecifier( ((IAccessable)getCurrentDOMScope()).getVisibility() ));
((IOffsetable)decl).setStartingOffset( firstToken.getOffset() );
return decl;
}
@@ -205,7 +231,7 @@
SimpleDeclaration decl = (SimpleDeclaration)declaration;
IOffsetable offsetable = (IOffsetable)decl;
offsetable.setTotalLength( lastToken.getOffset() + lastToken.getLength() - offsetable.getStartingOffset());
- decl.getOwnerScope().addDeclaration(decl);
+ getCurrentDOMScope().addDeclaration(decl);
}
/**
@@ -321,6 +347,7 @@
public void classSpecifierAbort(Object classSpecifier) {
ClassSpecifier cs = (ClassSpecifier)classSpecifier;
cs.getOwner().setTypeSpecifier(null);
+ domScopes.pop();
}
/**
@@ -518,20 +545,20 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
*/
public Object namespaceDefinitionBegin(Object container, Token namespace) {
- IScope ownerScope = (IScope)container;
- NamespaceDefinition namespaceDef = new NamespaceDefinition(ownerScope);
- namespaceDef.setStartToken(namespace);
- ((IOffsetable)namespaceDef).setStartingOffset( namespace.getOffset() );
- return namespaceDef;
-
+// IScope ownerScope = (IScope)container;
+// NamespaceDefinition namespaceDef = new NamespaceDefinition(ownerScope);
+// namespaceDef.setStartToken(namespace);
+// ((IOffsetable)namespaceDef).setStartingOffset( namespace.getOffset() );
+// return namespaceDef;
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationId(java.lang.Object)
*/
public void namespaceDefinitionId(Object namespace) {
- NamespaceDefinition ns = (NamespaceDefinition)namespace;
- ns.setName( currName );
+// NamespaceDefinition ns = (NamespaceDefinition)namespace;
+// ns.setName( currName );
}
/* (non-Javadoc)
@@ -544,77 +571,80 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
*/
public void namespaceDefinitionEnd(Object namespace, Token closingBrace) {
- NamespaceDefinition ns = (NamespaceDefinition)namespace;
- ns.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - ns.getStartingOffset() );
- ns.getOwnerScope().addDeclaration(ns);
+// NamespaceDefinition ns = (NamespaceDefinition)namespace;
+// ns.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - ns.getStartingOffset() );
+// ns.getOwnerScope().addDeclaration(ns);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationBegin(java.lang.Object, java.lang.String)
*/
public Object linkageSpecificationBegin(Object container, String literal) {
- IScope scope = (IScope)container;
- LinkageSpecification linkage = new LinkageSpecification( scope, literal );
- return linkage;
+// IScope scope = (IScope)container;
+// LinkageSpecification linkage = new LinkageSpecification( scope, literal );
+// domScopes.push( linkage );
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#linkageSpecificationEnd(java.lang.Object)
*/
public void linkageSpecificationEnd(Object linkageSpec) {
- LinkageSpecification linkage = (LinkageSpecification)linkageSpec;
- linkage.getOwnerScope().addDeclaration(linkage );
+// LinkageSpecification linkage = (LinkageSpecification)domScopes.pop();
+// linkage.getOwnerScope().addDeclaration(linkage );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveBegin(java.lang.Object)
*/
public Object usingDirectiveBegin(Object container) {
- IScope scope = (IScope)container;
- UsingDirective directive = new UsingDirective( scope );
- return directive;
+// IScope scope = (IScope)container;
+// UsingDirective directive = new UsingDirective( scope );
+// return directive;
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveNamespaceId(java.lang.Object)
*/
public void usingDirectiveNamespaceId(Object dir) {
- UsingDirective directive = (UsingDirective)dir;
- directive.setNamespaceName( currName );
+// UsingDirective directive = (UsingDirective)dir;
+// directive.setNamespaceName( currName );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDirectiveEnd(java.lang.Object)
*/
public void usingDirectiveEnd(Object dir) {
- UsingDirective directive = (UsingDirective)dir;
- directive.getOwnerScope().addDeclaration( directive );
+// UsingDirective directive = (UsingDirective)dir;
+// directive.getOwnerScope().addDeclaration( directive );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationBegin(java.lang.Object)
*/
public Object usingDeclarationBegin(Object container) {
- IScope scope = (IScope)container;
- UsingDeclaration declaration = new UsingDeclaration( scope );
- return declaration;
+// IScope scope = (IScope)container;
+// UsingDeclaration declaration = new UsingDeclaration( scope );
+// return declaration;
+ return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationMapping(java.lang.Object)
*/
public void usingDeclarationMapping(Object decl, boolean isTypename) {
- UsingDeclaration declaration = (UsingDeclaration)decl;
- declaration.setMappedName( currName );
- declaration.setTypename( isTypename );
+// UsingDeclaration declaration = (UsingDeclaration)decl;
+// declaration.setMappedName( currName );
+// declaration.setTypename( isTypename );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#usingDeclarationEnd(java.lang.Object)
*/
public void usingDeclarationEnd(Object decl) {
- UsingDeclaration declaration = (UsingDeclaration)decl;
- declaration.getOwnerScope().addDeclaration( declaration );
+// UsingDeclaration declaration = (UsingDeclaration)decl;
+// declaration.getOwnerScope().addDeclaration( declaration );
}
/* (non-Javadoc)
@@ -696,9 +726,9 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#asmDefinition(java.lang.String)
*/
public void asmDefinition(Object container, String assemblyCode) {
- IScope scope = (IScope)container;
- ASMDefinition definition = new ASMDefinition( scope, assemblyCode );
- scope.addDeclaration( definition );
+// IScope scope = (IScope)container;
+// ASMDefinition definition = new ASMDefinition( scope, assemblyCode );
+// scope.addDeclaration( definition );
}
/* (non-Javadoc)
@@ -767,8 +797,8 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitInstantiationBegin(java.lang.Object)
*/
public Object explicitInstantiationBegin(Object container) {
- IScope scope = (IScope)container;
- ExplicitTemplateDeclaration etd = new ExplicitTemplateDeclaration( scope, ExplicitTemplateDeclaration.k_instantiation );
+ ExplicitTemplateDeclaration etd = new ExplicitTemplateDeclaration( getCurrentDOMScope(), ExplicitTemplateDeclaration.k_instantiation );
+ domScopes.push( etd );
return etd;
}
@@ -776,7 +806,7 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitInstantiationEnd(java.lang.Object)
*/
public void explicitInstantiationEnd(Object instantiation) {
- ExplicitTemplateDeclaration declaration = (ExplicitTemplateDeclaration)instantiation;
+ ExplicitTemplateDeclaration declaration = (ExplicitTemplateDeclaration)domScopes.pop();
declaration.getOwnerScope().addDeclaration(declaration);
}
@@ -784,8 +814,8 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitSpecializationBegin(java.lang.Object)
*/
public Object explicitSpecializationBegin(Object container) {
- IScope scope = (IScope)container;
- ExplicitTemplateDeclaration etd = new ExplicitTemplateDeclaration( scope, ExplicitTemplateDeclaration.k_specialization);
+ ExplicitTemplateDeclaration etd = new ExplicitTemplateDeclaration( getCurrentDOMScope(), ExplicitTemplateDeclaration.k_specialization);
+ domScopes.push( etd );
return etd;
}
@@ -793,7 +823,7 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#explicitSpecializationEnd(java.lang.Object)
*/
public void explicitSpecializationEnd(Object instantiation) {
- ExplicitTemplateDeclaration etd = (ExplicitTemplateDeclaration)instantiation;
+ ExplicitTemplateDeclaration etd = (ExplicitTemplateDeclaration)domScopes.pop();
etd.getOwnerScope().addDeclaration(etd);
}
@@ -809,10 +839,11 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationBegin(java.lang.Object, boolean)
*/
public Object templateDeclarationBegin(Object container, Token exported) {
- TemplateDeclaration d = new TemplateDeclaration( (IScope)container, exported );
- if( container instanceof IAccessable )
+ TemplateDeclaration d = new TemplateDeclaration( (IScope)getCurrentDOMScope(), exported );
+ if( getCurrentDOMScope() instanceof IAccessable )
d.setVisibility( ((IAccessable)container).getVisibility() );
d.setStartingOffset( exported.getOffset() );
+ domScopes.push( d );
return d;
}
@@ -820,14 +851,14 @@
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationAbort(java.lang.Object)
*/
public void templateDeclarationAbort(Object templateDecl) {
- templateDecl = null;
+ domScopes.pop();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#templateDeclarationEnd(java.lang.Object)
*/
public void templateDeclarationEnd(Object templateDecl, Token lastToken) {
- TemplateDeclaration decl = (TemplateDeclaration)templateDecl;
+ TemplateDeclaration decl = (TemplateDeclaration)domScopes.pop();
decl.setLastToken(lastToken);
decl.getOwnerScope().addDeclaration(decl);
decl.setTotalLength(lastToken.getOffset() + lastToken.getLength() - decl.getStartingOffset() );
@@ -950,5 +981,295 @@
// System.out.println( "Told you so!");
// }
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptProblem(org.eclipse.cdt.core.parser.IProblem)
+ */
+ public void acceptProblem(IProblem problem) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMacro(org.eclipse.cdt.core.parser.ast.IASTMacro)
+ */
+ public void acceptMacro(IASTMacro macro) {
+ Macro m = new Macro( macro.getName(), macro.getElementNameOffset(), macro.getElementStartingOffset(),
+ macro.getElementEndingOffset() - macro.getElementStartingOffset());
+ translationUnit.addMacro( m );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariable(org.eclipse.cdt.core.parser.ast.IASTVariable)
+ */
+ public void acceptVariable(IASTVariable variable) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionDeclaration(org.eclipse.cdt.core.parser.ast.IASTFunction)
+ */
+ public void acceptFunctionDeclaration(IASTFunction function) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsageDirective(org.eclipse.cdt.core.parser.ast.IASTUsageDirective)
+ */
+ public void acceptUsingDirective(IASTUsingDirective usageDirective) {
+ UsingDirective directive = new UsingDirective( getCurrentDOMScope() );
+ directive.setNamespaceName( usageDirective.getNamespaceName() );
+ directive.getOwnerScope().addDeclaration( directive );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptUsageDeclaration(org.eclipse.cdt.core.parser.ast.IASTUsageDeclaration)
+ */
+ public void acceptUsingDeclaration(IASTUsingDeclaration usageDeclaration) {
+ UsingDeclaration declaration = new UsingDeclaration( getCurrentDOMScope() );
+ declaration.setTypename( usageDeclaration.isTypename());
+ declaration.setMappedName(usageDeclaration.usingTypeName());
+ declaration.getOwnerScope().addDeclaration( declaration );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptASMDefinition(org.eclipse.cdt.core.parser.ast.IASTASMDefinition)
+ */
+ public void acceptASMDefinition(IASTASMDefinition asmDefinition) {
+ IScope scope = getCurrentDOMScope();
+ ASMDefinition definition = new ASMDefinition( scope, asmDefinition.getBody() );
+ scope.addDeclaration( definition );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptTypedef(org.eclipse.cdt.core.parser.ast.IASTTypedef)
+ */
+ public void acceptTypedef(IASTTypedef typedef) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier)
+ */
+ public void enterEnumSpecifier(IASTEnumSpecifier enumSpec) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerator(org.eclipse.cdt.core.parser.ast.IASTEnumerator)
+ */
+ public void acceptEnumerator(IASTEnumerator enumerator) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitEnumSpecifier(org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier)
+ */
+ public void exitEnumSpecifier(IASTEnumSpecifier enumSpec) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
+ */
+ public void enterFunctionBody(IASTFunction function) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitFunctionBody(org.eclipse.cdt.core.parser.ast.IASTFunction)
+ */
+ public void exitFunctionBody(IASTFunction function) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
+ */
+ public void enterCompilationUnit(IASTCompilationUnit compilationUnit) {
+ domScopes.push( translationUnit );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
+ */
+ public void enterInclusion(IASTInclusion inclusion) {
+ Inclusion i = new Inclusion(
+ inclusion.getName(),
+ inclusion.getElementNameOffset(),
+ inclusion.getElementStartingOffset(),
+ inclusion.getElementEndingOffset(),
+ inclusion.isLocal() );
+ translationUnit.addInclusion( i );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
+ */
+ public void enterNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
+ NamespaceDefinition namespaceDef = new NamespaceDefinition(getCurrentDOMScope());
+ namespaceDef.setName( namespaceDefinition.getName() );
+ ((IOffsetable)namespaceDef).setStartingOffset( namespaceDefinition.getElementStartingOffset() );
+ if( ! namespaceDefinition.getName().equals( "" ))
+ namespaceDef.setNameOffset( namespaceDefinition.getElementNameOffset() );
+ this.domScopes.push( namespaceDef );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecification)
+ */
+ public void enterClassSpecifier(IASTClassSpecifier classSpecification) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
+ */
+ public void enterLinkageSpecification(IASTLinkageSpecification linkageSpec) {
+ LinkageSpecification linkage = new LinkageSpecification( getCurrentDOMScope(), linkageSpec.getLinkageString() );
+ domScopes.push( linkage );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
+ */
+ public void enterTemplateDeclaration(IASTTemplateDeclaration declaration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
+ */
+ public void enterTemplateSpecialization(IASTTemplateSpecialization specialization) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
+ */
+ public void enterTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodDeclaration(org.eclipse.cdt.core.parser.ast.IASTMethod)
+ */
+ public void acceptMethodDeclaration(IASTMethod method) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#enterMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
+ */
+ public void enterMethodBody(IASTMethod method) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitMethodBody(org.eclipse.cdt.core.parser.ast.IASTMethod)
+ */
+ public void exitMethodBody(IASTMethod method) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptField(org.eclipse.cdt.core.parser.ast.IASTField)
+ */
+ public void acceptField(IASTField field) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptConstructor(org.eclipse.cdt.core.parser.ast.IASTConstructor)
+ */
+ public void acceptConstructor(IASTConstructor constructor) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateDeclaration(org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration)
+ */
+ public void exitTemplateDeclaration(IASTTemplateDeclaration declaration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateSpecialization(org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization)
+ */
+ public void exitTemplateSpecialization(IASTTemplateSpecialization specialization) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitTemplateExplicitInstantiation(org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation)
+ */
+ public void exitTemplateExplicitInstantiation(IASTTemplateInstantiation instantiation) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitLinkageSpecification(org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification)
+ */
+ public void exitLinkageSpecification(IASTLinkageSpecification linkageSpec) {
+ LinkageSpecification linkage = (LinkageSpecification)domScopes.pop();
+ getCurrentDOMScope().addDeclaration(linkage );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitClassSpecifier(org.eclipse.cdt.core.parser.ast.IASTClassSpecification)
+ */
+ public void exitClassSpecifier(IASTClassSpecifier classSpecification) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitNamespaceDefinition(org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition)
+ */
+ public void exitNamespaceDefinition(IASTNamespaceDefinition namespaceDefinition) {
+ NamespaceDefinition definition = (NamespaceDefinition)domScopes.pop();
+ definition.setTotalLength( namespaceDefinition.getElementEndingOffset() - namespaceDefinition.getElementStartingOffset());
+ getCurrentDOMScope().addDeclaration( definition );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitInclusion(org.eclipse.cdt.core.parser.ast.IASTInclusion)
+ */
+ public void exitInclusion(IASTInclusion inclusion) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#exitCompilationUnit(org.eclipse.cdt.core.parser.ast.IASTCompilationUnit)
+ */
+ public void exitCompilationUnit(IASTCompilationUnit compilationUnit) {
+ domScopes.pop();
+ }
+ private ScopeStack domScopes = new ScopeStack();
+
+ private IScope getCurrentDOMScope()
+ {
+ return domScopes.peek();
+ }
}
Index: dom/org/eclipse/cdt/internal/core/dom/DOMFactory.java
===================================================================
RCS file: dom/org/eclipse/cdt/internal/core/dom/DOMFactory.java
diff -N dom/org/eclipse/cdt/internal/core/dom/DOMFactory.java
--- dom/org/eclipse/cdt/internal/core/dom/DOMFactory.java 21 Apr 2003 18:34:39 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * 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 Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.core.dom;
-
-/**
- * @author jcamelon
- */
-public class DOMFactory {
-
- public static DOMBuilder createDOMBuilder( boolean lineNumbers )
- {
- if( lineNumbers )
- return new LineNumberedDOMBuilder();
- else
- return new DOMBuilder();
- }
-}
Index: dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java,v
retrieving revision 1.4
diff -u -r1.4 DeclSpecifier.java
--- dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java 24 Apr 2003 18:36:22 -0000 1.4
+++ dom/org/eclipse/cdt/internal/core/dom/DeclSpecifier.java 13 Jun 2003 14:58:05 -0000
@@ -2,6 +2,7 @@
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Token;
/**
Index: dom/org/eclipse/cdt/internal/core/dom/Declarator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Declarator.java,v
retrieving revision 1.12
diff -u -r1.12 Declarator.java
--- dom/org/eclipse/cdt/internal/core/dom/Declarator.java 25 Apr 2003 16:13:17 -0000 1.12
+++ dom/org/eclipse/cdt/internal/core/dom/Declarator.java 13 Jun 2003 14:58:06 -0000
@@ -4,6 +4,8 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
+
public class Declarator implements IExpressionOwner, IDeclaratorOwner {
Index: dom/org/eclipse/cdt/internal/core/dom/ElaboratedTypeSpecifier.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ElaboratedTypeSpecifier.java,v
retrieving revision 1.5
diff -u -r1.5 ElaboratedTypeSpecifier.java
--- dom/org/eclipse/cdt/internal/core/dom/ElaboratedTypeSpecifier.java 5 May 2003 20:31:08 -0000 1.5
+++ dom/org/eclipse/cdt/internal/core/dom/ElaboratedTypeSpecifier.java 13 Jun 2003 14:58:06 -0000
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.dom;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author jcamelon
Index: dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java,v
retrieving revision 1.8
diff -u -r1.8 EnumerationSpecifier.java
--- dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java 17 Apr 2003 13:41:43 -0000 1.8
+++ dom/org/eclipse/cdt/internal/core/dom/EnumerationSpecifier.java 13 Jun 2003 14:58:06 -0000
@@ -16,6 +16,7 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Token;
/**
Index: dom/org/eclipse/cdt/internal/core/dom/EnumeratorDefinition.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/EnumeratorDefinition.java,v
retrieving revision 1.5
diff -u -r1.5 EnumeratorDefinition.java
--- dom/org/eclipse/cdt/internal/core/dom/EnumeratorDefinition.java 16 Apr 2003 12:30:47 -0000 1.5
+++ dom/org/eclipse/cdt/internal/core/dom/EnumeratorDefinition.java 13 Jun 2003 14:58:06 -0000
@@ -12,6 +12,8 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.dom;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author jcamelon
Index: dom/org/eclipse/cdt/internal/core/dom/ExceptionSpecifier.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/ExceptionSpecifier.java,v
retrieving revision 1.2
diff -u -r1.2 ExceptionSpecifier.java
--- dom/org/eclipse/cdt/internal/core/dom/ExceptionSpecifier.java 9 Apr 2003 21:11:59 -0000 1.2
+++ dom/org/eclipse/cdt/internal/core/dom/ExceptionSpecifier.java 13 Jun 2003 14:58:06 -0000
@@ -16,6 +16,8 @@
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author jcamelon
Index: dom/org/eclipse/cdt/internal/core/dom/Expression.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/Expression.java,v
retrieving revision 1.4
diff -u -r1.4 Expression.java
--- dom/org/eclipse/cdt/internal/core/dom/Expression.java 22 Apr 2003 15:22:31 -0000 1.4
+++ dom/org/eclipse/cdt/internal/core/dom/Expression.java 13 Jun 2003 14:58:06 -0000
@@ -15,6 +15,7 @@
import java.util.Collections;
import java.util.List;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Token;
/**
Index: dom/org/eclipse/cdt/internal/core/dom/NamespaceDefinition.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/NamespaceDefinition.java,v
retrieving revision 1.8
diff -u -r1.8 NamespaceDefinition.java
--- dom/org/eclipse/cdt/internal/core/dom/NamespaceDefinition.java 24 Apr 2003 18:36:22 -0000 1.8
+++ dom/org/eclipse/cdt/internal/core/dom/NamespaceDefinition.java 13 Jun 2003 14:58:06 -0000
@@ -16,8 +16,6 @@
import java.util.LinkedList;
import java.util.List;
-import org.eclipse.cdt.internal.core.parser.Token;
-
/**
* @author jcamelon
*
@@ -25,8 +23,10 @@
public class NamespaceDefinition extends Declaration implements IScope {
private List declarations = new LinkedList();
- private Name name = null;
- private Token startToken = null;
+ private String name = "namespace";
+ int startingOffset = 0;
+ int nameOffset = 0;
+ int endOffset = 0;
public NamespaceDefinition( IScope owner )
{
@@ -52,7 +52,7 @@
/**
* @return String
*/
- public Name getName() {
+ public String getName() {
return name;
}
@@ -60,25 +60,44 @@
* Sets the name.
* @param name The name to set
*/
- public void setName(Name name) {
+ public void setName(String name) {
this.name = name;
}
+
+ public int getStartOffset()
+ {
+ return startingOffset;
+ }
+
+ public int getNameOffset()
+ {
+ return nameOffset;
+ }
+
+ public int getEndOffset()
+ {
+ return endOffset;
+ }
/**
- * Returns the startToken.
- * @return Token
+ * @param i
*/
- public Token getStartToken() {
- return startToken;
+ public void setEndOffset(int i) {
+ endOffset = i;
}
/**
- * Sets the startToken.
- * @param startToken The startToken to set
+ * @param i
*/
- public void setStartToken(Token startToken) {
- this.startToken = startToken;
+ public void setNameOffset(int i) {
+ nameOffset = i;
}
-
+ /**
+ * @param i
+ */
+ public void setStartingOffset(int i) {
+ startingOffset = i;
+ }
+
}
Index: dom/org/eclipse/cdt/internal/core/dom/ScopeStack.java
===================================================================
RCS file: dom/org/eclipse/cdt/internal/core/dom/ScopeStack.java
diff -N dom/org/eclipse/cdt/internal/core/dom/ScopeStack.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dom/org/eclipse/cdt/internal/core/dom/ScopeStack.java 13 Jun 2003 14:58:06 -0000
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.dom;
+
+import java.util.Stack;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ScopeStack {
+
+ public IScope peek()
+ {
+ return (IScope)scopes.peek();
+ }
+
+ public IScope pop()
+ {
+ return (IScope)scopes.pop();
+ }
+
+ public void push( IScope scope )
+ {
+ scopes.push( scope );
+ }
+
+ private Stack scopes = new Stack();
+
+}
Index: dom/org/eclipse/cdt/internal/core/dom/TemplateParameter.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/TemplateParameter.java,v
retrieving revision 1.4
diff -u -r1.4 TemplateParameter.java
--- dom/org/eclipse/cdt/internal/core/dom/TemplateParameter.java 13 Apr 2003 22:01:29 -0000 1.4
+++ dom/org/eclipse/cdt/internal/core/dom/TemplateParameter.java 13 Jun 2003 14:58:06 -0000
@@ -12,6 +12,8 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.dom;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author jcamelon
Index: dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java,v
retrieving revision 1.3
diff -u -r1.3 UsingDeclaration.java
--- dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java 13 Apr 2003 22:01:29 -0000 1.3
+++ dom/org/eclipse/cdt/internal/core/dom/UsingDeclaration.java 13 Jun 2003 14:58:06 -0000
@@ -13,13 +13,14 @@
package org.eclipse.cdt.internal.core.dom;
+
/**
* @author jcamelon
*
*/
public class UsingDeclaration extends Declaration {
- private Name mappedName;
+ private String mappedName;
boolean isTypename = false;
public UsingDeclaration( IScope owner )
@@ -29,7 +30,7 @@
/**
* @return String
*/
- public Name getMappedName() {
+ public String getMappedName() {
return mappedName;
}
@@ -37,7 +38,7 @@
* Sets the mapping.
* @param mapping The mapping to set
*/
- public void setMappedName(Name mapping) {
+ public void setMappedName(String mapping) {
this.mappedName = mapping;
}
Index: dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java,v
retrieving revision 1.3
diff -u -r1.3 UsingDirective.java
--- dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java 13 Apr 2003 22:01:29 -0000 1.3
+++ dom/org/eclipse/cdt/internal/core/dom/UsingDirective.java 13 Jun 2003 14:58:06 -0000
@@ -12,6 +12,8 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.dom;
+import org.eclipse.cdt.internal.core.parser.Name;
+
/**
* @author jcamelon
@@ -19,7 +21,7 @@
*/
public class UsingDirective extends Declaration {
- private Name namespaceName;
+ private String namespaceName;
public UsingDirective( IScope owner )
{
@@ -29,7 +31,7 @@
/**
* @return String
*/
- public Name getNamespaceName() {
+ public String getNamespaceName() {
return namespaceName;
}
@@ -37,7 +39,7 @@
* Sets the namespaceName.
* @param namespaceName The namespaceName to set
*/
- public void setNamespaceName(Name namespaceName) {
+ public void setNamespaceName(String namespaceName) {
this.namespaceName = namespaceName;
}
}
Index: model/org/eclipse/cdt/core/model/ICElement.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ICElement.java,v
retrieving revision 1.11
diff -u -r1.11 ICElement.java
--- model/org/eclipse/cdt/core/model/ICElement.java 28 May 2003 18:10:08 -0000 1.11
+++ model/org/eclipse/cdt/core/model/ICElement.java 13 Jun 2003 14:58:06 -0000
@@ -6,8 +6,8 @@
*/
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
/**
* Common protocol for all elements provided by the C model.
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.54
diff -u -r1.54 ChangeLog
--- parser/ChangeLog 10 Jun 2003 14:41:40 -0000 1.54
+++ parser/ChangeLog 13 Jun 2003 14:58:06 -0000
@@ -1,3 +1,22 @@
+2003-06-13 John Camelon
+ Merged ParserSymbolTable branch back into HEAD.
+
+2003-06-12 John Camelon
+ Get rest of JUnit tests working, will merge back to HEAD branch.
+
+2003-06-12 John Camelon
+ Introduction of ASTFactory strategy, some restructuring of packages and interfaces.
+
+2003-06-10 John Camelon
+ Futher pursuit of the golden hammer, symbol table integration.
+
+2003-06-09 John Camelon
+ First step in replacing IParserCallback with ISourceElementRequestor.
+
+2003-06-05 Andrew Niefer
+ Begin implementation of functions for template specializations: deduceTemplateArgument,
+ classTemplateSpecializationToFunctionTemplate, transformFunctionTemplateForOrdering
+
2003-06-09 Victor Mozgin
Fixed for conversion operator declarations.
This fixes PR 36769 (finally) and PR 38657.
@@ -19,6 +38,31 @@
2003-06-05 John Camelon
Fix Bug 38380 "Include" class public methods fails JUnit tests
+
+2003-05-29 Andrew Niefer
+ new Class eType for stronger type safety in TypeInfo
+ new class PtrOp for better handling of pointer operators and cv qualifiers
+ new class TemplateInstance to support templates
+ Start of implementation for templates & specializations
+
+2003-05-29 John Camelon
+ Remove all AST components.
+
+2003-05-26 John Camelon
+ Rollback PST/Parser integration.
+
+2003-05-13 Andrew Niefer
+ Moved symbol table to org.eclipse.cdt.internal.core.pst
+ Created interface for symbol table: ISymbol, IContainerSymbol, IDerivableContainerSymbol,
+ IParameterizedSymbol, and ISpecializedSymbol. These are all implemented by Declaration
+ The symbol table itself uses this interface instead of using its Declaration directly
+ (with the exception of the undo command framework)
+
+2003-05-08 Andrew Niefer
+ Added a basic command structure to support rollbacks
+
+2003-05-06 John Camelon
+ Further integration of SymbolTable into Parser, some refactoring.
2003-05-05 John Camelon/Andrew Niefer
Added Symboltable infrastructure into main parser.
Index: parser/org/eclipse/cdt/core/parser/IParser.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/IParser.java
diff -N parser/org/eclipse/cdt/core/parser/IParser.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/IParser.java 13 Jun 2003 14:58:06 -0000
@@ -0,0 +1,88 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser;
+
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+
+
+/**
+ * This is the external interface that all C and C++ parsers in the CDT
+ * must implement.
+ *
+ * @author jcamelon
+ */
+public interface IParser {
+
+
+ /**
+ * Request a parse from a pre-configured parser to parse a whole translation unit or file.
+ *
+ * @return whether or not the parse was successful
+ */
+ public boolean parse();
+
+
+ /**
+ * Request a parse from a pre-configured parser to parse an expression.
+ *
+ * @param expression Optional parameter representing an expression object that
+ * your particular IParserCallback instance would appreciate
+ *
+ * @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid
+ * expression
+ */
+ public void expression(Object expression) throws Backtrack;
+
+ /**
+ * Is the parser configured for ANSI C or ANSI C++?
+ *
+ * @return true for C++, false for C
+ */
+ public boolean isCppNature();
+
+ /**
+ * Set the Parser explicitly to be a C or C++ parser.
+ *
+ * @param b true for C++, false for C
+ */
+ public void setCppNature(boolean b);
+
+ /**
+ * Do we wish to keep track of the lineNumbers/Offset mapping?
+ *
+ * By default, the value is false. Setting it to true impacts performance but
+ * provides that feature.
+ *
+ * @param value true for the feature, false for improved performance
+ */
+ public void mapLineNumbers( boolean value );
+
+ /**
+ * Given an character offset into the file, return the lineNumber this offset maps to.
+ *
+ * @param offset character offset in the file
+ * @return lineNumber this offset maps to
+ * @throws NoSuchMethodException if mapLineNumbers( true ) was not previously called
+ */
+ public int getLineNumberForOffset(int offset) throws NoSuchMethodException;
+
+ /**
+ * If an error was encountered, give us the offset of the token that caused the error.
+ *
+ * @return -1 for no error, otherwise the character offset where we encountered
+ * our first unrecoverable error.
+ */
+ public int getLastErrorOffset();
+
+
+ public void setRequestor( ISourceElementRequestor r );
+
+}
\ No newline at end of file
Index: parser/org/eclipse/cdt/core/parser/IProblem.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/IProblem.java
diff -N parser/org/eclipse/cdt/core/parser/IProblem.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/IProblem.java 13 Jun 2003 14:58:06 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IProblem {
+
+}
Index: parser/org/eclipse/cdt/core/parser/IScanner.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/IScanner.java
diff -N parser/org/eclipse/cdt/core/parser/IScanner.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/IScanner.java 13 Jun 2003 14:58:06 -0000
@@ -0,0 +1,40 @@
+package org.eclipse.cdt.core.parser;
+
+import java.io.Reader;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.IMacroDescriptor;
+import org.eclipse.cdt.internal.core.parser.IParserCallback;
+import org.eclipse.cdt.internal.core.parser.Parser;
+import org.eclipse.cdt.internal.core.parser.ScannerException;
+import org.eclipse.cdt.internal.core.parser.Token;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IScanner {
+
+ public static final int tPOUNDPOUND = -6;
+ public static final int tPOUND = -7;
+
+ public IScanner initialize( Reader sourceToBeRead, String fileName );
+
+ public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
+ public void addDefinition(String key, String value);
+ public Object getDefinition(String key);
+
+ public Object[] getIncludePaths();
+ public void addIncludePath(String includePath);
+ public void overwriteIncludePath( List newIncludePaths );
+
+ public Token nextToken() throws ScannerException, Parser.EndOfFile;
+ public int getLineNumberForOffset(int offset) throws NoSuchMethodException;
+ public void setCppNature( boolean value );
+ public void mapLineNumbers( boolean value );
+ public void setQuickScan(boolean qs);
+ public void setCallback(IParserCallback c);
+ public void setRequestor( ISourceElementRequestor r );
+ public void setASTFactory( IASTFactory f );
+}
Index: parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java
diff -N parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ISourceElementRequestor.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,82 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser;
+
+import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTConstructor;
+import org.eclipse.cdt.core.parser.ast.IASTEnumSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
+import org.eclipse.cdt.core.parser.ast.IASTField;
+import org.eclipse.cdt.core.parser.ast.IASTFunction;
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTMacro;
+import org.eclipse.cdt.core.parser.ast.IASTMethod;
+import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateSpecialization;
+import org.eclipse.cdt.core.parser.ast.IASTTypedef;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.core.parser.ast.IASTVariable;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface ISourceElementRequestor {
+
+ public void acceptProblem( IProblem problem );
+
+ public void acceptMacro( IASTMacro macro );
+ public void acceptVariable( IASTVariable variable );
+ public void acceptFunctionDeclaration( IASTFunction function );
+ public void acceptUsingDirective( IASTUsingDirective usageDirective );
+ public void acceptUsingDeclaration( IASTUsingDeclaration usageDeclaration );
+ public void acceptASMDefinition( IASTASMDefinition asmDefinition );
+ public void acceptTypedef( IASTTypedef typedef );
+
+ public void enterEnumSpecifier( IASTEnumSpecifier enumSpec );
+ public void acceptEnumerator( IASTEnumerator enumerator );
+ public void exitEnumSpecifier( IASTEnumSpecifier enumSpec );
+
+ public void enterFunctionBody( IASTFunction function );
+ public void exitFunctionBody( IASTFunction function );
+
+ public void enterCompilationUnit( IASTCompilationUnit compilationUnit );
+ public void enterInclusion( IASTInclusion inclusion );
+ public void enterNamespaceDefinition( IASTNamespaceDefinition namespaceDefinition );
+ public void enterClassSpecifier( IASTClassSpecifier classSpecification );
+ public void enterLinkageSpecification( IASTLinkageSpecification linkageSpec );
+
+ public void enterTemplateDeclaration( IASTTemplateDeclaration declaration );
+ public void enterTemplateSpecialization( IASTTemplateSpecialization specialization );
+ public void enterTemplateExplicitInstantiation( IASTTemplateInstantiation instantiation );
+
+ public void acceptMethodDeclaration( IASTMethod method );
+ public void enterMethodBody( IASTMethod method );
+ public void exitMethodBody( IASTMethod method );
+ public void acceptField( IASTField field );
+ public void acceptConstructor( IASTConstructor constructor );
+
+ public void exitTemplateDeclaration( IASTTemplateDeclaration declaration );
+ public void exitTemplateSpecialization( IASTTemplateSpecialization specialization );
+ public void exitTemplateExplicitInstantiation( IASTTemplateInstantiation instantiation );
+
+ public void exitLinkageSpecification( IASTLinkageSpecification linkageSpec );
+ public void exitClassSpecifier( IASTClassSpecifier classSpecification );
+ public void exitNamespaceDefinition( IASTNamespaceDefinition namespaceDefinition );
+ public void exitInclusion( IASTInclusion inclusion );
+ public void exitCompilationUnit( IASTCompilationUnit compilationUnit );
+}
Index: parser/org/eclipse/cdt/core/parser/ast/AccessVisibility.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/AccessVisibility.java
diff -N parser/org/eclipse/cdt/core/parser/ast/AccessVisibility.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/AccessVisibility.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,29 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class AccessVisibility {
+
+ public static final AccessVisibility v_public = new AccessVisibility( 1 );
+ public static final AccessVisibility v_protected = new AccessVisibility( 2 );
+ public static final AccessVisibility v_private = new AccessVisibility( 3 );
+
+ private AccessVisibility( int constant)
+ {
+ value = constant;
+ }
+
+ private final int value;
+}
Index: parser/org/eclipse/cdt/core/parser/ast/ClassKind.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/ClassKind.java
diff -N parser/org/eclipse/cdt/core/parser/ast/ClassKind.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/ClassKind.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ClassKind {
+
+ public final static ClassKind k_class = new ClassKind( 1 );
+ public final static ClassKind k_struct = new ClassKind( 2 );
+ public final static ClassKind k_union = new ClassKind( 3 );
+
+ private ClassKind( int value )
+ {
+ this.value = value;
+ }
+
+ private final int value;
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/ClassNameType.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/ClassNameType.java
diff -N parser/org/eclipse/cdt/core/parser/ast/ClassNameType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/ClassNameType.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,27 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ClassNameType {
+
+ public static final ClassNameType t_identifier = new ClassNameType( 1 );
+ public static final ClassNameType t_template = new ClassNameType( 2 );
+
+ private final int type;
+ private ClassNameType( int t )
+ {
+ type = t;
+ }
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTASMDefinition.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTASMDefinition extends IASTOffsetableElement, IASTDeclaration {
+
+ public String getBody();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTBaseSpecifier.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTBaseSpecifier.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTBaseSpecifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTBaseSpecifier.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,24 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTBaseSpecifier {
+
+ public AccessVisibility getAccess();
+ public boolean isVirtual();
+ public IASTClassSpecifier getParent();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTClassSpecifier.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,27 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+import java.util.Iterator;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTClassSpecifier extends IASTScope, IASTOffsetableNamedElement, IASTTemplatedDeclaration {
+
+ public ClassNameType getClassNameType();
+
+ public ClassKind getClassKind();
+
+ public Iterator getBaseClauses();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTCompilationUnit.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTCompilationUnit.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTCompilationUnit.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTCompilationUnit.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTCompilationUnit extends IASTScope {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTConstructor.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTConstructor.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTConstructor.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTConstructor.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTConstructor {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTDeclaration.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTDeclaration.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTDeclaration {
+
+ IASTScope getOwnerScope();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTEnumSpecifier.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTEnumSpecifier {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTEnumerator.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTEnumerator {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFactory.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,51 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+import org.eclipse.cdt.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFactory {
+
+ public IASTMacro createMacro( String name, int startingOffset, int endingOffset, int nameOffset );
+ public IASTInclusion createInclusion( String name, String fileName, boolean local, int startingOffset, int endingOffset, int nameOffset );
+
+ public IASTUsingDirective createUsingDirective(
+ IASTScope scope,
+ TokenDuple duple)
+ throws Backtrack;
+
+ public IASTUsingDeclaration createUsingDeclaration(
+ IASTScope scope,
+ boolean isTypeName,
+ TokenDuple name );
+
+
+ public IASTASMDefinition createASMDefinition(
+ IASTScope scope,
+ String assembly,
+ int first,
+ int last);
+
+ public IASTNamespaceDefinition createNamespaceDefinition(
+ IASTScope scope,
+ String identifier,
+ int startingOffset, int nameOffset);
+
+ public IASTCompilationUnit createCompilationUnit();
+
+ public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec);
+
+}
\ No newline at end of file
Index: parser/org/eclipse/cdt/core/parser/ast/IASTField.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTField.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTField.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTField.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTField {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTFunction.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFunction {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTInclusion.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTInclusion.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTInclusion.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTInclusion.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,26 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTInclusion extends IASTOffsetableNamedElement {
+
+ public String getName();
+
+ public String getFullFileName();
+
+ public boolean isLocal();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTLinkageSpecification.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTLinkageSpecification extends IASTScope, IASTDeclaration {
+
+ public String getLinkageString();
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTMacro.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTMacro.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTMacro.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTMacro.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTMacro extends IASTOffsetableNamedElement {
+
+ public String getName();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTMethod.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTMethod {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTNamespaceDefinition.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTNamespaceDefinition extends IASTOffsetableNamedElement, IASTScope, IASTDeclaration {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableElement.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableElement.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableElement.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableElement.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,26 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTOffsetableElement {
+
+ public void setStartingOffset( int o );
+ public void setEndingOffset( int o );
+
+ public int getElementStartingOffset();
+ public int getElementEndingOffset();
+
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableNamedElement.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableNamedElement.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableNamedElement.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTOffsetableNamedElement.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,23 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTOffsetableNamedElement extends IASTOffsetableElement {
+
+ public String getName();
+ public int getElementNameOffset();
+ public void setNameOffset( int o );
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTScope.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTScope.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTScope.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTScope.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,22 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+import java.util.Iterator;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTScope {
+
+ public Iterator getDeclarations();
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTemplateDeclaration.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,24 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+import java.util.Iterator;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTemplateDeclaration {
+
+ public TemplateDeclarationType getTemplateDeclarationType();
+ public Iterator getTemplateParameters();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateInstantiation.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateInstantiation.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTemplateInstantiation.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTemplateInstantiation.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTemplateInstantiation {
+
+ public TemplateDeclarationType getTemplateDeclarationType();
+ public IASTTemplateDeclaration getTemplateDeclaration();
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateParameter.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateParameter.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTemplateParameter.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTemplateParameter.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTemplateParameter {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateSpecialization.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTemplateSpecialization.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTemplateSpecialization.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTemplateSpecialization.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTemplateSpecialization {
+
+ public TemplateDeclarationType getTemplateDeclarationType();
+ public IASTTemplateDeclaration getTemplateDeclaration();
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTemplatedDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTemplatedDeclaration.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTemplatedDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTemplatedDeclaration.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTemplatedDeclaration {
+
+ public IASTTemplateDeclaration getOwnerTemplateDeclaration();
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTTypedef.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTTypedef {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTUsingDeclaration.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,22 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTUsingDeclaration extends IASTDeclaration {
+
+ public boolean isTypename();
+ public String usingTypeName();
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTUsingDirective.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTUsingDirective extends IASTDeclaration {
+
+ public String getNamespaceName();
+}
Index: parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java
diff -N parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/IASTVariable.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,19 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTVariable {
+
+}
Index: parser/org/eclipse/cdt/core/parser/ast/TemplateDeclarationType.java
===================================================================
RCS file: parser/org/eclipse/cdt/core/parser/ast/TemplateDeclarationType.java
diff -N parser/org/eclipse/cdt/core/parser/ast/TemplateDeclarationType.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/core/parser/ast/TemplateDeclarationType.java 13 Jun 2003 14:58:07 -0000
@@ -0,0 +1,32 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class TemplateDeclarationType {
+
+ public static final TemplateDeclarationType t_class = new TemplateDeclarationType(1);
+ public static final TemplateDeclarationType t_function = new TemplateDeclarationType( 2 );
+ public static final TemplateDeclarationType t_memberClass = new TemplateDeclarationType( 3 );
+ public static final TemplateDeclarationType t_method = new TemplateDeclarationType( 4 );
+ public static final TemplateDeclarationType t_field = new TemplateDeclarationType( 5 );
+
+
+ private final int type;
+ private TemplateDeclarationType( int t )
+ {
+ type = t;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java,v
retrieving revision 1.24
diff -u -r1.24 CModelBuilder.java
--- parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 5 Jun 2003 20:01:54 -0000 1.24
+++ parser/org/eclipse/cdt/internal/core/model/CModelBuilder.java 13 Jun 2003 14:58:07 -0000
@@ -24,11 +24,11 @@
import org.eclipse.cdt.core.model.IStructure;
import org.eclipse.cdt.core.model.ITemplate;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.IParser;
import org.eclipse.cdt.internal.core.dom.ArrayQualifier;
import org.eclipse.cdt.internal.core.dom.ClassKey;
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
-import org.eclipse.cdt.internal.core.dom.DOMFactory;
import org.eclipse.cdt.internal.core.dom.DeclSpecifier;
import org.eclipse.cdt.internal.core.dom.Declaration;
import org.eclipse.cdt.internal.core.dom.Declarator;
@@ -39,7 +39,6 @@
import org.eclipse.cdt.internal.core.dom.ITemplateParameterListOwner;
import org.eclipse.cdt.internal.core.dom.Inclusion;
import org.eclipse.cdt.internal.core.dom.Macro;
-import org.eclipse.cdt.internal.core.dom.Name;
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
@@ -49,7 +48,7 @@
import org.eclipse.cdt.internal.core.dom.TemplateParameter;
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
-import org.eclipse.cdt.internal.core.parser.IParser;
+import org.eclipse.cdt.internal.core.parser.Name;
import org.eclipse.cdt.internal.core.parser.Parser;
import org.eclipse.core.resources.IProject;
@@ -66,7 +65,7 @@
public Map parse(boolean requiresLineNumbers) throws Exception {
// Note - if a CModel client wishes to have a CModel with valid line numbers
// DOMFactory.createDOMBuilder should be given the parameter 'true'
- DOMBuilder domBuilder = DOMFactory.createDOMBuilder( requiresLineNumbers );
+ DOMBuilder domBuilder = new DOMBuilder();
String code = translationUnit.getBuffer().getContents();
IParser parser = new Parser(code, domBuilder, true);
parser.mapLineNumbers(requiresLineNumbers);
@@ -283,12 +282,12 @@
parent.addChild((ICElement)element);
// set element position
if(nsDef.getName() != null){
- element.setIdPos(nsDef.getName().getStartOffset(), nsDef.getName().length());
+ element.setIdPos(nsDef.getNameOffset(), nsDef.getName().length());
}else{
- element.setIdPos(nsDef.getStartToken().getOffset(), nsDef.getStartToken().getLength());
+ element.setIdPos(nsDef.getStartingOffset(), new String( "namespace").length());
}
element.setPos(nsDef.getStartingOffset(), nsDef.getTotalLength());
- element.setTypeName(nsDef.getStartToken().getImage());
+ element.setTypeName(new String( "namespace"));
// set the element lines
element.setLines(nsDef.getTopLine(), nsDef.getBottomLine());
Index: parser/org/eclipse/cdt/internal/core/parser/ContextStack.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ContextStack.java,v
retrieving revision 1.3
diff -u -r1.3 ContextStack.java
--- parser/org/eclipse/cdt/internal/core/parser/ContextStack.java 21 Apr 2003 18:34:39 -0000 1.3
+++ parser/org/eclipse/cdt/internal/core/parser/ContextStack.java 13 Jun 2003 14:58:07 -0000
@@ -19,6 +19,9 @@
import java.util.Set;
import java.util.Stack;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+
/**
* @author aniefer
*
@@ -31,18 +34,20 @@
super();
}
- public void updateContext(Reader reader, String filename, int type) throws ScannerException {
+ public void updateContext(Reader reader, String filename, int type, IASTInclusion inclusion, ISourceElementRequestor requestor) throws ScannerException {
undoStack.clear();
-
- push( new ScannerContext().initialize(reader, filename, type ) );
+ push( new ScannerContext().initialize(reader, filename, type, null ), requestor );
}
- protected void push( IScannerContext context ) throws ScannerException
+ protected void push( IScannerContext context, ISourceElementRequestor requestor ) throws ScannerException
{
if( context.getKind() == IScannerContext.INCLUSION )
{
if( !inclusions.add( context.getFilename() ) )
- throw new ScannerException( "Inclusion " + context.getFilename() + " already encountered." );
+ throw new ScannerException( "Inclusion " + context.getFilename() + " already encountered." );
+ if( requestor != null )
+ requestor.enterInclusion( context.getExtension() );
+
} else if( context.getKind() == IScannerContext.MACROEXPANSION )
{
if( !defines.add( context.getFilename() ) )
@@ -56,7 +61,7 @@
topContext = context;
}
- public boolean rollbackContext() {
+ public boolean rollbackContext(ISourceElementRequestor requestor) {
try {
currentContext.getReader().close();
} catch (IOException ie) {
@@ -66,6 +71,8 @@
if( currentContext.getKind() == IScannerContext.INCLUSION )
{
inclusions.remove( currentContext.getFilename() );
+ if( requestor != null )
+ requestor.exitInclusion( currentContext.getExtension() );
} else if( currentContext.getKind() == IScannerContext.MACROEXPANSION )
{
defines.remove( currentContext.getFilename() );
@@ -82,7 +89,7 @@
return true;
}
- public void undoRollback( IScannerContext undoTo ) throws ScannerException {
+ public void undoRollback( IScannerContext undoTo, ISourceElementRequestor requestor ) throws ScannerException {
if( currentContext == undoTo ){
return;
}
@@ -93,7 +100,7 @@
Iterator iter = undoStack.iterator();
for( int i = size; i > 0; i-- )
{
- push( (IScannerContext) undoStack.removeFirst() );
+ push( (IScannerContext) undoStack.removeFirst(), requestor );
if( currentContext == undoTo )
break;
Index: parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java,v
retrieving revision 1.25
diff -u -r1.25 ExpressionEvaluator.java
--- parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 5 Jun 2003 20:01:54 -0000 1.25
+++ parser/org/eclipse/cdt/internal/core/parser/ExpressionEvaluator.java 13 Jun 2003 14:58:08 -0000
@@ -13,7 +13,8 @@
import java.util.EmptyStackException;
import java.util.Stack;
-import org.eclipse.cdt.internal.core.dom.Name;
+import org.eclipse.cdt.core.parser.IParser;
+
public class ExpressionEvaluator implements IParserCallback {
Index: parser/org/eclipse/cdt/internal/core/parser/IParser.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/IParser.java
diff -N parser/org/eclipse/cdt/internal/core/parser/IParser.java
--- parser/org/eclipse/cdt/internal/core/parser/IParser.java 30 Apr 2003 22:14:55 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,85 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * 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:
- * Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.core.parser;
-
-import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
-
-
-/**
- * This is the external interface that all C and C++ parsers in the CDT
- * must implement.
- *
- * @author jcamelon
- */
-public interface IParser {
-
-
- /**
- * Request a parse from a pre-configured parser to parse a whole translation unit or file.
- *
- * @return whether or not the parse was successful
- */
- public boolean parse();
-
-
- /**
- * Request a parse from a pre-configured parser to parse an expression.
- *
- * @param expression Optional parameter representing an expression object that
- * your particular IParserCallback instance would appreciate
- *
- * @throws Backtrack thrown if the Scanner/Stream provided does not yield a valid
- * expression
- */
- public void expression(Object expression) throws Backtrack;
-
- /**
- * Is the parser configured for ANSI C or ANSI C++?
- *
- * @return true for C++, false for C
- */
- public boolean isCppNature();
-
- /**
- * Set the Parser explicitly to be a C or C++ parser.
- *
- * @param b true for C++, false for C
- */
- public void setCppNature(boolean b);
-
- /**
- * Do we wish to keep track of the lineNumbers/Offset mapping?
- *
- * By default, the value is false. Setting it to true impacts performance but
- * provides that feature.
- *
- * @param value true for the feature, false for improved performance
- */
- public void mapLineNumbers( boolean value );
-
- /**
- * Given an character offset into the file, return the lineNumber this offset maps to.
- *
- * @param offset character offset in the file
- * @return lineNumber this offset maps to
- * @throws NoSuchMethodException if mapLineNumbers( true ) was not previously called
- */
- public int getLineNumberForOffset(int offset) throws NoSuchMethodException;
-
- /**
- * If an error was encountered, give us the offset of the token that caused the error.
- *
- * @return -1 for no error, otherwise the character offset where we encountered
- * our first unrecoverable error.
- */
- public int getLastErrorOffset();
-
-}
\ No newline at end of file
Index: parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java,v
retrieving revision 1.24
diff -u -r1.24 IParserCallback.java
--- parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java 5 Jun 2003 20:01:54 -0000 1.24
+++ parser/org/eclipse/cdt/internal/core/parser/IParserCallback.java 13 Jun 2003 14:58:08 -0000
@@ -10,6 +10,8 @@
******************************************************************************/
package org.eclipse.cdt.internal.core.parser;
+import org.eclipse.cdt.core.parser.IParser;
+
public interface IParserCallback {
public void setParser( IParser parser );
Index: parser/org/eclipse/cdt/internal/core/parser/IScanner.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/IScanner.java
diff -N parser/org/eclipse/cdt/internal/core/parser/IScanner.java
--- parser/org/eclipse/cdt/internal/core/parser/IScanner.java 21 Apr 2003 18:34:39 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-package org.eclipse.cdt.internal.core.parser;
-
-import java.io.Reader;
-import java.util.List;
-
-/**
- * @author jcamelon
- *
- * To change this generated comment edit the template variable
-"typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public interface IScanner {
-
- public static final int tPOUNDPOUND = -6;
- public static final int tPOUND = -7;
-
- public IScanner initialize( Reader sourceToBeRead, String fileName );
-
- public void addDefinition(String key, IMacroDescriptor macroToBeAdded );
- public void addDefinition(String key, String value);
- public Object getDefinition(String key);
-
- public Object[] getIncludePaths();
- public void addIncludePath(String includePath);
- public void overwriteIncludePath( List newIncludePaths );
-
- public Token nextToken() throws ScannerException, Parser.EndOfFile;
- public int getLineNumberForOffset(int offset) throws NoSuchMethodException;
- public void setCppNature( boolean value );
- public void mapLineNumbers( boolean value );
- public void setQuickScan(boolean qs);
- public void setCallback(IParserCallback c);
-}
Index: parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java,v
retrieving revision 1.4
diff -u -r1.4 IScannerContext.java
--- parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java 16 Apr 2003 12:30:46 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/IScannerContext.java 13 Jun 2003 14:58:08 -0000
@@ -1,6 +1,8 @@
package org.eclipse.cdt.internal.core.parser;
import java.io.IOException;
import java.io.Reader;
+
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
/**
* @author jcamelon
*
@@ -17,17 +19,20 @@
public static int INCLUSION = 2;
public static int MACROEXPANSION = 3;
+ public IScannerContext initialize(Reader r, String f, int k, IASTInclusion i);
+ public int read() throws IOException;
+ public String getFilename();
+ public int getOffset();
+ public Reader getReader();
- IScannerContext initialize(Reader r, String f, int k);
- int read() throws IOException;
- String getFilename();
- int getOffset();
- Reader getReader();
+ public int undoStackSize();
+ public int popUndo();
+ public void pushUndo(int undo);
- int undoStackSize();
- int popUndo();
- void pushUndo(int undo);
+ public int getKind();
+ public void setKind( int kind );
+
+ public IASTInclusion getExtension();
+ public void setExtension( IASTInclusion ext );
- int getKind();
- void setKind( int kind );
}
Index: parser/org/eclipse/cdt/internal/core/parser/ISymbol.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ISymbol.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ISymbol.java
--- parser/org/eclipse/cdt/internal/core/parser/ISymbol.java 5 May 2003 20:31:08 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,21 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * 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 Rational Software - Initial API and implementation
-***********************************************************************/
-package org.eclipse.cdt.internal.core.parser;
-
-/**
- * @author jcamelon
- *
- */
-public interface ISymbol {
-
- public Object getObject();
-
-}
Index: parser/org/eclipse/cdt/internal/core/parser/Name.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/Name.java
diff -N parser/org/eclipse/cdt/internal/core/parser/Name.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/Name.java 13 Jun 2003 14:58:08 -0000
@@ -0,0 +1,75 @@
+package org.eclipse.cdt.internal.core.parser;
+
+
+
+/**
+ * @author dschaefe
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class Name {
+
+ private Token nameStart, nameEnd;
+
+ public Name(Token nameStart) {
+ this.nameStart = nameStart;
+ }
+
+ public Name(Token nameStart, Token nameEnd) {
+ this( nameStart );
+ setEnd( nameEnd );
+ }
+
+
+ public void setEnd(Token nameEnd) {
+ this.nameEnd = nameEnd;
+ }
+
+ public int getStartOffset()
+ {
+ return nameStart.offset;
+ }
+
+ public int getEndOffset()
+ {
+ return nameEnd.offset;
+ }
+
+ public String toString() {
+ Token t = nameStart;
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( t.getImage() );
+ if( t.getType() == Token.t_operator )
+ buffer.append( " " );
+
+ while (t != nameEnd) {
+ t = t.getNext();
+
+ buffer.append( t.getImage() );
+ if (t.getType() == Token.t_operator) buffer.append( " " );
+ }
+
+ return buffer.toString();
+ }
+
+ public int length()
+ {
+ return getEndOffset() - getStartOffset() + nameEnd.getImage().length();
+ }
+ /**
+ * @return
+ */
+ public Token getNameStart() {
+ return nameStart;
+ }
+
+ public static String tokensToString( Token first, Token last )
+ {
+ Name n = new Name( first, last );
+ return n.toString();
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java,v
retrieving revision 1.24
diff -u -r1.24 NullParserCallback.java
--- parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java 5 Jun 2003 20:01:54 -0000 1.24
+++ parser/org/eclipse/cdt/internal/core/parser/NullParserCallback.java 13 Jun 2003 14:58:08 -0000
@@ -1,5 +1,7 @@
package org.eclipse.cdt.internal.core.parser;
+import org.eclipse.cdt.core.parser.IParser;
+
public class NullParserCallback implements IParserCallback {
/* (non-Javadoc)
Index: parser/org/eclipse/cdt/internal/core/parser/Parser.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java,v
retrieving revision 1.49
diff -u -r1.49 Parser.java
--- parser/org/eclipse/cdt/internal/core/parser/Parser.java 10 Jun 2003 22:57:02 -0000 1.49
+++ parser/org/eclipse/cdt/internal/core/parser/Parser.java 13 Jun 2003 14:58:09 -0000
@@ -15,9 +15,18 @@
import java.io.InputStreamReader;
import java.io.StringReader;
+import org.eclipse.cdt.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
import org.eclipse.cdt.internal.core.model.Util;
-import org.eclipse.cdt.internal.core.parser.ParserSymbolTable.Declaration;
-import org.eclipse.cdt.internal.core.parser.ParserSymbolTable.TypeInfo;
/**
* This is our first implementation of the IParser interface, serving as a parser for
@@ -35,7 +44,8 @@
private boolean quickParse = false; // are we doing the high-level parse, or an in depth parse?
private boolean parsePassed = true; // did the parse pass?
private boolean cppNature = true; // true for C++, false for C
- private ParserSymbolTable pst = new ParserSymbolTable(); // names
+ private ISourceElementRequestor requestor = null; // new callback mechanism
+ private IASTFactory astFactory = null; // ast factory
/**
* This is the single entry point for setting parsePassed to
@@ -62,9 +72,13 @@
public Parser(IScanner s, IParserCallback c, boolean quick) {
callback = c;
scanner = s;
+ if( c instanceof ISourceElementRequestor )
+ setRequestor( (ISourceElementRequestor)c );
quickParse = quick;
+ astFactory = ParserFactory.createASTFactory( quick );
scanner.setQuickScan(quick);
scanner.setCallback(c);
+ scanner.setASTFactory( astFactory );
}
@@ -162,14 +176,17 @@
protected void translationUnit() {
try { callback.setParser( this ); } catch( Exception e) {}
Object translationUnit = null;
- try{ translationUnit = callback.translationUnitBegin();} catch( Exception e ) {}
- pst.getCompilationUnit().setObject(translationUnit);
+ try{ translationUnit = callback.translationUnitBegin();} catch( Exception e ) {}
+
+ IASTCompilationUnit compilationUnit = astFactory.createCompilationUnit();
+ requestor.enterCompilationUnit( compilationUnit );
+
Token lastBacktrack = null;
Token checkToken;
while (true) {
try {
checkToken = LA(1);
- declaration( translationUnit, pst.getCompilationUnit() );
+ declaration( translationUnit, compilationUnit );
if( LA(1) == checkToken )
errorHandling();
} catch (EndOfFile e) {
@@ -199,8 +216,12 @@
}
}
try{ callback.translationUnitEnd(translationUnit);} catch( Exception e ) {}
+ requestor.exitCompilationUnit( compilationUnit );
}
+
+
+
/**
* This function is called whenever we encounter and error that we cannot backtrack out of and we
* still wish to try and continue on with the parse to do a best-effort parse for our client.
@@ -240,7 +261,7 @@
* @param container Callback object representing the scope these definitions fall into.
* @throws Backtrack request for a backtrack
*/
- protected void usingClause( Object container ) throws Backtrack
+ protected void usingClause( Object container, IASTScope scope ) throws Backtrack
{
Token firstToken = consume( Token.t_using );
@@ -251,10 +272,11 @@
// using-directive
consume( Token.t_namespace );
- // optional :: and nested classes handled in name
+ // optional :: and nested classes handled in name
+ TokenDuple duple = null ;
if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON )
{
- name();
+ duple = name();
try{ callback.usingDirectiveNamespaceId( directive );} catch( Exception e ) {}
}
else
@@ -267,6 +289,9 @@
{
consume( Token.tSEMI );
try{ callback.usingDirectiveEnd( directive );} catch( Exception e ) {}
+
+ IASTUsingDirective astUD = astFactory.createUsingDirective(scope, duple);
+ requestor.acceptUsingDirective( astUD );
return;
}
else
@@ -287,10 +312,11 @@
consume( Token.t_typename );
}
+ TokenDuple name = null;
if( LT(1) == Token.tIDENTIFIER || LT(1) == Token.tCOLONCOLON )
{
// optional :: and nested classes handled in name
- name();
+ name = name();
try{ callback.usingDeclarationMapping( usingDeclaration, typeName ); } catch( Exception e ) {}
}
else
@@ -302,7 +328,11 @@
if( LT(1) == Token.tSEMI )
{
consume( Token.tSEMI );
+
try{ callback.usingDeclarationEnd( usingDeclaration );} catch( Exception e ) {}
+
+ IASTUsingDeclaration declaration = astFactory.createUsingDeclaration( scope, typeName, name );
+ requestor.acceptUsingDeclaration(declaration);
}
else
{
@@ -311,7 +341,8 @@
}
}
}
-
+
+
/**
* Implements Linkage specification in the ANSI C++ grammar.
*
@@ -322,19 +353,25 @@
* @param container Callback object representing the scope these definitions fall into.
* @throws Backtrack request for a backtrack
*/
- protected void linkageSpecification( Object container ) throws Backtrack
+ protected void linkageSpecification( Object container, IASTScope scope ) throws Backtrack
{
consume( Token.t_extern );
if( LT(1) != Token.tSTRING )
throw backtrack;
- Object linkageSpec = null;
- try{ linkageSpec = callback.linkageSpecificationBegin( container, consume( Token.tSTRING ).getImage() );} catch( Exception e ) {}
-
+ Object linkageSpec = null;
+ Token spec = consume( Token.tSTRING );
+ try{ linkageSpec = callback.linkageSpecificationBegin( container, spec.getImage() );} catch( Exception e ) {}
+
if( LT(1) == Token.tLBRACE )
- {
- consume(Token.tLBRACE);
+ {
+ consume(Token.tLBRACE);
+
+ IASTLinkageSpecification linkage = astFactory.createLinkageSpecification(scope, spec.getImage());
+
+ requestor.enterLinkageSpecification( linkage );
+
linkageDeclarationLoop:
while (LT(1) != Token.tRBRACE) {
Token checkToken = LA(1);
@@ -345,7 +382,7 @@
default:
try
{
- declaration(linkageSpec, null);
+ declaration(linkageSpec, linkage);
}
catch( Backtrack bt )
{
@@ -360,13 +397,21 @@
// consume the }
consume();
try{ callback.linkageSpecificationEnd( linkageSpec );} catch( Exception e ) {}
+ requestor.exitLinkageSpecification( linkage );
}
else // single declaration
{
- declaration( linkageSpec, null );
+
+ IASTLinkageSpecification linkage = astFactory.createLinkageSpecification( scope, spec.getImage() );
+
+ requestor.enterLinkageSpecification( linkage );
+
+ declaration( linkageSpec );
try{ callback.linkageSpecificationEnd( linkageSpec );} catch( Exception e ) {}
+ requestor.exitLinkageSpecification( linkage );
}
}
+
/**
*
@@ -397,7 +442,7 @@
// explicit-instantiation
Object instantiation = null;
try { instantiation = callback.explicitInstantiationBegin( container ); } catch( Exception e ) { }
- declaration( instantiation, null );
+ declaration( instantiation );
try { callback.explicitInstantiationEnd( instantiation ); } catch( Exception e ) { }
return;
}
@@ -410,7 +455,7 @@
// explicit-specialization
Object specialization = null;
try{ specialization = callback.explicitSpecializationBegin( container ); } catch( Exception e ) { }
- declaration( specialization, null );
+ declaration( specialization );
try{ callback.explicitSpecializationEnd( specialization ); } catch( Exception e ) { }
return;
}
@@ -422,7 +467,7 @@
try{ templateDeclaration = callback.templateDeclarationBegin( container, firstToken ); } catch ( Exception e ) {}
templateParameterList( templateDeclaration );
consume( Token.tGT );
- declaration( templateDeclaration, null );
+ declaration( templateDeclaration );
try{ callback.templateDeclarationEnd( templateDeclaration, lastToken ); } catch( Exception e ) {}
} catch( Backtrack bt )
@@ -529,6 +574,11 @@
}
}
+
+ protected void declaration( Object container ) throws Backtrack
+ {
+ declaration( container, null );
+ }
/**
* The most abstract construct within a translationUnit : a declaration.
*
@@ -552,23 +602,29 @@
* @param container IParserCallback object which serves as the owner scope for this declaration.
* @throws Backtrack request a backtrack
*/
- protected void declaration( Object container, Declaration scope ) throws Backtrack {
+ protected void declaration( Object container, IASTScope scope ) throws Backtrack {
switch (LT(1)) {
case Token.t_asm:
- consume( Token.t_asm );
+ Token first = consume( Token.t_asm );
consume( Token.tLPAREN );
String assembly = consume( Token.tSTRING ).getImage();
consume( Token.tRPAREN );
- consume( Token.tSEMI );
+ Token last = consume( Token.tSEMI );
+
+ IASTASMDefinition asmDefinition =
+ astFactory.createASMDefinition(scope, assembly, first.getOffset(), last.getEndOffset());
+
// if we made it this far, then we have all we need
// do the callback
try{ callback.asmDefinition( container, assembly );} catch( Exception e ) {}
- return;
+
+ requestor.acceptASMDefinition( asmDefinition );
+ return;
case Token.t_namespace:
- namespaceDefinition( container, scope );
+ namespaceDefinition( container, scope);
return;
case Token.t_using:
- usingClause( container );
+ usingClause( container, scope );
return;
case Token.t_export:
case Token.t_template:
@@ -577,20 +633,20 @@
case Token.t_extern:
if( LT(2) == Token.tSTRING )
{
- linkageSpecification( container );
+ linkageSpecification( container, scope );
return;
}
default:
Token mark = mark();
try
{
- simpleDeclaration( container, true, scope ); // try it first with the original strategy
+ simpleDeclaration( container, true ); // try it first with the original strategy
}
catch( Backtrack bt)
{
// did not work
backup( mark );
- simpleDeclaration( container, false, scope ); // try it again with the second strategy
+ simpleDeclaration( container, false ); // try it again with the second strategy
}
}
}
@@ -606,72 +662,43 @@
* @throws Backtrack request a backtrack
*/
- protected void namespaceDefinition( Object container, Declaration scope ) throws Backtrack
+ protected void namespaceDefinition( Object container, IASTScope scope ) throws Backtrack
{
Object namespace = null;
- boolean redeclared = false;
- Token firstToken = consume( Token.t_namespace );
+ Token first = consume( Token.t_namespace );
+ try{ namespace = callback.namespaceDefinitionBegin( container, first );} catch( Exception e ) {}
- // optional name
- String identifier = "";
+ Token identifier = null;
+ // optional name
if( LT(1) == Token.tIDENTIFIER )
{
- identifier = LA(1).getImage();
- identifier();
+ identifier = identifier();
+ try{ callback.namespaceDefinitionId( namespace );} catch( Exception e ) {}
}
if( LT(1) == Token.tLBRACE )
{
- consume( Token.tLBRACE);
-
- Declaration namespaceSymbol = null;
- try {
- namespaceSymbol = scope.Lookup( identifier );
- } catch (ParserSymbolTableException e1) {
- // should not get ambiguity here
- }
-
- if( namespaceSymbol == null )
- {
- namespaceSymbol = pst.new Declaration( identifier );
- try
- {
- namespaceSymbol.setType( TypeInfo.t_namespace );
- }
- catch( ParserSymbolTableException pste )
- {
- // should never happen
- }
- try{ namespace = callback.namespaceDefinitionBegin( container, firstToken );} catch( Exception e ) {}
- namespaceSymbol.setObject( namespace );
- try {
- scope.addDeclaration( namespaceSymbol );
- } catch (ParserSymbolTableException e2) {
- // TODO ambiguity?
- }
- if( !identifier.equals( "" ))
- try{ callback.namespaceDefinitionId( namespace );} catch( Exception e ) {}
- }
- else
- {
- if( namespaceSymbol.getType() != TypeInfo.t_namespace )
- throw backtrack;
- namespace = namespaceSymbol.getObject();
- redeclared = true;
- }
-
-
+ consume();
+
+ IASTNamespaceDefinition namespaceDefinition =
+ astFactory.createNamespaceDefinition(
+ scope,
+ ( identifier == null ? "" : identifier.getImage() ),
+ first.getOffset(), ( identifier == null ? 0 : identifier.getOffset()) );
+
+ requestor.enterNamespaceDefinition( namespaceDefinition );
+
namepsaceDeclarationLoop:
while (LT(1) != Token.tRBRACE) {
Token checkToken = LA(1);
switch (LT(1)) {
case Token.tRBRACE:
- consume(Token.tRBRACE);
+ //consume(Token.tRBRACE);
break namepsaceDeclarationLoop;
default:
try
{
- declaration(namespace, namespaceSymbol);
+ declaration(namespace, namespaceDefinition);
}
catch( Backtrack bt )
{
@@ -685,9 +712,11 @@
}
// consume the }
- Token lastToken =consume( Token.tRBRACE );
- if( ! redeclared )
- try{ callback.namespaceDefinitionEnd( namespace, lastToken );} catch( Exception e ) {}
+ Token last = consume( Token.tRBRACE );
+ try{ callback.namespaceDefinitionEnd( namespace, last);} catch( Exception e ) {}
+
+ namespaceDefinition.setEndingOffset( last.getOffset() + last.getLength());
+ requestor.exitNamespaceDefinition( namespaceDefinition );
}
else
{
@@ -695,9 +724,9 @@
throw backtrack;
}
}
-
-
+
+
/**
* Serves as the catch-all for all complicated declarations, including function-definitions.
*
@@ -715,10 +744,10 @@
* @param tryConstructor true == take strategy1 (constructor ) : false == take strategy 2 ( pointer to function)
* @throws Backtrack request a backtrack
*/
- protected void simpleDeclaration( Object container, boolean tryConstructor, Declaration scope ) throws Backtrack {
+ protected void simpleDeclaration( Object container, boolean tryConstructor ) throws Backtrack {
Object simpleDecl = null;
try{ simpleDecl = callback.simpleDeclarationBegin( container, LA(1));} catch( Exception e ) {}
- declSpecifierSeq(simpleDecl, false, tryConstructor, scope);
+ declSpecifierSeq(simpleDecl, false, tryConstructor);
Object declarator = null;
if (LT(1) != Token.tSEMI)
@@ -846,7 +875,7 @@
Token current = LA(1);
Object parameterDecl = null;
try{ parameterDecl = callback.parameterDeclarationBegin( containerObject );} catch( Exception e ) {}
- declSpecifierSeq( parameterDecl, true, false, null );
+ declSpecifierSeq( parameterDecl, true, false );
if (LT(1) != Token.tSEMI)
try {
@@ -1029,7 +1058,7 @@
* @param tryConstructor true for constructor, false for pointer to function strategy
* @throws Backtrack request a backtrack
*/
- protected void declSpecifierSeq( Object decl, boolean parm, boolean tryConstructor, Declaration scope ) throws Backtrack {
+ protected void declSpecifierSeq( Object decl, boolean parm, boolean tryConstructor ) throws Backtrack {
Flags flags = new Flags( parm, tryConstructor );
declSpecifiers:
for (;;) {
@@ -1097,7 +1126,6 @@
return;
if ( lookAheadForDeclarator( flags ) )
return;
-
try{ callback.simpleDeclSpecifier(decl,LA(1));} catch( Exception e ) {}
name();
try{ callback.simpleDeclSpecifierName( decl );} catch( Exception e ) {}
@@ -1112,7 +1140,7 @@
{
try
{
- classSpecifier(decl, scope);
+ classSpecifier(decl);
return;
}
catch( Backtrack bt )
@@ -1172,6 +1200,7 @@
callback.elaboratedTypeSpecifierEnd( elab );
} catch( Exception e ) {}
}
+
/**
* Consumes template parameters.
@@ -1210,13 +1239,14 @@
*
* @throws Backtrack request a backtrack
*/
- protected void identifier() throws Backtrack {
+ protected Token identifier() throws Backtrack {
Token first = consume(Token.tIDENTIFIER); // throws backtrack if its not that
try
{
callback.nameBegin(first);
callback.nameEnd(first);
} catch( Exception e ) {}
+ return first;
}
/**
@@ -1274,7 +1304,7 @@
*
* @throws Backtrack request a backtrack
*/
- protected void name() throws Backtrack {
+ protected TokenDuple name() throws Backtrack {
Token first = LA(1);
Token last = null;
@@ -1318,6 +1348,7 @@
}
try{ callback.nameEnd(last);} catch( Exception e ) {}
+ return new TokenDuple( first, last );
}
@@ -1873,7 +1904,7 @@
* @param owner IParserCallback object that represents the declaration that owns this classSpecifier
* @throws Backtrack request a backtrack
*/
- protected void classSpecifier( Object owner, Declaration scope ) throws Backtrack {
+ protected void classSpecifier( Object owner ) throws Backtrack {
Token classKey = null;
Token mark = mark();
@@ -1931,7 +1962,7 @@
default:
try
{
- declaration(classSpec, scope);
+ declaration(classSpec);
}
catch( Backtrack bt )
{
@@ -2115,7 +2146,7 @@
while (LT(1) == Token.t_catch) {
consume();
consume(Token.tLPAREN);
- declaration(null, null); // was exceptionDeclaration
+ declaration(null); // was exceptionDeclaration
consume(Token.tRPAREN);
compoundStatement();
}
@@ -2147,7 +2178,7 @@
}
// declarationStatement
- declaration(null, null);
+ declaration(null);
}
}
@@ -3120,5 +3151,15 @@
*/
public int getLastErrorOffset() {
return firstErrorOffset;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.IParser#setRequestor(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void setRequestor(ISourceElementRequestor r) {
+ requestor = r;
+ if( scanner != null )
+ scanner.setRequestor(r);
}
}
Index: parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ParserFactory.java 13 Jun 2003 14:58:09 -0000
@@ -0,0 +1,30 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser;
+
+import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.full.FullParseASTFactory;
+import org.eclipse.cdt.internal.core.parser.ast.quick.QuickParseASTFactory;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ParserFactory {
+
+ public static IASTFactory createASTFactory( boolean quickParse )
+ {
+ if( quickParse )
+ return new QuickParseASTFactory();
+ else
+ return new FullParseASTFactory();
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTable.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTable.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTable.java
--- parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTable.java 5 May 2003 20:31:08 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2368 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * 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:
- * Rational Software - Initial API and implementation
- *
-***********************************************************************/
-
-
-package org.eclipse.cdt.internal.core.parser;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-//import java.util.Stack;
-
-
-/**
- * @author aniefer
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-
-public class ParserSymbolTable {
-
- /**
- * Constructor for ParserSymbolTable.
- */
- public ParserSymbolTable() {
- super();
- _compilationUnit = new Declaration();
- try{
- _compilationUnit.setType( TypeInfo.t_namespace );
- } catch ( ParserSymbolTableException e ){
- /*shouldn't happen*/
- }
- }
-
- public Declaration getCompilationUnit(){
- return _compilationUnit;
- }
-
- /**
- * Lookup the name from LookupData starting in the inDeclaration
- * @param data
- * @param inDeclaration
- * @return Declaration
- * @throws ParserSymbolTableException
- */
- static private void Lookup( LookupData data, Declaration inDeclaration ) throws ParserSymbolTableException
- {
- if( data.type != -1 && data.type < TypeInfo.t_class && data.upperType > TypeInfo.t_union ){
- throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
- }
-
- Declaration decl = null; //the return value
- LinkedList transitives = new LinkedList(); //list of transitive using directives
-
- //if this name define in this scope?
- LookupInContained( data, inDeclaration );
-
- if( !data.ignoreUsingDirectives ){
- //check nominated namespaces
- //the transitives list is populated in LookupInNominated, and then
- //processed in ProcessDirectives
-
- data.visited.clear(); //each namesapce is searched at most once, so keep track
-
- LookupInNominated( data, inDeclaration, transitives );
-
- //if we are doing a qualified lookup, only process using directives if
- //we haven't found the name yet (and if we aren't ignoring them).
- if( !data.qualified || data.foundItems == null ){
- ProcessDirectives( inDeclaration, data, transitives );
-
- if( inDeclaration.getUsingDirectives() != null ){
- ProcessDirectives( inDeclaration, data, inDeclaration.getUsingDirectives() );
- }
-
- while( data.usingDirectives != null && data.usingDirectives.get( inDeclaration ) != null ){
- transitives.clear();
-
- LookupInNominated( data, inDeclaration, transitives );
-
- if( !data.qualified || data.foundItems == null ){
- ProcessDirectives( inDeclaration, data, transitives );
- }
- }
- }
- }
-
- if( data.foundItems != null || data.stopAt == inDeclaration ){
- return;
- }
-
- //if we still havn't found it, check any parents we have
- data.visited.clear(); //each virtual base class is searched at most once
- decl = LookupInParents( data, inDeclaration );
-
- //there is a resolveAmbiguities inside LookupInParents, which means if we found
- //something the foundItems set will be non-null, but empty. So, add the decl into
- //the foundItems set
- if( decl != null ){
- data.foundItems.add( decl );
- }
-
- //if still not found, check our containing scope.
- if( data.foundItems == null && inDeclaration._containingScope != null ){
- Lookup( data, inDeclaration._containingScope );
- }
-
- return;
- }
-
- /**
- * function LookupInNominated
- * @param data
- * @param transitiveDirectives
- * @return List
- *
- * for qualified:
- * 3.4.3.2-2 "let S be the set of all declarations of m in X
- * and in the transitive closure of all namespaces nominated by using-
- * directives in X and its used namespaces, except that using-directives are
- * ignored in any namespace, including X, directly containing one or more
- * declarations of m."
- *
- * for unqualified:
- * 7.3.4-2 The using-directive is transitive: if a scope contains a using
- * directive that nominates a second namespace that itself contains using-
- * directives, the effect is as if the using-directives from the second
- * namespace also appeared in the first.
- */
- static private void LookupInNominated( LookupData data, Declaration declaration, LinkedList transitiveDirectives ) throws ParserSymbolTableException{
- //if the data.usingDirectives is empty, there is nothing to do.
- if( data.usingDirectives == null ){
- return;
- }
-
- //local variables
- LinkedList directives = null; //using directives association with declaration
- Iterator iter = null;
- Declaration decl = null;
-
- boolean foundSomething = false;
- int size = 0;
-
- directives = (LinkedList) data.usingDirectives.remove( declaration );
-
- if( directives == null ){
- return;
- }
-
- iter = directives.iterator();
- size = directives.size();
- for( int i = size; i > 0; i-- ){
- decl = (Declaration) iter.next();
-
- //namespaces are searched at most once
- if( !data.visited.contains( decl ) ){
- data.visited.add( decl );
-
- foundSomething = LookupInContained( data, decl );
-
- //only consider the transitive using directives if we are an unqualified
- //lookup, or we didn't find the name in decl
- if( (!data.qualified || !foundSomething ) && decl.getUsingDirectives() != null ){
- //name wasn't found, add transitive using directives for later consideration
- transitiveDirectives.addAll( decl.getUsingDirectives() );
- }
- }
- }
-
- return;
- }
-
- /**
- * function LookupInContained
- * @param data
- * @return List
- * @throws ParserSymbolTableException
- *
- * Look for data.name in our collection _containedDeclarations
- */
- private static boolean LookupInContained( LookupData data, Declaration lookIn ) throws ParserSymbolTableException{
- boolean foundSomething = false;
- Declaration temp = null;
- Object obj = null;
-
- if( data.associated != null ){
- //we are looking in lookIn, remove it from the associated scopes list
- data.associated.remove( lookIn );
- }
-
- Map declarations = lookIn.getContainedDeclarations();
- if( declarations == null )
- return foundSomething;
-
- obj = declarations.get( data.name );
-
- if( obj == null ){
- //not found
- return foundSomething;
- }
-
- //the contained declarations map either to a Declaration object, or to a list
- //of declaration objects.
- if( obj.getClass() == Declaration.class ){
- if( ((Declaration)obj).isType( data.type, data.upperType ) ){
- if( data.foundItems == null ){
- data.foundItems = new HashSet();
- }
- data.foundItems.add( obj );
- foundSomething = true;
- }
- } else {
- //we have to filter on type so can't just add the list whole to the fount set
- LinkedList objList = (LinkedList)obj;
- Iterator iter = objList.iterator();
- int size = objList.size();
-
- for( int i = 0; i < size; i++ ){
- temp = (Declaration) iter.next();
-
- if( temp.isType( data.type, data.upperType ) ){
- if( data.foundItems == null ){
- data.foundItems = new HashSet();
- }
- data.foundItems.add(temp);
- foundSomething = true;
- }
- }
- }
-
- return foundSomething;
- }
-
- /**
- *
- * @param data
- * @param lookIn
- * @return Declaration
- * @throws ParserSymbolTableException
- */
- private static Declaration LookupInParents( LookupData data, Declaration lookIn ) throws ParserSymbolTableException{
- LinkedList scopes = lookIn.getParentScopes();
- boolean foundSomething = false;
- Declaration temp = null;
- Declaration decl = null;
-
- Iterator iterator = null;
- Declaration.ParentWrapper wrapper = null;
-
- if( scopes == null )
- return null;
-
- //use data to detect circular inheritance
- if( data.inheritanceChain == null )
- data.inheritanceChain = new HashSet();
-
- data.inheritanceChain.add( lookIn );
-
- iterator = scopes.iterator();
-
- int size = scopes.size();
-
- for( int i = size; i > 0; i-- )
- {
- wrapper = (Declaration.ParentWrapper) iterator.next();
- if( !wrapper.isVirtual || !data.visited.contains( wrapper.parent ) ){
- if( wrapper.isVirtual ){
- data.visited.add( wrapper.parent );
- }
-
- //if the inheritanceChain already contains the parent, then that
- //is circular inheritance
- if( ! data.inheritanceChain.contains( wrapper.parent ) ){
- //is this name define in this scope?
- LookupInContained( data, wrapper.parent );
- temp = ResolveAmbiguities( data );
- if( temp == null ){
- temp = LookupInParents( data, wrapper.parent );
- }
- } else {
- throw new ParserSymbolTableException( ParserSymbolTableException.r_CircularInheritance );
- }
-
- }
-
- if( temp != null && temp.isType( data.type ) ){
-
- if( decl == null ){
- decl = temp;
- } else if ( temp != null ) {
- //it is not ambiguous if temp & decl are the same thing and it is static
- //or an enumerator
- TypeInfo type = temp.getTypeInfo();
-
- if( decl == temp && ( type.checkBit( TypeInfo.isStatic ) || type.isType( TypeInfo.t_enumerator ) ) ){
- temp = null;
- } else {
- throw( new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous ) );
- }
-
- }
- } else {
- temp = null; //reset temp for next iteration
- }
- }
-
- data.inheritanceChain.remove( lookIn );
-
- return decl;
- }
-
- /**
- * function isValidOverload
- * @param origDecl
- * @param newDecl
- * @return boolean
- *
- * 3.3.7 "A class name or enumeration name can be hidden by the name of an
- * object, function or enumerator declared in the same scope"
- *
- * 3.4-1 "Name lookup may associate more than one declaration with a name if
- * it finds the name to be a function name"
- */
- private static boolean isValidOverload( Declaration origDecl, Declaration newDecl ){
- int origType = origDecl.getType();
- int newType = newDecl.getType();
-
- if( (origType >= TypeInfo.t_class && origType <= TypeInfo.t_enumeration) && //class name or enumeration ...
- ( newType == TypeInfo.t_type || (newType >= TypeInfo.t_function && newType <= TypeInfo.typeMask) ) ){
-
- return true;
- }
- //if the origtype is not a class-name or enumeration name, then the only other
- //allowable thing is if they are both functions.
- return isValidFunctionOverload( origDecl, newDecl );
- }
-
- private static boolean isValidOverload( LinkedList origList, Declaration newDecl ){
- if( origList.size() == 1 ){
- return isValidOverload( (Declaration)origList.getFirst(), newDecl );
- } else if ( origList.size() > 1 ){
-
- //the first thing can be a class-name or enumeration name, but the rest
- //must be functions. So make sure the newDecl is a function before even
- //considering the list
- if( newDecl.getType() != TypeInfo.t_function ){
- return false;
- }
-
- Iterator iter = origList.iterator();
- Declaration decl = (Declaration) iter.next();
- boolean valid = (( decl.getType() >= TypeInfo.t_class && decl.getType() <= TypeInfo.t_enumeration ) ||
- isValidFunctionOverload( decl, newDecl ));
-
- while( valid && iter.hasNext() ){
- decl = (Declaration) iter.next();
- valid = isValidFunctionOverload( decl, newDecl );
- }
-
- return valid;
- }
-
- //empty list, return true
- return true;
- }
-
- private static boolean isValidFunctionOverload( Declaration origDecl, Declaration newDecl ){
- if( origDecl.getType() != TypeInfo.t_function || newDecl.getType() != TypeInfo.t_function ){
- return false;
- }
-
- if( origDecl.hasSameParameters( newDecl ) ){
- //functions with the same name and same parameter types cannot be overloaded if any of them
- //is static
- if( origDecl.getTypeInfo().checkBit( TypeInfo.isStatic ) || newDecl.getTypeInfo().checkBit( TypeInfo.isStatic ) ){
- return false;
- }
-
- //if none of them are static, then the function can be overloaded if they differ in the type
- //of their implicit object parameter.
- if( origDecl.getCVQualifier() != newDecl.getCVQualifier() ){
- return true;
- }
-
- return false;
- }
-
- return true;
- }
-
- /**
- *
- * @param data
- * @return Declaration
- * @throws ParserSymbolTableException
- *
- * Resolve the foundItems set down to one declaration and return that
- * declaration.
- * If we successfully resolve, then the data.foundItems list will be
- * cleared. If however, we were not able to completely resolve the set,
- * then the data.foundItems set will be left with those items that
- * survived the partial resolution and we will return null. (currently,
- * this case applies to when we have overloaded functions and no parameter
- * information)
- *
- * NOTE: data.parameters == null means there is no parameter information at
- * all, when looking for functions with no parameters, an empty list must be
- * provided in data.parameters.
- */
- static private Declaration ResolveAmbiguities( LookupData data ) throws ParserSymbolTableException{
- Declaration decl = null;
- Declaration obj = null;
- Declaration cls = null;
-
- if( data.foundItems == null ){
- return null;
- }
-
- int size = data.foundItems.size();
- Iterator iter = data.foundItems.iterator();
-
- boolean needDecl = true;
-
- if( size == 0){
- return null;
- } else if (size == 1) {
- decl = (Declaration) iter.next();
- //if it is a function we need to check its parameters
- if( !decl.isType( TypeInfo.t_function ) ){
- data.foundItems.clear();
- return decl;
- }
- needDecl = false;
- }
-
- LinkedList functionList = null;
-
- for( int i = size; i > 0; i-- ){
- //if we
- if( needDecl ){
- decl = (Declaration) iter.next();
- } else {
- needDecl = true;
- }
-
- if( decl.isType( TypeInfo.t_function ) ){
- if( functionList == null){
- functionList = new LinkedList();
- }
- functionList.add( decl );
- } else {
- //if this is a class-name, other stuff hides it
- if( decl.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) ){
- if( cls == null ) {
- cls = decl;
- } else {
- throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
- }
- } else {
- //an object, can only have one of these
- if( obj == null ){
- obj = decl;
- } else {
- throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
- }
- }
- }
-
- decl = null;
- }
-
- data.foundItems.clear();
-
- int numFunctions = ( functionList == null ) ? 0 : functionList.size();
-
- boolean ambiguous = false;
-
- if( cls != null ){
- //the class is only hidden by other stuff if they are from the same scope
- if( obj != null && cls._containingScope != obj._containingScope ){
- ambiguous = true;
- }
- if( functionList != null ){
- Iterator fnIter = functionList.iterator();
- Declaration fn = null;
- for( int i = numFunctions; i > 0; i-- ){
- fn = (Declaration) fnIter.next();
- if( cls._containingScope != fn._containingScope ){
- ambiguous = true;
- break;
- }
- }
- }
- }
-
- if( obj != null && !ambiguous ){
- if( numFunctions > 0 ){
- ambiguous = true;
- } else {
- return obj;
- }
- } else if( numFunctions > 0 ) {
- if( data.parameters == null ){
- //we have no parameter information, if we only have one function, return
- //that, otherwise we can't decide between them
- if( numFunctions == 1){
- return (Declaration) functionList.getFirst();
- } else {
- data.foundItems.addAll( functionList );
- return null;
- }
- } else {
- return ResolveFunction( data, functionList );
- }
- }
-
- if( ambiguous ){
- throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
- } else {
- return cls;
- }
- }
-
- static private Declaration ResolveFunction( LookupData data, LinkedList functions ) throws ParserSymbolTableException{
-
- ReduceToViable( data, functions );
-
- int numSourceParams = ( data.parameters == null ) ? 0 : data.parameters.size();
- int numFns = functions.size();
-
- if( numSourceParams == 0 ){
- //no parameters
- //if there is only 1 viable function, return it, if more than one, its ambiguous
- if( numFns == 0 ){
- return null;
- } else if ( numFns == 1 ){
- return (Declaration)functions.getFirst();
- } else{
- throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
- }
- }
-
- Declaration bestFn = null; //the best function
- Declaration currFn = null; //the function currently under consideration
- Cost [] bestFnCost = null; //the cost of the best function
- Cost [] currFnCost = null; //the cost for the current function
-
- Iterator iterFns = functions.iterator();
- Iterator sourceParams = null;
- Iterator targetParams = null;
-
- int numTargetParams = 0;
- int numParams = 0;
- int comparison;
- Cost cost = null;
- Cost temp = null;
-
- TypeInfo source = null;
- TypeInfo target = null;
-
- boolean hasWorse = false;
- boolean hasBetter = false;
- boolean ambiguous = false;
- boolean currHasAmbiguousParam = false;
- boolean bestHasAmbiguousParam = false;
-
- for( int i = numFns; i > 0; i-- ){
- currFn = (Declaration) iterFns.next();
-
- sourceParams = data.parameters.iterator();
- targetParams = currFn.getParameters().iterator();
-
- //number of parameters in the current function
- numTargetParams = currFn.getParameters().size();
-
- //we only need to look at the smaller number of parameters
- //(a larger number in the Target means default parameters, a larger
- //number in the source means ellipses.)
- numParams = ( numTargetParams < numSourceParams ) ? numTargetParams : numSourceParams;
-
- if( currFnCost == null ){
- currFnCost = new Cost [ numParams ];
- }
-
- comparison = 0;
-
- for( int j = 0; j < numParams; j++ ){
- source = ( TypeInfo )sourceParams.next();
- target = ( TypeInfo )targetParams.next();
- if( source.equals( target ) ){
- cost = new Cost( source, target );
- cost.rank = 0; //exact match, no cost
- } else {
- cost = checkStandardConversionSequence( source, target );
-
- if( cost.rank == -1){
- temp = checkUserDefinedConversionSequence( source, target );
- if( temp != null ){
- cost = temp;
- }
- }
- }
-
- currFnCost[ j ] = cost;
- }
-
-
- hasWorse = false;
- hasBetter = false;
-
- for( int j = 0; j < numParams; j++ ){
- if( currFnCost[ j ].rank < 0 ){
- hasWorse = true;
- hasBetter = false;
- break;
- }
-
- currHasAmbiguousParam = ( currFnCost[ j ].userDefined == 1 );
-
- if( bestFnCost != null ){
- comparison = currFnCost[ j ].compare( bestFnCost[ j ] );
- hasWorse |= ( comparison < 0 );
- hasBetter |= ( comparison > 0 );
- } else {
- hasBetter = true;
- }
- }
-
- ambiguous |= ( hasWorse && hasBetter ) || ( !hasWorse && !hasBetter );
-
- if( !hasWorse ){
- if( hasBetter ){
- ambiguous = false;
- bestFnCost = currFnCost;
- bestHasAmbiguousParam = currHasAmbiguousParam;
- currFnCost = null;
- bestFn = currFn;
- }
- }
- }
-
- if( ambiguous || bestHasAmbiguousParam ){
- throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
- }
-
- return bestFn;
- }
-
- static private void ReduceToViable( LookupData data, LinkedList functions ){
- int numParameters = ( data.parameters == null ) ? 0 : data.parameters.size();
- int num;
-
- //Trim the list down to the set of viable functions
- Declaration function;
- Iterator iter = functions.iterator();
- while( iter.hasNext() ){
- function = (Declaration) iter.next();
- num = ( function.getParameters() == null ) ? 0 : function.getParameters().size();
-
- //if there are m arguments in the list, all candidate functions having m parameters
- //are viable
- if( num == numParameters ){
- continue;
- }
- //A candidate function having fewer than m parameters is viable only if it has an
- //ellipsis in its parameter list.
- else if( num < numParameters ) {
- //TBD ellipsis
- //not enough parameters, remove it
- iter.remove();
- }
- //a candidate function having more than m parameters is viable only if the (m+1)-st
- //parameter has a default argument
- else {
- ListIterator listIter = function.getParameters().listIterator( num );
- TypeInfo param;
- for( int i = num; i > ( numParameters - num + 1); i-- ){
- param = (TypeInfo)listIter.previous();
- if( !param.getHasDefault() ){
- iter.remove();
- break;
- }
- }
- }
- }
- }
-
- /**
- * function ProcessDirectives
- * @param Declaration decl
- * @param LookupData data
- * @param LinkedList directives
- *
- * Go through the directives and for each nominated namespace find the
- * closest enclosing declaration for that namespace and decl, then add the
- * nominated namespace to the lookup data for consideration when we reach
- * the enclosing declaration.
- */
- static private void ProcessDirectives( Declaration decl, LookupData data, LinkedList directives ){
- Declaration enclosing = null;
- Declaration temp = null;
-
- int size = directives.size();
- Iterator iter = directives.iterator();
-
- for( int i = size; i > 0; i-- ){
- temp = (Declaration) iter.next();
-
- //namespaces are searched at most once
- if( !data.visited.contains( temp ) ){
- enclosing = getClosestEnclosingDeclaration( decl, temp );
-
- //the data.usingDirectives is a map from enclosing declaration to
- //a list of namespaces to consider when we reach that enclosing
- //declaration
- LinkedList list = (data.usingDirectives == null )
- ? null
- : (LinkedList) data.usingDirectives.get( enclosing );
- if ( list == null ){
- list = new LinkedList();
- list.add( temp );
- if( data.usingDirectives == null ){
- data.usingDirectives = new HashMap();
- }
- data.usingDirectives.put( enclosing, list );
- } else {
- list.add( temp );
- }
- }
- }
- }
-
- /**
- * function getClosestEnclosingDeclaration
- * @param decl1
- * @param decl2
- * @return Declaration
- *
- * 7.3.4-1 "During unqualified lookup, the names appear as if they were
- * declared in the nearest enclosing namespace which contains both the
- * using-directive and the nominated namespace"
- *
- * TBD: Consider rewriting this iteratively instead of recursively, for
- * performance
- */
- static private Declaration getClosestEnclosingDeclaration( Declaration decl1, Declaration decl2 ){
- if( decl1 == decl2 ){
- return decl1;
- }
-
- if( decl1.getDepth() == decl2.getDepth() ){
- return getClosestEnclosingDeclaration( decl1._containingScope, decl2._containingScope );
- } else if( decl1.getDepth() > decl2.getDepth() ) {
- return getClosestEnclosingDeclaration( decl1._containingScope, decl2 );
- } else {
- return getClosestEnclosingDeclaration( decl1, decl2._containingScope );
- }
- }
-
- /**
- *
- * @param obj
- * @param base
- * @return int
- * figure out if base is a base class of obj, and return the "distance" to
- * the base class.
- * ie:
- * A -> B -> C
- * the distance from A to B is 1 and from A to C is 2. This distance is used
- * to rank standard pointer conversions.
- *
- * TBD: Consider rewriting iteratively for performance.
- */
- static private int hasBaseClass( Declaration obj, Declaration base ){
- if( obj == base ){
- return 0;
- }
-
- if( obj.getParentScopes() != null ){
- Declaration decl;
- Declaration.ParentWrapper wrapper;
-
- Iterator iter = obj.getParentScopes().iterator();
- int size = obj.getParentScopes().size();
-
- for( int i = size; i > 0; i-- ){
- wrapper = (Declaration.ParentWrapper) iter.next();
- decl = wrapper.parent;
-
- if( decl == base ){
- return 1;
- } else {
- int n = hasBaseClass( decl, base );
- if( n > 0 ){
- return n + 1;
- }
- }
-
- }
- }
-
- return -1;
- }
-
- static private void getAssociatedScopes( Declaration decl, HashSet associated ){
- if( decl == null ){
- return;
- }
- //if T is a class type, its associated classes are the class itself,
- //and its direct and indirect base classes. its associated Namespaces are the
- //namespaces in which its associated classes are defined
- if( decl.getType() == TypeInfo.t_class ){
- associated.add( decl );
- getBaseClassesAndContainingNamespaces( decl, associated );
- }
- //if T is a union or enumeration type, its associated namespace is the namespace in
- //which it is defined. if it is a class member, its associated class is the member's
- //class
- else if( decl.getType() == TypeInfo.t_union || decl.getType() == TypeInfo.t_enumeration ){
- associated.add( decl._containingScope );
- }
- }
-
- static private void getBaseClassesAndContainingNamespaces( Declaration obj, HashSet classes ){
- if( obj.getParentScopes() != null ){
- if( classes == null ){
- return;
- }
-
- Iterator iter = obj.getParentScopes().iterator();
- int size = obj.getParentScopes().size();
- Declaration.ParentWrapper wrapper;
- Declaration base;
-
- for( int i = size; i > 0; i-- ){
- wrapper = (Declaration.ParentWrapper) iter.next();
- base = (Declaration) wrapper.parent;
- classes.add( base );
- if( base._containingScope.getType() == TypeInfo.t_namespace ){
- classes.add( base._containingScope );
- }
-
- getBaseClassesAndContainingNamespaces( base, classes );
- }
- }
- }
-
- static private boolean okToAddUsingDeclaration( Declaration obj, Declaration context ){
- boolean okToAdd = false;
-
- //7.3.3-4
- if( context.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
- //a member of a base class
- if( obj.getContainingScope().getType() == context.getType() ){
- okToAdd = ( hasBaseClass( context, obj.getContainingScope() ) > 0 );
- }
- //TBD : a member of an _anonymous_ union
- else if ( obj.getContainingScope().getType() == TypeInfo.t_union ) {
- Declaration union = obj.getContainingScope();
- okToAdd = ( hasBaseClass( context, union.getContainingScope() ) > 0 );
- }
- //an enumerator for an enumeration
- else if ( obj.getType() == TypeInfo.t_enumerator ){
- Declaration enumeration = obj.getContainingScope();
- okToAdd = ( hasBaseClass( context, enumeration.getContainingScope() ) > 0 );
- }
- } else {
- okToAdd = true;
- }
-
- return okToAdd;
- }
-
- static private Cost lvalue_to_rvalue( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException{
- //lvalues will have type t_type
- if( source.isType( TypeInfo.t_type ) ){
- source = getFlatTypeInfo( source );
- }
-
- String sourcePtr = source.getPtrOperator();
- String targetPtr = target.getPtrOperator();
-
- if( sourcePtr != null && sourcePtr.length() > 0 ){
- char sourcePtrArray [] = sourcePtr.toCharArray();
- if( sourcePtrArray[ 0 ] == '&' ){
- source.setPtrOperator( new String(sourcePtrArray, 1, sourcePtr.length() - 1 ) );
- }
- }
-
- if( targetPtr != null && targetPtr.length() > 0 ){
- char targetPtrArray [] = targetPtr.toCharArray();
- if( targetPtrArray[ 0 ] == '&' ){
- target.setPtrOperator ( new String( targetPtrArray, 1, targetPtr.length() - 1 ) );
- }
- }
-
- Cost cost = new Cost( source, target );
-
- return cost;
- }
-
- static private void qualificationConversion( Cost cost ){
- if( cost.source.getCVQualifier() == cost.target.getCVQualifier() ||
- ( cost.target.getCVQualifier() - cost.source.getCVQualifier()) > 1 )
- {
- cost.qualification = cost.target.getCVQualifier() + 1;
- cost.rank = 0;
- } else {
- cost.qualification = 0;
- }
- }
-
- /**
- *
- * @param source
- * @param target
- * @return int
- *
- * 4.5-1 char, signed char, unsigned char, short int or unsigned short int
- * can be converted to int if int can represent all the values of the source
- * type, otherwise they can be converted to unsigned int.
- * 4.5-2 wchar_t or an enumeration can be converted to the first of the
- * following that can hold it: int, unsigned int, long unsigned long.
- * 4.5-4 bool can be promoted to int
- * 4.6 float can be promoted to double
- */
- static private void promotion( Cost cost ){
- TypeInfo src = cost.source;
- TypeInfo trg = cost.target;
-
- int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isUnsigned;
-
- if( (src.isType( TypeInfo.t_bool, TypeInfo.t_float ) || src.isType( TypeInfo.t_enumeration )) &&
- (trg.isType( TypeInfo.t_int ) || trg.isType( TypeInfo.t_double )) )
- {
- if( src.getType() == trg.getType() && (( src.getTypeInfo() & mask) == (trg.getTypeInfo() & mask)) ){
- //same, no promotion needed
- return;
- }
-
- if( src.isType( TypeInfo.t_float ) ){
- cost.promotion = trg.isType( TypeInfo.t_double ) ? 1 : 0;
- } else {
- cost.promotion = ( trg.isType( TypeInfo.t_int ) && trg.canHold( src ) ) ? 1 : 0;
- }
-
- } else {
- cost.promotion = 0;
- }
-
- cost.rank = (cost.promotion > 0 ) ? 1 : -1;
- }
-
- /**
- *
- * @param source
- * @param target
- * @return int
- *
- */
- static private void conversion( Cost cost ){
- TypeInfo src = cost.source;
- TypeInfo trg = cost.target;
-
- int temp;
-
- String tempStr = src.getPtrOperator();
- String srcPtr = ( tempStr == null ) ? new String("") : tempStr;
-
- tempStr = trg.getPtrOperator();
- String trgPtr = ( tempStr == null ) ? new String("") : tempStr;
-
- cost.conversion = 0;
- cost.detail = 0;
-
- if( !srcPtr.equals( trgPtr ) ){
- return;
- }
- if( srcPtr.equals("*") ){
- Declaration srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeDeclaration() : null;
- Declaration trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeDeclaration() : null;
-
- if( srcDecl == null || (trgDecl == null && !trg.isType( TypeInfo.t_void )) ){
- return;
- }
-
- //4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
- //converted to an rvalue of type "pointer to cv void"
- if( trg.isType( TypeInfo.t_void ) ){
- cost.rank = 2;
- cost.conversion = 1;
- cost.detail = 2;
- return;
- }
-
- cost.detail = 1;
-
- //4.10-3 An rvalue of type "pointer to cv D", where D is a class type can be converted
- // to an rvalue of type "pointer to cv B", where B is a base class of D.
- if( srcDecl.isType( TypeInfo.t_class ) && trgDecl.isType( TypeInfo.t_class ) ){
- temp = hasBaseClass( srcDecl, trgDecl );
- cost.rank = 2;
- cost.conversion = ( temp > -1 ) ? temp : 0;
- cost.detail = 1;
- return;
- }
-
- //4.11-2 An rvalue of type "pointer to member of B of type cv T", where B is a class type,
- //can be converted to an rvalue of type "pointer to member of D of type cv T" where D is a
- //derived class of B
- if( srcDecl._containingScope.isType( TypeInfo.t_class ) && trgDecl._containingScope.isType( TypeInfo.t_class ) ){
- temp = hasBaseClass( trgDecl._containingScope, srcDecl._containingScope );
- cost.rank = 2;
- cost.conversion = ( temp > -1 ) ? temp : 0;
- return;
- }
- } else {
- //4.7 An rvalue of an integer type can be converted to an rvalue of another integer type.
- //An rvalue of an enumeration type can be converted to an rvalue of an integer type.
- if( src.isType( TypeInfo.t_bool, TypeInfo.t_int ) ||
- src.isType( TypeInfo.t_float, TypeInfo.t_double ) ||
- src.isType( TypeInfo.t_enumeration ) )
- {
- if( trg.isType( TypeInfo.t_bool, TypeInfo.t_int ) ||
- trg.isType( TypeInfo.t_float, TypeInfo.t_double ) )
- {
- cost.rank = 2;
- cost.conversion = 1;
- }
- }
- }
- }
-
- static private Cost checkStandardConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException {
- Cost cost = lvalue_to_rvalue( source, target );
-
- if( cost.source.equals( cost.target ) ){
- cost.rank = 0;
- return cost;
- }
-
- qualificationConversion( cost );
-
- //if we can't convert the qualifications, then we can't do anything
- if( cost.qualification == 0 ){
- return cost;
- }
-
- promotion( cost );
- if( cost.promotion > 0 || cost.rank > -1 ){
- return cost;
- }
-
- conversion( cost );
-
- return cost;
- }
-
- static private Cost checkUserDefinedConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException {
- Cost cost = null;
- Cost constructorCost = null;
- Cost conversionCost = null;
-
- Declaration targetDecl = null;
- Declaration sourceDecl = null;
- Declaration constructor = null;
- Declaration conversion = null;
-
- //constructors
- if( target.getType() == TypeInfo.t_type ){
- targetDecl = target.getTypeDeclaration();
- if( targetDecl.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
- LookupData data = new LookupData( "", TypeInfo.t_function );
- LinkedList params = new LinkedList();
- params.add( source );
- data.parameters = params;
- LookupInContained( data, targetDecl );
- constructor = ResolveAmbiguities( data );
- }
- }
-
- //conversion operators
- if( source.getType() == TypeInfo.t_type ){
- source = getFlatTypeInfo( source );
- sourceDecl = source.getTypeDeclaration();
-
- if( sourceDecl != null ){
- String name = target.toString();
-
- if( !name.equals("") ){
- LookupData data = new LookupData( "operator " + name, TypeInfo.t_function );
- LinkedList params = new LinkedList();
- data.parameters = params;
-
- LookupInContained( data, sourceDecl );
- conversion = ResolveAmbiguities( data );
- }
- }
- }
-
- if( constructor != null ){
- constructorCost = checkStandardConversionSequence( new TypeInfo( TypeInfo.t_type, constructor._containingScope ), target );
- }
- if( conversion != null ){
- conversionCost = checkStandardConversionSequence( new TypeInfo( target.getType(), target.getTypeDeclaration() ), target );
- }
-
- //if both are valid, then the conversion is ambiguous
- if( constructorCost != null && constructorCost.rank != -1 &&
- conversionCost != null && conversionCost.rank != -1 )
- {
- cost = constructorCost;
- cost.userDefined = 1;
- cost.rank = 3;
- } else {
- if( constructorCost != null && constructorCost.rank != -1 ){
- cost = constructorCost;
- cost.userDefined = constructor.hashCode();
- cost.rank = 3;
- } else if( conversionCost != null && conversionCost.rank != -1 ){
- cost = conversionCost;
- cost.userDefined = conversion.hashCode();
- cost.rank = 3;
- }
- }
-
- return cost;
- }
-
- /**
- *
- * @param decl
- * @return TypeInfo
- * @throws ParserSymbolTableException
- * The top level TypeInfo represents modifications to the object and the
- * remaining TypeInfo's represent the object.
- */
- static private TypeInfo getFlatTypeInfo( TypeInfo topInfo ) throws ParserSymbolTableException {
- TypeInfo returnInfo = topInfo;
- TypeInfo info = null;
-
- if( topInfo.getType() == TypeInfo.t_type ){
- returnInfo = new TypeInfo();
-
- Declaration typeDecl = topInfo.getTypeDeclaration();
-
- info = topInfo.getTypeDeclaration().getTypeInfo();
-
- while( info.getType() == TypeInfo.t_type ){
- typeDecl = info.getTypeDeclaration();
-
- returnInfo.addCVQualifier( info.getCVQualifier() );
- returnInfo.addPtrOperator( info.getPtrOperator() );
-
- info = info.getTypeDeclaration().getTypeInfo();
- }
-
- if( info.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) ){
- returnInfo.setType( TypeInfo.t_type );
- returnInfo.setTypeDeclaration( typeDecl );
- } else {
- returnInfo.setTypeInfo( info.getTypeInfo() );
- returnInfo.setTypeDeclaration( null );
- }
-
- String ptrOp = returnInfo.getPtrOperator();
- returnInfo.setPtrOperator( topInfo.getInvertedPtrOperator() );
-
- if( ptrOp != null ){
- returnInfo.addPtrOperator( ptrOp );
- }
-
- returnInfo.setCVQualifier( info.getCVQualifier() );
- returnInfo.addCVQualifier( topInfo.getCVQualifier() );
- }
-
- return returnInfo;
- }
-
-
- //private Stack _contextStack = new Stack();
- private Declaration _compilationUnit;
- private LinkedList undoList = new LinkedList();
-
- static abstract private class Command{
- abstract public void undoIt();
- }
-
- static private class AddDeclarationCommand extends Command{
- AddDeclarationCommand( Declaration newDecl, Declaration context, boolean removeThis ){
- _decl = newDecl;
- _context = context;
- _removeThis = removeThis;
- }
- public void undoIt(){
- Object obj = _context.getContainedDeclarations().get( _decl.getName() );
-
- if( obj instanceof LinkedList ){
- LinkedList list = (LinkedList)obj;
- ListIterator iter = list.listIterator();
- int size = list.size();
- Declaration item = null;
- for( int i = 0; i < size; i++ ){
- item = (Declaration)iter.next();
- if( item == _decl ){
- iter.remove();
- break;
- }
- }
- if( list.size() == 1 ){
- _context.getContainedDeclarations().remove( _decl.getName() );
- _context.getContainedDeclarations().put( _decl.getName(), list.getFirst() );
- }
- } else if( obj instanceof Declaration ){
- _context.getContainedDeclarations().remove( _decl.getName() );
- }
- if( _removeThis ){
- _context.getContainedDeclarations().remove( "this" );
- }
- }
-
- private Declaration _decl;
- private Declaration _context;
- private boolean _removeThis;
- }
-
- static private class LookupData
- {
-
- public String name;
- public Map usingDirectives;
- public Set visited = new HashSet(); //used to ensure we don't visit things more than once
-
- public HashSet inheritanceChain; //used to detect circular inheritance
-
- public LinkedList parameters; //parameter info for resolving functions
- public HashSet associated; //associated namespaces for argument dependant lookup
- public Declaration stopAt; //stop looking along the stack once we hit this declaration
-
- public int type = -1;
- public int upperType = 0;
- public boolean qualified = false;
- public boolean ignoreUsingDirectives = false;
-
- public HashSet foundItems = null;
-
- public LookupData( String n, int t ){
- name = n;
- type = t;
- }
- }
-
- static private class Cost
- {
- public Cost( TypeInfo s, TypeInfo t ){
- source = s;
- target = t;
- }
-
- public TypeInfo source;
- public TypeInfo target;
-
- public int lvalue;
- public int promotion;
- public int conversion;
- public int qualification;
- public int userDefined;
- public int rank = -1;
- public int detail;
-
- public int compare( Cost cost ){
- int result = 0;
-
- if( rank != cost.rank ){
- return cost.rank - rank;
- }
-
- if( userDefined != 0 || cost.userDefined != 0 ){
- if( userDefined == 0 || cost.userDefined == 0 ){
- return cost.userDefined - userDefined;
- } else {
- if( (userDefined == 1 || cost.userDefined == 1) ||
- (userDefined != cost.userDefined ) )
- {
- return 0;
- }
- // else they are the same constructor/conversion operator and are ranked
- //on the standard conversion sequence
- }
- }
-
- if( promotion > 0 || cost.promotion > 0 ){
- result = cost.promotion - promotion;
- }
- if( conversion > 0 || cost.conversion > 0 ){
- if( detail == cost.detail ){
- result = cost.conversion - conversion;
- } else {
- result = cost.detail - detail;
- }
- }
-
- if( result == 0 ){
- result = cost.qualification - qualification;
- }
-
- return result;
- }
- }
-
- public class Declaration implements Cloneable, ISymbol {
-
- /**
- * Constructor for Declaration.
- */
- public Declaration(){
- super();
- _typeInfo = new TypeInfo();
- }
-
- public Declaration( String name ){
- super();
- _name = name;
- _typeInfo = new TypeInfo();
- }
-
- public Declaration( String name, Object obj ){
- super();
- _name = name;
- _object = obj;
- _typeInfo = new TypeInfo();
- }
-
- /**
- * clone
- * @see java.lang.Object#clone()
- *
- * implement clone for the purposes of using declarations.
- * int _typeInfo; //by assignment
- * String _name; //by assignment
- * Object _object; //null this out
- * Declaration _typeDeclaration; //by assignment
- * Declaration _containingScope; //by assignment
- * LinkedList _parentScopes; //shallow copy
- * LinkedList _usingDirectives; //shallow copy
- * HashMap _containedDeclarations; //shallow copy
- * int _depth; //by assignment
- */
- public Object clone(){
- Declaration copy = null;
- try{
- copy = (Declaration)super.clone();
- }
- catch ( CloneNotSupportedException e ){
- //should not happen
- return null;
- }
-
- copy._object = null;
- copy._parentScopes = ( _parentScopes != null ) ? (LinkedList) _parentScopes.clone() : null;
- copy._usingDirectives = ( _usingDirectives != null ) ? (LinkedList) _usingDirectives.clone() : null;
- copy._containedDeclarations = ( _containedDeclarations != null ) ? (HashMap) _containedDeclarations.clone() : null;
- copy._parameters = ( _parameters != null ) ? (LinkedList) _parameters.clone() : null;
-
- return copy;
- }
-
- public void setType(int t) throws ParserSymbolTableException{
- _typeInfo.setType( t );
- }
-
- public int getType(){
- return _typeInfo.getType();
- }
-
- public boolean isType( int type ){
- return _typeInfo.isType( type, 0 );
- }
-
- public boolean isType( int type, int upperType ){
- return _typeInfo.isType( type, upperType );
- }
-
- public Declaration getTypeDeclaration(){
- return _typeInfo.getTypeDeclaration();
- }
-
- public void setTypeDeclaration( Declaration type ){
- _typeInfo.setTypeDeclaration( type );
- }
-
- public TypeInfo getTypeInfo(){
- return _typeInfo;
- }
-
- public String getName() { return _name; }
- public void setName(String name) { _name = name; }
-
- public Object getObject() { return _object; }
- public void setObject( Object obj ) { _object = obj; }
-
- public Declaration getContainingScope() { return _containingScope; }
- protected void setContainingScope( Declaration scope ){
- _containingScope = scope;
- _depth = scope._depth + 1;
- }
-
- private int getDepth(){
- return _depth;
- }
-
- public void addParent( Declaration parent ){
- addParent( parent, false );
- }
- public void addParent( Declaration parent, boolean virtual ){
- if( _parentScopes == null ){
- _parentScopes = new LinkedList();
- }
-
- _parentScopes.add( new ParentWrapper( parent, virtual ) );
- }
-
- public Map getContainedDeclarations(){
- return _containedDeclarations;
- }
-
- public Map createContained(){
- if( _containedDeclarations == null )
- _containedDeclarations = new HashMap();
-
- return _containedDeclarations;
- }
-
- public LinkedList getParentScopes(){
- return _parentScopes;
- }
-
- public boolean needsDefinition(){
- return _needsDefinition;
- }
- public void setNeedsDefinition( boolean need ) {
- _needsDefinition = need;
- }
-
- public int getCVQualifier(){
- return _cvQualifier;
- }
-
- public void setCVQualifier( int cv ){
- _cvQualifier = cv;
- }
-
- public String getPtrOperator(){
- return _typeInfo.getPtrOperator();
- }
- public void setPtrOperator( String ptrOp ){
- _typeInfo.setPtrOperator( ptrOp );
- }
-
- public int getReturnType(){
- return _returnType;
- }
-
- public void setReturnType( int type ){
- _returnType = type;
- }
-
- public LinkedList getParameters(){
- return _parameters;
- }
-
- public void addParameter( Declaration typeDecl, int cvQual, String ptrOperator, boolean hasDefault ){
- if( _parameters == null ){
- _parameters = new LinkedList();
- }
-
- TypeInfo info = new TypeInfo( TypeInfo.t_type, typeDecl, cvQual, ptrOperator, hasDefault );
-
- _parameters.add( info );
- }
-
- public void addParameter( int type, int cvQual, String ptrOperator, boolean hasDefault ){
- if( _parameters == null ){
- _parameters = new LinkedList();
- }
-
- TypeInfo info = new TypeInfo(type, null, cvQual, ptrOperator, hasDefault );
-
- _parameters.add( info );
- }
-
- public boolean hasSameParameters( Declaration function ){
- if( function.getType() != getType() ){
- return false;
- }
-
- int size = getParameters().size();
- if( function.getParameters().size() != size ){
- return false;
- }
-
- Iterator iter = getParameters().iterator();
- Iterator fIter = function.getParameters().iterator();
-
- TypeInfo info = null;
- TypeInfo fInfo = null;
-
- for( int i = size; i > 0; i-- ){
- info = (TypeInfo) iter.next();
- fInfo = (TypeInfo) fIter.next();
-
- if( !info.equals( fInfo ) ){
- return false;
- }
- }
-
-
- return true;
- }
-
- public void addDeclaration( Declaration obj ) throws ParserSymbolTableException{
- Declaration containing = this;
-
- //handle enumerators
- if( obj.getType() == TypeInfo.t_enumerator ){
- //a using declaration of an enumerator will not be contained in a
- //enumeration.
- if( containing.getType() == TypeInfo.t_enumeration ){
- //Following the closing brace of an enum-specifier, each enumerator has the type of its
- //enumeration
- obj.setTypeDeclaration( containing );
- //Each enumerator is declared in the scope that immediately contains the enum-specifier
- containing = containing.getContainingScope();
- }
- }
-
- Map declarations = containing.getContainedDeclarations();
-
- boolean unnamed = obj.getName().equals( "" );
-
- Object origObj = null;
-
- obj.setContainingScope( containing );
-
- if( declarations == null ){
- declarations = containing.createContained();
- } else {
- //does this name exist already?
- origObj = declarations.get( obj.getName() );
- }
-
- if( origObj != null )
- {
- Declaration origDecl = null;
- LinkedList origList = null;
-
- if( origObj.getClass() == Declaration.class ){
- origDecl = (Declaration)origObj;
- } else if( origObj.getClass() == LinkedList.class ){
- origList = (LinkedList)origObj;
- } else {
- throw new ParserSymbolTableException();
- }
-
- if( unnamed || (origList == null) ? isValidOverload( origDecl, obj ) : isValidOverload( origList, obj ) ){
- if( origList == null ){
- origList = new LinkedList();
- origList.add( origDecl );
- origList.add( obj );
-
- declarations.remove( obj );
- declarations.put( obj.getName(), origList );
- } else {
- origList.add( obj );
- //origList is already in _containedDeclarations
- }
- } else {
- throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidOverload );
- }
- } else {
- declarations.put( obj.getName(), obj );
- }
-
- //take care of the this pointer
- TypeInfo type = obj.getTypeInfo();
- boolean addedThis = false;
- if( type.isType( TypeInfo.t_function ) && !type.checkBit( TypeInfo.isStatic ) ){
- addThis( obj );
- addedThis = true;
- }
-
- Command command = new AddDeclarationCommand( obj, containing, addedThis );
- }
-
- /**
- *
- * @param obj
- * @throws ParserSymbolTableException
- * 9.3.2-1 In the body of a nonstatic member function... the type of this of
- * a class X is X*. If the member function is declared const, the type of
- * this is const X*, if the member function is declared volatile, the type
- * of this is volatile X*....
- */
- private void addThis( Declaration obj ) throws ParserSymbolTableException{
- TypeInfo type = obj.getTypeInfo();
- if( !type.isType( TypeInfo.t_function ) || type.checkBit( TypeInfo.isStatic ) ){
- return;
- }
-
- if( obj.getContainingScope().isType( TypeInfo.t_class, TypeInfo.t_union ) ){
- //check to see if there is already a this object, since using declarations
- //of function will have them from the original declaration
- LookupData data = new LookupData( "this", -1 );
- LookupInContained( data, obj );
- //if we didn't find "this" then foundItems will still be null, no need to actually
- //check its contents
- if( data.foundItems == null ){
- Declaration thisObj = new Declaration("this");
- thisObj.setType( TypeInfo.t_type );
- thisObj.setTypeDeclaration( obj.getContainingScope() );
- thisObj.setCVQualifier( obj.getCVQualifier() );
- thisObj.setPtrOperator("*");
-
- obj.addDeclaration( thisObj );
- }
- }
- }
-
- /**
- *
- * @param name
- * @return Declaration
- * @throws ParserSymbolTableException
- *
- * 7.3.1.2-3 If a friend declaration in a non-local class first declares a
- * class or function, the friend class or function is a member of the
- * innermost enclosing namespace.
- *
- * TBD: if/when the parser symbol table starts caring about visibility
- * (public/protected/private) we will need to do more to record friendship.
- */
- public Declaration addFriend( String name ) throws ParserSymbolTableException{
- Declaration friend = LookupForFriendship( name );
-
- if( friend == null ){
- friend = new Declaration( name );
- friend.setNeedsDefinition( true );
-
- Declaration containing = getContainingScope();
- //find innermost enclosing namespace
- while( containing != null && containing.getType() != TypeInfo.t_namespace ){
- containing = containing.getContainingScope();
- }
-
- Declaration namespace = ( containing == null ) ? ParserSymbolTable.this.getCompilationUnit() : containing;
- namespace.addDeclaration( friend );
- }
-
- return friend;
- }
-
- /**
- * LookupForFriendship
- * @param name
- * @return Declaration
- * 7.3.1.2-3 When looking for a prior declaration of a class or a function
- * declared as a friend, scopes outside the innermost enclosing namespace
- * scope are not considered.
- * 11.4-9 If a friend declaration appears in a local class and the name
- * specified is an unqualified name, a prior declaration is looked up
- * without considering scopes that are outside the innermost enclosing non-
- * class scope.
- */
- private Declaration LookupForFriendship( String name ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, -1 );
-
- boolean inClass = ( getType() == TypeInfo.t_class);
-
- Declaration enclosing = getContainingScope();
- while( enclosing != null && (inClass ? enclosing.getType() != TypeInfo.t_class
- : enclosing.getType() == TypeInfo.t_namespace) )
- {
- enclosing = enclosing.getContainingScope();
- }
-
- data.stopAt = enclosing;
-
- ParserSymbolTable.Lookup( data, this );
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- /**
- * addUsingDeclaration
- * @param obj
- * @throws ParserSymbolTableException
- *
- * 7.3.3-9 The entity declared by a using-declaration shall be known in the
- * context using it according to its definition at the point of the using-
- * declaration. Definitions added to the namespace after the using-
- * declaration are not considered when a use of the name is made.
- *
- * 7.3.3-4 A using-declaration used as a member-declaration shall refer to a
- * member of a base class of the class being defined, shall refer to a
- * member of an anonymous union that is a member of a base class of the
- * class being defined, or shall refer to an enumerator for an enumeration
- * type that is a member of a base class of the class being defined.
- */
- public Declaration addUsingDeclaration( String name ) throws ParserSymbolTableException {
- return addUsingDeclaration( name, null );
- }
-
- public Declaration addUsingDeclaration( String name, Declaration declContext ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, -1 );
-
- if( declContext != null ){
- data.qualified = true;
- ParserSymbolTable.Lookup( data, declContext );
- } else {
- ParserSymbolTable.Lookup( data, this );
- }
-
- //figure out which declaration we are talking about, if it is a set of functions,
- //then they will be in data.foundItems (since we provided no parameter info);
- Declaration obj = ParserSymbolTable.ResolveAmbiguities( data );
-
- if( data.foundItems == null ){
- throw new ParserSymbolTableException();
- }
-
- Declaration clone = null;
-
- //if obj != null, then that is the only object to consider, so size is 1,
- //otherwise we consider the foundItems set
- int size = ( obj == null ) ? data.foundItems.size() : 1;
- Iterator iter = data.foundItems.iterator();
- for( int i = size; i > 0; i-- ){
- obj = ( obj != null && size == 1 ) ? obj : (Declaration) iter.next();
-
- if( ParserSymbolTable.okToAddUsingDeclaration( obj, this ) ){
- clone = (Declaration) obj.clone(); //7.3.3-9
- addDeclaration( clone );
- } else {
- throw new ParserSymbolTableException();
- }
- }
-
- return ( size == 1 ) ? clone : null;
- }
-
- public void addUsingDirective( Declaration namespace ) throws ParserSymbolTableException{
- if( namespace.getType() != TypeInfo.t_namespace ){
- throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
- }
-
- if( _usingDirectives == null ){
- _usingDirectives = new LinkedList();
- }
-
- _usingDirectives.add( namespace );
- }
-
- public LinkedList getUsingDirectives(){
- return _usingDirectives;
- }
-
- public Declaration ElaboratedLookup( int type, String name ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, type );
-
- ParserSymbolTable.Lookup( data, this );
-
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- public Declaration Lookup( String name ) throws ParserSymbolTableException {
- LookupData data = new LookupData( name, -1 );
-
- ParserSymbolTable.Lookup( data, this );
-
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- /**
- * LookupMemberForDefinition
- * @param name
- * @return Declaration
- * @throws ParserSymbolTableException
- *
- * In a definition for a namespace member in which the declarator-id is a
- * qualified-id, given that the qualified-id for the namespace member has
- * the form "nested-name-specifier unqualified-id", the unqualified-id shall
- * name a member of the namespace designated by the nested-name-specifier.
- *
- * ie:
- * you have this:
- * namespace A{
- * namespace B{
- * void f1(int);
- * }
- * using namespace B;
- * }
- *
- * if you then do this
- * void A::f1(int) { ... } //ill-formed, f1 is not a member of A
- * but, you can do this (Assuming f1 has been defined elsewhere)
- * A::f1( 1 ); //ok, finds B::f1
- *
- * ie, We need a seperate lookup function for looking up the member names
- * for a definition.
- */
- public Declaration LookupMemberForDefinition( String name ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, -1 );
- data.qualified = true;
-
- ParserSymbolTable.LookupInContained( data, this );
-
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- /**
- * Method LookupNestedNameSpecifier.
- * @param name
- * @return Declaration
- * The name of a class or namespace member can be referred to after the ::
- * scope resolution operator applied to a nested-name-specifier that
- * nominates its class or namespace. During the lookup for a name preceding
- * the ::, object, function and enumerator names are ignored. If the name
- * is not a class-name or namespace-name, the program is ill-formed
- */
- public Declaration LookupNestedNameSpecifier( String name ) throws ParserSymbolTableException {
- return LookupNestedNameSpecifier( name, this );
- }
- private Declaration LookupNestedNameSpecifier(String name, Declaration inDeclaration ) throws ParserSymbolTableException{
- Declaration foundDeclaration = null;
-
- LookupData data = new LookupData( name, TypeInfo.t_namespace );
- data.upperType = TypeInfo.t_union;
-
- ParserSymbolTable.LookupInContained( data, inDeclaration );
-
- if( data.foundItems != null ){
- foundDeclaration = ParserSymbolTable.ResolveAmbiguities( data );//, data.foundItems );
- }
-
- if( foundDeclaration == null && inDeclaration.getContainingScope() != null ){
- foundDeclaration = LookupNestedNameSpecifier( name, inDeclaration.getContainingScope() );
- }
-
- return foundDeclaration;
- }
-
- /**
- * MemberFunctionLookup
- * @param name
- * @param parameters
- * @return Declaration
- * @throws ParserSymbolTableException
- *
- * Member lookup really proceeds as an unqualified lookup, but doesn't
- * include argument dependant scopes
- */
- public Declaration MemberFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, TypeInfo.t_function );
- //if parameters == null, thats no parameters, but we need to distinguish that from
- //no parameter information at all, so make an empty list.
- data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
-
- ParserSymbolTable.Lookup( data, this );
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- public Declaration QualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, TypeInfo.t_function );
- data.qualified = true;
- //if parameters == null, thats no parameters, but we need to distinguish that from
- //no parameter information at all, so make an empty list.
- data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
-
- ParserSymbolTable.Lookup( data, this );
-
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- public Declaration QualifiedLookup( String name ) throws ParserSymbolTableException{
- LookupData data = new LookupData( name, -1 );
- data.qualified = true;
- ParserSymbolTable.Lookup( data, this );
-
- return ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- /**
- * UnqualifiedFunctionLookup
- * @param name
- * @param parameters
- * @return Declaration
- * @throws ParserSymbolTableException
- *
- * 3.4.2-1 When an unqualified name is used as the post-fix expression in a
- * function call, other namespaces not consdiered during the usual
- * unqualified lookup may be searched.
- *
- * 3.4.2-2 For each argument type T in the function call, there is a set of
- * zero or more associated namespaces and a set of zero or more associated
- * classes to be considered.
- *
- * If the ordinary unqualified lookup of the name find the declaration of a
- * class member function, the associated namespaces and classes are not
- * considered. Otherwise, the set of declarations found by the lookup of
- * the function name is the union of the set of declarations found using
- * ordinary unqualified lookup and the set of declarations found in the
- * namespaces and classes associated with the argument types.
- */
- public Declaration UnqualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException{
- //figure out the set of associated scopes first, so we can remove those that are searched
- //during the normal lookup to avoid doing them twice
- HashSet associated = new HashSet();
-
- //collect associated namespaces & classes.
- int size = ( parameters == null ) ? 0 : parameters.size();
- Iterator iter = ( parameters == null ) ? null : parameters.iterator();
-
- TypeInfo param = null;
- Declaration paramType = null;
- for( int i = size; i > 0; i-- ){
- param = (TypeInfo) iter.next();
- paramType = ParserSymbolTable.getFlatTypeInfo( param ).getTypeDeclaration();
-
- ParserSymbolTable.getAssociatedScopes( paramType, associated );
-
- //if T is a pointer to a data member of class X, its associated namespaces and classes
- //are those associated with the member type together with those associated with X
- if( param.getPtrOperator() != null &&
- (param.getPtrOperator().equals("*") || param.getPtrOperator().equals("[]")) &&
- paramType.getContainingScope().isType( TypeInfo.t_class, TypeInfo.t_union ) )
- {
- ParserSymbolTable.getAssociatedScopes( paramType.getContainingScope(), associated );
- }
- }
-
- LookupData data = new LookupData( name, TypeInfo.t_function );
- //if parameters == null, thats no parameters, but we need to distinguish that from
- //no parameter information at all, so make an empty list.
- data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
- data.associated = associated;
-
- ParserSymbolTable.Lookup( data, this );
-
- Declaration found = ResolveAmbiguities( data );
-
- //if we haven't found anything, or what we found is not a class member, consider the
- //associated scopes
- if( found == null || found.getContainingScope().getType() != TypeInfo.t_class ){
- if( found != null ){
- data.foundItems.add( found );
- }
-
- Declaration decl;
- Declaration temp;
-
- //dump the hash to an array and iterate over the array because we
- //could be removing items from the collection as we go and we don't
- //want to get ConcurrentModificationExceptions
- Object [] scopes = associated.toArray();
-
- size = associated.size();
-
- for( int i = 0; i < size; i++ ){
- decl = (Declaration) scopes[ i ];
- if( associated.contains( decl ) ){
- data.qualified = true;
- data.ignoreUsingDirectives = true;
- ParserSymbolTable.Lookup( data, decl );
- }
- }
-
- found = ParserSymbolTable.ResolveAmbiguities( data );
- }
-
- return found;
- }
-
- private String _name; //our name
- private Object _object; //the object associated with us
- private boolean _needsDefinition; //this name still needs to be defined
- private int _cvQualifier;
-
- private TypeInfo _typeInfo; //our type info
- private Declaration _containingScope; //the scope that contains us
- private LinkedList _parentScopes; //inherited scopes (is base classes)
- private LinkedList _usingDirectives; //collection of nominated namespaces
- private HashMap _containedDeclarations; //declarations contained by us.
-
- private LinkedList _parameters; //parameter list
- private int _returnType;
-
- private int _depth; //how far down the scope stack we are
-
- protected class ParentWrapper
- {
- public ParentWrapper( Declaration p, boolean v ){
- parent = p;
- isVirtual = v;
- }
-
- public boolean isVirtual = false;
- public Declaration parent = null;
- }
- }
-
- static public class TypeInfo{
- public TypeInfo(){
- super();
- }
-
- public TypeInfo( int type, Declaration decl ){
- super();
- _typeInfo = type;
- _typeDeclaration = decl;
- }
-
- public TypeInfo( int type, Declaration decl, int cvQualifier, String ptrOp, boolean hasDefault ){
- super();
- _typeInfo = type;
- _typeDeclaration = decl;
- _cvQualifier = cvQualifier;
- _ptrOperator = ( ptrOp != null ) ? new String( ptrOp ) : null;
- _hasDefaultValue = hasDefault;
- }
-
- public TypeInfo( TypeInfo info ){
- super();
-
- _typeInfo = info._typeInfo;
- _typeDeclaration = info._typeDeclaration;
- _cvQualifier = info._cvQualifier;
- _ptrOperator = ( info._ptrOperator == null ) ? null : new String( info._ptrOperator );
- _hasDefaultValue = info._hasDefaultValue;
- }
-
- public static final int typeMask = 0x001f;
- public static final int isAuto = 0x0020;
- public static final int isRegister = 0x0040;
- public static final int isStatic = 0x0080;
- public static final int isExtern = 0x0100;
- public static final int isMutable = 0x0200;
- public static final int isInline = 0x0400;
- public static final int isVirtual = 0x0800;
- public static final int isExplicit = 0x1000;
- public static final int isTypedef = 0x2000;
- public static final int isFriend = 0x4000;
- public static final int isConst = 0x8000;
- public static final int isVolatile = 0x10000;
- public static final int isUnsigned = 0x20000;
- public static final int isShort = 0x40000;
- public static final int isLong = 0x80000;
-
- // Types (maximum type is typeMask
- // Note that these should be considered ordered and if you change
- // the order, you should consider the ParserSymbolTable uses
- public static final int t_undef = 0; //not specified
- public static final int t_type = 1; // Type Specifier
- public static final int t_namespace = 2;
- public static final int t_class = 3;
- public static final int t_struct = 4;
- public static final int t_union = 5;
- public static final int t_enumeration = 6;
- public static final int t_function = 7;
- public static final int t_bool = 8;
- public static final int t_char = 9;
- public static final int t_wchar_t = 10;
- public static final int t_int = 11;
- public static final int t_float = 12;
- public static final int t_double = 13;
- public static final int t_void = 14;
- public static final int t_enumerator = 15;
-
- private static final String _image[] = { "",
- "",
- "namespace",
- "class",
- "struct",
- "union",
- "enum",
- "",
- "bool",
- "char",
- "wchar_t",
- "int",
- "float",
- "double",
- "void",
- ""
- };
- //Partial ordering :
- // none < const
- // none < volatile
- // none < const volatile
- // const < const volatile
- // volatile < const volatile
- public static final int cvConst = 2;
- public static final int cvVolatile = 3;
- public static final int cvConstVolatile = 5;
-
- // Convenience methods
- public void setBit(boolean b, int mask){
- if( b ){
- _typeInfo = _typeInfo | mask;
- } else {
- _typeInfo = _typeInfo & ~mask;
- }
- }
-
- public boolean checkBit(int mask){
- return (_typeInfo & mask) != 0;
- }
-
- public void setType(int t) throws ParserSymbolTableException{
- //sanity check, t must fit in its allocated 5 bits in _typeInfo
- if( t > typeMask ){
- throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
- }
-
- _typeInfo = _typeInfo & ~typeMask | t;
- }
-
- public int getType(){
- return _typeInfo & typeMask;
- }
-
- public boolean isType( int type ){
- return isType( type, 0 );
- }
-
- public int getTypeInfo(){
- return _typeInfo;
- }
-
- public void setTypeInfo( int typeInfo ){
- _typeInfo = typeInfo;
- }
-
- /**
- *
- * @param type
- * @param upperType
- * @return boolean
- *
- * type checking, check that this declaration's type is between type and
- * upperType (inclusive). upperType of 0 means no range and our type must
- * be type.
- */
- public boolean isType( int type, int upperType ){
- //type of -1 means we don't care
- if( type == -1 )
- return true;
-
- //upperType of 0 means no range
- if( upperType == 0 ){
- return ( getType() == type );
- } else {
- return ( getType() >= type && getType() <= upperType );
- }
- }
-
- public Declaration getTypeDeclaration(){
- return _typeDeclaration;
- }
-
- public void setTypeDeclaration( Declaration type ){
- _typeDeclaration = type;
- }
-
- public int getCVQualifier(){
- return _cvQualifier;
- }
-
- public void setCVQualifier( int cv ){
- _cvQualifier = cv;
- }
-
- public void addCVQualifier( int cv ){
- switch( _cvQualifier ){
- case 0:
- _cvQualifier = cv;
- break;
-
- case cvConst:
- if( cv != cvConst ){
- _cvQualifier = cvConstVolatile;
- }
- break;
-
- case cvVolatile:
- if( cv != cvVolatile ){
- _cvQualifier = cvConstVolatile;
- }
- break;
-
- case cvConstVolatile:
- break; //nothing to do
- }
- }
-
- public String getPtrOperator(){
- return _ptrOperator;
- }
-
- public void setPtrOperator( String ptr ){
- _ptrOperator = ptr;
- }
-
- public void addPtrOperator( String ptr ){
- if( ptr == null ){
- return;
- }
-
- char chars[] = ( _ptrOperator == null ) ? ptr.toCharArray() : ( ptr + _ptrOperator ).toCharArray();
-
- int nChars = ( _ptrOperator == null ) ? ptr.length() : ptr.length() + _ptrOperator.length();
-
- char dest[] = new char [ nChars ];
- int j = 0;
-
- char currChar, nextChar, tempChar;
-
- for( int i = 0; i < nChars; i++ ){
- currChar = chars[ i ];
- nextChar = ( i + 1 < nChars ) ? chars[ i + 1 ] : 0;
-
- switch( currChar ){
- case '&':{
- switch( nextChar ){
- case '[':
- tempChar = ( i + 2 < nChars ) ? chars[ i + 2 ] : 0;
- if( tempChar == ']' ){
- i++;
- nextChar = '*';
- }
- //fall through to '*'
- case '*':
- i++;
- break;
- case '&':
- default:
- dest[ j++ ] = currChar;
- break;
- }
- break;
- }
- case '[':{
- if( nextChar == ']' ){
- i++;
- currChar = '*';
- nextChar = ( i + 2 < nChars ) ? chars[ i + 2 ] : 0;
- }
- //fall through to '*'
- }
- case '*':{
-
- if( nextChar == '&' ){
- i++;
- } else {
- dest[ j++ ] = currChar;
- }
- break;
- }
- default:
- break;
-
- }
- }
-
- _ptrOperator = new String( dest, 0, j );
- }
-
- public String getInvertedPtrOperator(){
- if( _ptrOperator == null ){
- return null;
- }
-
- char chars[] = _ptrOperator.toCharArray();
- int nChars = _ptrOperator.length();
-
- char dest[] = new char [ nChars ];
- char currChar;
-
- for( int i = 0; i < nChars; i++ ){
- currChar = chars[ i ];
- switch( currChar ){
- case '*' : dest[ i ] = '&'; break;
- case '&' : dest[ i ] = '*'; break;
- default: dest[ i ] = currChar; break;
- }
- }
-
- return new String( dest );
- }
-
- public boolean getHasDefault(){
- return _hasDefaultValue;
- }
-
- public void setHasDefault( boolean def ){
- _hasDefaultValue = def;
- }
-
- /**
- * canHold
- * @param type
- * @return boolean
- * return true is the our type can hold all the values of the passed in
- * type.
- * TBD, for now return true if our type is "larger" (based on ordering of
- * the type values)
- */
- public boolean canHold( TypeInfo type ){
- return getType() >= type.getType();
- }
-
- public boolean equals( Object t ){
- if( t == null || !(t instanceof TypeInfo) ){
- return false;
- }
-
- TypeInfo type = (TypeInfo)t;
-
- boolean result = ( _typeInfo == type._typeInfo );
- result &= ( _typeDeclaration == type._typeDeclaration );
- result &= ( _cvQualifier == type._cvQualifier );
-
- String op1 = ( _ptrOperator != null && _ptrOperator.equals("") ) ? null : _ptrOperator;
- String op2 = ( type._ptrOperator != null && type._ptrOperator.equals("") ) ? null : type._ptrOperator;
- result &= (( op1 != null && op2 != null && op1.equals( op2 ) ) || op1 == op2 );
-
- return result;
- }
-
- public String toString(){
- if( isType( t_type ) ){
- return _typeDeclaration.getName();
- } else {
- return _image[ getType() ];
- }
- }
-
- private int _typeInfo = 0;
- private Declaration _typeDeclaration;
- private int _cvQualifier = 0;
-
- private boolean _hasDefaultValue = false;
- private String _ptrOperator;
- }
-}
Index: parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTableException.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTableException.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTableException.java
--- parser/org/eclipse/cdt/internal/core/parser/ParserSymbolTableException.java 7 Apr 2003 21:43:01 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2002,2003 Rational Software Corporation and others.
- * 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:
- * Rational Software - Initial API and implementation
-***********************************************************************/
-
-package org.eclipse.cdt.internal.core.parser;
-
-/**
- * @author aniefer
- *
- * To change this generated comment edit the template variable "typecomment":
- * Window>Preferences>Java>Templates.
- * To enable and disable the creation of type comments go to
- * Window>Preferences>Java>Code Generation.
- */
-public class ParserSymbolTableException extends Exception {
-
- /**
- * Constructor for ParserSymbolTableException.
- */
- public ParserSymbolTableException() {
- super();
- }
-
- /**
- * Constructor for ParserSymbolTableException.
- * @param int r: reason
- */
- public ParserSymbolTableException( int r ) {
- reason = r;
- }
-
- public static final int r_Unspecified = -1;
- public static final int r_Ambiguous = 0;
- public static final int r_BadTypeInfo = 1;
- public static final int r_CircularInheritance = 2;
- public static final int r_InvalidOverload = 3;
-
- public int reason = -1;
-}
\ No newline at end of file
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.29
diff -u -r1.29 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 9 Jun 2003 18:40:17 -0000 1.29
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 13 Jun 2003 14:58:10 -0000
@@ -24,6 +24,13 @@
import java.util.StringTokenizer;
import java.util.Vector;
+import org.eclipse.cdt.core.parser.IParser;
+import org.eclipse.cdt.core.parser.IScanner;
+import org.eclipse.cdt.core.parser.ISourceElementRequestor;
+import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.core.parser.ast.IASTMacro;
+
/**
* @author jcamelon
*
@@ -43,12 +50,12 @@
new ScannerContext().initialize(
new StringReader("\n"),
START,
- ScannerContext.SENTINEL));
+ ScannerContext.SENTINEL, null), requestor);
if (filename == null)
- contextStack.push( new ScannerContext().initialize(reader, TEXT, ScannerContext.TOP ) );
+ contextStack.push( new ScannerContext().initialize(reader, TEXT, ScannerContext.TOP, null ), requestor );
else
- contextStack.push( new ScannerContext().initialize(reader, filename, ScannerContext.TOP ) );
+ contextStack.push( new ScannerContext().initialize(reader, filename, ScannerContext.TOP, null ), requestor );
} catch( ScannerException se ) {
//won't happen since we aren't adding an include or a macro
}
@@ -255,8 +262,10 @@
return buffer.toString();
}
- protected void handleInclusion(String fileName, boolean useIncludePaths ) throws ScannerException {
+ protected void handleInclusion(String fileName, boolean useIncludePaths, int nameOffset, int beginOffset, int endOffset ) throws ScannerException {
+ FileReader inclusionReader = null;
+ String newPath = null;
if( useIncludePaths ) // search include paths for this file
{
// iterate through the include paths
@@ -266,16 +275,12 @@
File pathFile = (File)iter.next();
if (pathFile.isDirectory()) {
- String newPath = pathFile.getPath() + File.separatorChar + fileName;
-
+ newPath = pathFile.getPath() + File.separatorChar + fileName;
File includeFile = new File(newPath);
-
if (includeFile.exists() && includeFile.isFile()) {
try {
- FileReader inclusionReader =
- new FileReader(includeFile);
- contextStack.updateContext(inclusionReader, newPath, ScannerContext.INCLUSION );
- return;
+ inclusionReader = new FileReader(includeFile);
+ break;
} catch (FileNotFoundException fnf) {
// do nothing - check the next directory
}
@@ -289,23 +294,24 @@
File currentIncludeFile = new File( currentFilename );
String parentDirectory = currentIncludeFile.getParent();
currentIncludeFile = null;
- String fullPath = parentDirectory + File.separatorChar + fileName;
- File includeFile = new File( fullPath );
+ newPath = parentDirectory + File.separatorChar + fileName;
+ File includeFile = new File( newPath );
if (includeFile.exists() && includeFile.isFile()) {
try {
- FileReader inclusionReader =
+ inclusionReader =
new FileReader(includeFile);
- contextStack.updateContext(inclusionReader, fullPath, ScannerContext.INCLUSION );
- return;
} catch (FileNotFoundException fnf) {
if (throwExceptionOnInclusionNotFound)
throw new ScannerException("Cannot find inclusion " + fileName);
}
}
}
-
- if (throwExceptionOnInclusionNotFound)
+
+ if (throwExceptionOnInclusionNotFound && inclusionReader == null )
throw new ScannerException("Cannot find inclusion " + fileName);
+
+ IASTInclusion inclusion = astFactory.createInclusion( fileName, newPath, !useIncludePaths, beginOffset, endOffset, nameOffset );
+ contextStack.updateContext(inclusionReader, newPath, ScannerContext.INCLUSION, inclusion, requestor );
}
// constants
@@ -390,7 +396,7 @@
try {
c = contextStack.getCurrentContext().read();
if (c == NOCHAR) {
- if (contextStack.rollbackContext() == false) {
+ if (contextStack.rollbackContext(requestor) == false) {
c = NOCHAR;
break;
} else {
@@ -398,7 +404,7 @@
}
}
} catch (IOException e) {
- if (contextStack.rollbackContext() == false) {
+ if (contextStack.rollbackContext(requestor) == false) {
c = NOCHAR;
} else {
done = false;
@@ -442,7 +448,7 @@
private void ungetChar(int c) throws ScannerException{
contextStack.getCurrentContext().pushUndo(c);
if( c == '\n' ) contextStack.recantNewline();
- contextStack.undoRollback( lastContext );
+ contextStack.undoRollback( lastContext, requestor );
}
protected boolean lookAheadForTokenPasting() throws ScannerException
@@ -652,7 +658,7 @@
if( storageBuffer != null )
{
storageBuffer.append( ident );
- contextStack.updateContext( new StringReader( storageBuffer.toString()), PASTING, IScannerContext.MACROEXPANSION );
+ contextStack.updateContext( new StringReader( storageBuffer.toString()), PASTING, IScannerContext.MACROEXPANSION, null, requestor );
storageBuffer = null;
c = getChar();
continue;
@@ -788,7 +794,7 @@
{
if( storageBuffer != null )
{
- contextStack.updateContext( new StringReader( buff.toString()), PASTING, IScannerContext.MACROEXPANSION );
+ contextStack.updateContext( new StringReader( buff.toString()), PASTING, IScannerContext.MACROEXPANSION, null, requestor );
storageBuffer = null;
c = getChar();
continue;
@@ -1776,17 +1782,26 @@
}
String f = fileName.toString();
+ offset = contextStack.getCurrentContext().getOffset() - f.length() - 1; // -1 for the end quote
if( quickScan )
{
if( callback != null )
{
- offset = contextStack.getCurrentContext().getOffset() - f.length() - 1; // -1 for the end quote
callback.inclusionEnd(callback.inclusionBegin( f, offset, beginningOffset, !useIncludePath ));
}
+
+ if( requestor != null )
+ {
+ IASTInclusion i = astFactory.createInclusion( f, "", !useIncludePath, beginningOffset,
+ contextStack.getCurrentContext().getOffset(), offset );
+ requestor.enterInclusion(i);
+ requestor.exitInclusion(i);
+ }
}
else
- handleInclusion(f.trim(), useIncludePath );
+ handleInclusion(f.trim(), useIncludePath, offset, beginningOffset, contextStack.getCurrentContext().getOffset() );
+
}
protected void poundDefine(int beginning) throws ScannerException, Parser.EndOfFile {
@@ -1952,6 +1967,12 @@
// NOTE: return value is ignored!
callback.macro( key, offset, beginning, contextStack.getCurrentContext().getOffset() );
}
+
+ if( requestor != null )
+ {
+ IASTMacro m = astFactory.createMacro( key, beginning, contextStack.getCurrentContext().getOffset(), offset );
+ requestor.acceptMacro(m);
+ }
}
protected Vector getMacroParameters (String params, boolean forStringizing) throws ScannerException {
@@ -2000,7 +2021,7 @@
throws ScannerException {
if (expansion instanceof String ) {
String replacementValue = (String) expansion;
- contextStack.updateContext( new StringReader(replacementValue), (POUND_DEFINE + symbol ), ScannerContext.MACROEXPANSION );
+ contextStack.updateContext( new StringReader(replacementValue), (POUND_DEFINE + symbol ), ScannerContext.MACROEXPANSION, null, requestor );
} else if (expansion instanceof IMacroDescriptor ) {
IMacroDescriptor macro = (IMacroDescriptor) expansion;
skipOverWhitespace();
@@ -2117,7 +2138,7 @@
String finalString = buffer.toString();
contextStack.updateContext(
new StringReader(finalString),
- POUND_DEFINE + macro.getSignature(), ScannerContext.MACROEXPANSION );
+ POUND_DEFINE + macro.getSignature(), ScannerContext.MACROEXPANSION, null, requestor );
} else
if (throwExceptionOnBadMacroExpansion)
throw new ScannerException(
@@ -2184,5 +2205,22 @@
mapLineNumbers = value;
}
- private boolean mapLineNumbers = false;
+ private boolean mapLineNumbers = false;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IScanner#setRequestor(org.eclipse.cdt.core.parser.ISourceElementRequestor)
+ */
+ public void setRequestor(ISourceElementRequestor r) {
+ requestor = r;
+ }
+
+ private ISourceElementRequestor requestor = null;
+ private IASTFactory astFactory = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.IScanner#setASTFactory(org.eclipse.cdt.internal.core.parser.ast.IASTFactory)
+ */
+ public void setASTFactory(IASTFactory f) {
+ astFactory = f;
+ }
}
Index: parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java,v
retrieving revision 1.4
diff -u -r1.4 ScannerContext.java
--- parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java 16 Apr 2003 12:30:46 -0000 1.4
+++ parser/org/eclipse/cdt/internal/core/parser/ScannerContext.java 13 Jun 2003 14:58:10 -0000
@@ -14,6 +14,8 @@
import java.io.Reader;
import java.util.Stack;
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+
public class ScannerContext implements IScannerContext
{
private Reader reader;
@@ -23,12 +25,13 @@
private int kind;
public ScannerContext(){}
- public IScannerContext initialize(Reader r, String f, int k)
+ public IScannerContext initialize(Reader r, String f, int k, IASTInclusion i)
{
reader = r;
filename = f;
offset = 0;
kind = k;
+ inc = i;
return this;
}
@@ -103,6 +106,20 @@
public void setKind(int kind) {
this.kind = kind;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IScannerContext#getExtension()
+ */
+ public IASTInclusion getExtension() {
+ return inc;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.IScannerContext#setExtension(org.eclipse.cdt.core.parser.ast.IASTInclusion)
+ */
+ public void setExtension(IASTInclusion ext) {
+ inc = ext;
+ }
+
+ private IASTInclusion inc = null;
}
Index: parser/org/eclipse/cdt/internal/core/parser/Token.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Token.java,v
retrieving revision 1.12
diff -u -r1.12 Token.java
--- parser/org/eclipse/cdt/internal/core/parser/Token.java 24 Apr 2003 18:36:22 -0000 1.12
+++ parser/org/eclipse/cdt/internal/core/parser/Token.java 13 Jun 2003 14:58:10 -0000
@@ -43,6 +43,8 @@
public int offset;
public int getOffset() { return offset; }
public int getLength() { return image.length(); }
+ public int getEndOffset() { return getOffset() + getLength(); }
+
public int getDelta( Token other )
{
Index: parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java
diff -N parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/TokenDuple.java 13 Jun 2003 14:58:10 -0000
@@ -0,0 +1,87 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser;
+
+import java.util.Iterator;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class TokenDuple {
+
+ public TokenDuple( Token first, Token last )
+ {
+ firstToken = first;
+ lastToken = last;
+ }
+ private final Token firstToken, lastToken;
+ /**
+ * @return
+ */
+ public Token getFirstToken() {
+ return firstToken;
+ }
+
+ /**
+ * @return
+ */
+ public Token getLastToken() {
+ return lastToken;
+ }
+
+ public Iterator iterator()
+ {
+ return new TokenIterator();
+ }
+
+ private class TokenIterator implements Iterator
+ {
+ private Token iter = TokenDuple.this.firstToken;
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return ( iter != TokenDuple.this.lastToken);
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+ Token temp = iter;
+ iter = iter.getNext();
+ return temp;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+ Token iter = firstToken;
+ for( ; ; )
+ {
+ buff.append( iter.getImage() );
+ if( iter == lastToken ) break;
+ iter = iter.getNext();
+ }
+ return buff.toString();
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/ASTBaseSpecifier.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/ASTBaseSpecifier.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/ASTBaseSpecifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/ASTBaseSpecifier.java 13 Jun 2003 14:58:10 -0000
@@ -0,0 +1,55 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+import org.eclipse.cdt.core.parser.ast.AccessVisibility;
+import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
+import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTBaseSpecifier implements IASTBaseSpecifier {
+
+ private final IASTClassSpecifier baseClass;
+ private final boolean isVirtual;
+ private final AccessVisibility visibility;
+
+ public ASTBaseSpecifier( IASTClassSpecifier c, AccessVisibility a, boolean virtual )
+ {
+ isVirtual = virtual;
+ baseClass = c;
+ visibility = a;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getAccess()
+ */
+ public AccessVisibility getAccess() {
+ return visibility;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#isVirtual()
+ */
+ public boolean isVirtual() {
+ return isVirtual;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier#getParent()
+ */
+ public IASTClassSpecifier getParent() {
+ return baseClass;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/ASTInclusion.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/ASTInclusion.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/ASTInclusion.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/ASTInclusion.java 13 Jun 2003 14:58:10 -0000
@@ -0,0 +1,97 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTInclusion implements IASTInclusion {
+
+ public ASTInclusion( String name, String fileName, boolean local )
+ {
+ this.name = name;
+ this.fileName = fileName;
+ this.local = local;
+ }
+
+ private final String name, fileName;
+ private final boolean local;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTInclusion#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTInclusion#getFullFileName()
+ */
+ public String getFullFileName() {
+ return fileName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTInclusion#isLocal()
+ */
+ public boolean isLocal() {
+ return local;
+ }
+
+
+ private int startingOffset = 0, nameOffset = 0, endingOffset = 0;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return startingOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return endingOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementNameOffset()
+ */
+ public int getElementNameOffset() {
+ return nameOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IOffsetableElementRW#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ startingOffset = o;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IOffsetableElementRW#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ endingOffset = o;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
+ */
+ public void setNameOffset(int o) {
+ nameOffset = o;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/ASTMacro.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/ASTMacro.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/ASTMacro.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/ASTMacro.java 13 Jun 2003 14:58:10 -0000
@@ -0,0 +1,72 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+import org.eclipse.cdt.core.parser.ast.IASTMacro;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTMacro implements IASTMacro {
+
+ private final String name;
+ public ASTMacro( String name )
+ {
+ this.name =name;
+ }
+
+ private int startingOffset = 0, endingOffset = 0, nameOffset = 0;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTMacro#getName()
+ */
+ public String getName() {
+ return name;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElementRW#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ startingOffset = o;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElementRW#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ endingOffset = o;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElementRW#setNameOffset(int)
+ */
+ public void setNameOffset(int o) {
+ nameOffset = o;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return startingOffset;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return endingOffset;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementNameOffset()
+ */
+ public int getElementNameOffset() {
+ return nameOffset;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/BaseASTFactory.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,46 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+import org.eclipse.cdt.core.parser.ast.IASTInclusion;
+import org.eclipse.cdt.core.parser.ast.IASTMacro;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public class BaseASTFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createMacro(java.lang.String, int, int, int)
+ */
+ public IASTMacro createMacro(String name, int startingOffset, int endingOffset, int nameOffset) {
+ IASTMacro m = new ASTMacro( name );
+ m.setStartingOffset( startingOffset );
+ m.setEndingOffset( endingOffset );
+ m.setNameOffset( nameOffset );
+ return m;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createInclusion(java.lang.String, java.lang.String, boolean)
+ */
+ public IASTInclusion createInclusion(String name, String fileName, boolean local, int startingOffset, int endingOffset, int nameOffset) {
+ IASTInclusion inclusion = new ASTInclusion( name, fileName, local );
+ inclusion.setStartingOffset( startingOffset );
+ inclusion.setEndingOffset( endingOffset );
+ inclusion.setNameOffset( nameOffset );
+ return inclusion;
+ }
+
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/NamedOffsets.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/NamedOffsets.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/NamedOffsets.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/NamedOffsets.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,37 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public class NamedOffsets extends Offsets {
+
+ private int nameOffset = 0;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
+ */
+ public int getElementNameOffset() {
+ return nameOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
+ */
+ public void setNameOffset(int o) {
+ nameOffset = o;
+ }
+
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/Offsets.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/Offsets.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/Offsets.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/Offsets.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,39 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class Offsets {
+
+ protected int startingOffset = 0;
+
+ protected int endingOffset = 0;
+
+ public void setStartingOffset(int o) {
+ startingOffset = o;
+ }
+
+ public void setEndingOffset(int o) {
+ endingOffset = o;
+ }
+
+ public int getElementStartingOffset() {
+ return startingOffset;
+ }
+
+ public int getElementEndingOffset() {
+ return endingOffset;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTASMDefinition.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,78 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTASMDefinition implements IASTFASMDefinition {
+
+ private final String body;
+
+ public ASTASMDefinition( ISymbol s, String body )
+ {
+ this.symbol = s;
+ this.body = body;
+ }
+
+ private int startingOffset, endingOffset;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTASMDefinition#getBody()
+ */
+ public String getBody() {
+ return body;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ startingOffset = o;
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ endingOffset = o;
+
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return startingOffset;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return endingOffset;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.ISymbolTableExtension#getSymbol()
+ */
+
+ private final ISymbol symbol;
+ public ISymbol getSymbol() {
+ return symbol;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTClassSpecifier.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,137 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.parser.ast.ClassKind;
+import org.eclipse.cdt.core.parser.ast.ClassNameType;
+import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
+import org.eclipse.cdt.internal.core.parser.pst.IDerivableContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTClassSpecifier implements IASTFClassSpecifier, IPSTSymbolExtension {
+
+ private final IDerivableContainerSymbol symbol;
+ private final ClassKind classKind;
+ private final ClassNameType type;
+ private final String name;
+
+ public ASTClassSpecifier( IDerivableContainerSymbol symbol, String name, ClassNameType type, ClassKind kind )
+ {
+ this.name = name;
+ this.symbol = symbol;
+ this.classKind = kind;
+ this.type = type;
+ symbol.setASTNode( this );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return new ScopeIterator( symbol.getContainedSymbols());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassNameType()
+ */
+ public ClassNameType getClassNameType() {
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getClassKind()
+ */
+ public ClassKind getClassKind() {
+ return classKind;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTClassSpecifier#getBaseClauses()
+ */
+ public Iterator getBaseClauses() {
+ return new BaseIterator( symbol.getParents() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ private int nameOffset = 0, startingOffset = 0, endingOffset = 0;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
+ */
+ public int getElementNameOffset() {
+ return nameOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
+ */
+ public void setNameOffset(int o) {
+ nameOffset = o;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTTemplatedDeclaration#getOwnerTemplateDeclaration()
+ */
+ public IASTTemplateDeclaration getOwnerTemplateDeclaration() {
+ if( getSymbol().getContainingSymbol().getType() == ParserSymbolTable.TypeInfo.t_template )
+ return (IASTTemplateDeclaration)getSymbol().getContainingSymbol().getASTNode();
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ startingOffset = o;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ endingOffset = o;
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return startingOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return endingOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension#getSymbol()
+ */
+ public ISymbol getSymbol() {
+ return symbol;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTCompilationUnit.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,50 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTCompilationUnit implements IASTFCompilationUnit {
+
+ public ASTCompilationUnit( IContainerSymbol symbol )
+ {
+ this.symbol = symbol;
+ symbol.setASTNode( this );
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return new ScopeIterator( symbol.getContainedSymbols() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.ISymbolTableExtension#getSymbol()
+ */
+ public IContainerSymbol getContainerSymbol() {
+ return symbol;
+ }
+
+ private final IContainerSymbol symbol;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension#getSymbol()
+ */
+ public ISymbol getSymbol() {
+ return symbol;
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTLinkageSpecification.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,68 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTLinkageSpecification implements IASTFLinkageSpecification {
+
+ public ASTLinkageSpecification( IContainerSymbol symbol, String linkage )
+ {
+ this.symbol = symbol;
+ symbol.setASTNode( this );
+ this.linkage = linkage;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return new ScopeIterator( symbol.getContainedSymbols() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension#getSymbol()
+ */
+ public IContainerSymbol getContainerSymbol() {
+ return symbol;
+ }
+
+ private final IContainerSymbol symbol;
+ private final String linkage;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification#getLinkageString()
+ */
+ public String getLinkageString() {
+ return linkage;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension#getSymbol()
+ */
+ public ISymbol getSymbol() {
+ return symbol;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTNamespaceDefinition.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,112 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTNamespaceDefinition implements IASTFNamespaceDefinition {
+
+ public ASTNamespaceDefinition( IContainerSymbol symbol, String name )
+ {
+ this.symbol = symbol;
+ this.name = name;
+ }
+
+ private final String name;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return new ScopeIterator( symbol.getContainedSymbols() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IPSTSymbolExtension#getSymbol()
+ */
+ public ISymbol getSymbol() {
+ return symbol;
+ }
+
+ private final IContainerSymbol symbol;
+
+ private int nameOffset = 0, startingOffset = 0, endingOffset = 0;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
+ */
+ public int getElementNameOffset() {
+ return nameOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
+ */
+ public void setNameOffset(int o) {
+ nameOffset = o;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ startingOffset = o;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ endingOffset = o;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return startingOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return endingOffset;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IPSTContainerExtension#getContainerSymbol()
+ */
+ public IContainerSymbol getContainerSymbol() {
+ return symbol;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return (IPSTContainerExtension)symbol.getContainingSymbol().getASTNode();
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ASTUsingDirective.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,42 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTUsingDirective implements IASTUsingDirective {
+
+ private final String namespaceName;
+
+ public ASTUsingDirective( String namespace )
+ {
+ namespaceName = namespace;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName()
+ */
+ public String getNamespaceName() {
+ return namespaceName;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return null; //TODO
+ }
+
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/BaseIterator.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,53 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.internal.core.parser.ast.ASTBaseSpecifier;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class BaseIterator implements Iterator {
+
+ private final Iterator rawIter;
+ public BaseIterator( List bases )
+ {
+ rawIter = bases.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return rawIter.hasNext();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+ ParserSymbolTable.Declaration.ParentWrapper wrapper = (ParserSymbolTable.Declaration.ParentWrapper)rawIter.next();
+ return new ASTBaseSpecifier( (IASTFClassSpecifier)wrapper.getParent().getASTNode(), wrapper.getAccess(), wrapper.isVirtual());
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/FullParseASTFactory.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,148 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+
+import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.internal.core.parser.Token;
+import org.eclipse.cdt.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTableException;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class FullParseASTFactory extends BaseASTFactory implements IASTFactory {
+
+ private ParserSymbolTable pst = new ParserSymbolTable(); // symbol table
+
+ public IASTUsingDirective createUsingDirective(
+ IASTScope scope,
+ TokenDuple duple)
+ throws Backtrack {
+ Iterator iter = duple.iterator();
+ Token t1 = (Token)iter.next();
+ IContainerSymbol symbol = null;
+
+ if( t1.getType() == Token.tCOLONCOLON )
+ symbol = pst.getCompilationUnit();
+ else
+ {
+ try
+ {
+ symbol = (IContainerSymbol)((IASTFScope)scope).getContainerSymbol().Lookup( t1.getImage() );
+ }
+ catch( ParserSymbolTableException pste )
+ {
+ handlePSTException( pste );
+ }
+ }
+
+ while( iter.hasNext() )
+ {
+ Token t = (Token)iter.next();
+ if( t.getType() == Token.tCOLONCOLON ) continue;
+ try
+ {
+ symbol = symbol.LookupNestedNameSpecifier( t.getImage() );
+ }
+ catch( ParserSymbolTableException pste )
+ {
+ handlePSTException( pste );
+ }
+ }
+
+ try {
+ ((IASTFScope)scope).getContainerSymbol().addUsingDirective( symbol );
+ } catch (ParserSymbolTableException pste) {
+ handlePSTException( pste );
+ }
+
+ IASTUsingDirective astUD = new ASTUsingDirective( duple.toString() );
+ return astUD;
+ }
+
+ public IASTASMDefinition createASMDefinition(
+ IASTScope scope,
+ String assembly,
+ int first,
+ int last) {
+ IContainerSymbol containerSymbol = (IContainerSymbol)((IASTFScope)scope).getSymbol();
+ ISymbol asmSymbol = pst.newSymbol( "", ParserSymbolTable.TypeInfo.t_asm );
+ IASTFASMDefinition asmDefinition = new ASTASMDefinition( asmSymbol, assembly );
+ asmSymbol.setASTNode( asmDefinition );
+
+ try {
+ containerSymbol.addSymbol(asmSymbol);
+ } catch (ParserSymbolTableException e1) {
+ //?
+ }
+
+ asmDefinition.setStartingOffset( first );
+ asmDefinition.setEndingOffset( last );
+ return asmDefinition;
+ }
+
+ public IASTNamespaceDefinition createNamespaceDefinition(
+ IASTScope scope,
+ String identifier,
+ int first, int nameOffset ) {
+
+ IContainerSymbol namespaceSymbol = null;
+
+ pst.newContainerSymbol( identifier, ParserSymbolTable.TypeInfo.t_namespace );
+ IASTFNamespaceDefinition namespaceDefinition = new ASTNamespaceDefinition( namespaceSymbol, identifier );
+ namespaceDefinition.setStartingOffset( first );
+ if( identifier != "" )
+ namespaceDefinition.setNameOffset( nameOffset );
+ return namespaceDefinition;
+ }
+
+ public IASTCompilationUnit createCompilationUnit() {
+ IASTFCompilationUnit compilationUnit = new ASTCompilationUnit( pst.getCompilationUnit() );
+ return compilationUnit;
+ }
+
+ public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec) {
+ IContainerSymbol symbol = pst.newContainerSymbol("", ParserSymbolTable.TypeInfo.t_linkage );
+ IASTFLinkageSpecification linkage = new ASTLinkageSpecification( symbol, spec);
+ return linkage;
+ }
+
+ /**
+ * @param pste
+ */
+ private void handlePSTException(ParserSymbolTableException pste) throws Backtrack {
+ throw new Backtrack();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
+ */
+ public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFASMDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFASMDefinition.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFASMDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFASMDefinition.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,21 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFASMDefinition
+ extends org.eclipse.cdt.core.parser.ast.IASTASMDefinition, IPSTSymbolExtension {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFClassSpecifier.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFClassSpecifier.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFClassSpecifier.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFClassSpecifier.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,22 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFClassSpecifier
+ extends IASTScope, org.eclipse.cdt.core.parser.ast.IASTClassSpecifier {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFCompilationUnit.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFCompilationUnit.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFCompilationUnit.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFCompilationUnit.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,23 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFCompilationUnit
+ extends
+ org.eclipse.cdt.core.parser.ast.IASTCompilationUnit,
+ IASTFScope {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFLinkageSpecification.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFLinkageSpecification.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFLinkageSpecification.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFLinkageSpecification.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFLinkageSpecification
+ extends org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification, IASTFScope {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFNamespaceDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFNamespaceDefinition.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFNamespaceDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFNamespaceDefinition.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFNamespaceDefinition
+ extends IASTFScope, org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFScope.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFScope.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFScope.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IASTFScope.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,20 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTFScope
+ extends org.eclipse.cdt.core.parser.ast.IASTScope, IPSTContainerExtension {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTContainerExtension.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,23 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.pst.IContainerSymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IPSTContainerExtension extends IPSTSymbolExtension, IASTScope {
+
+ public IContainerSymbol getContainerSymbol();
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/IPSTSymbolExtension.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,22 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IPSTSymbolExtension {
+
+ ISymbol getSymbol();
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/full/ScopeIterator.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,55 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.full;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.cdt.internal.core.parser.pst.ISymbol;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ScopeIterator implements Iterator {
+
+ private final Map sourceMap;
+ private final Iterator keyIter;
+
+ public ScopeIterator( Map in )
+ {
+ sourceMap = in;
+ keyIter = in.keySet().iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#hasNext()
+ */
+ public boolean hasNext() {
+ return keyIter.hasNext();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#next()
+ */
+ public Object next() {
+ ISymbol symbol = (ISymbol)sourceMap.get( keyIter.next() );
+ return symbol.getASTNode();
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.Iterator#remove()
+ */
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTASMDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTASMDefinition.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTASMDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTASMDefinition.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,70 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.ast.Offsets;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTASMDefinition
+ extends ASTDeclaration
+ implements IASTASMDefinition {
+
+ private Offsets offsets = new Offsets();
+ private final String assembly;
+ /**
+ * @param scope
+ */
+ public ASTASMDefinition(IASTScope scope, String assembly) {
+ super(scope);
+ this.assembly = assembly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTASMDefinition#getBody()
+ */
+ public String getBody() {
+ return assembly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ offsets.setStartingOffset(o);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ offsets.setEndingOffset( o );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return offsets.getElementStartingOffset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return offsets.getElementEndingOffset();
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTCompilationUnit.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTCompilationUnit.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTCompilationUnit.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTCompilationUnit.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,40 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTCompilationUnit implements IASTCompilationUnit, IASTQScope {
+
+ private List declarations = new ArrayList();
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return declarations.iterator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQScope#addDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
+ */
+ public void addDeclaration(IASTDeclaration declaration) {
+ declarations.add( declaration );
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTDeclaration.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTDeclaration.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,35 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTDeclaration implements IASTDeclaration {
+
+ private final IASTScope scope;
+ public ASTDeclaration( IASTScope scope )
+ {
+ this.scope = scope;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTDeclaration#getOwnerScope()
+ */
+ public IASTScope getOwnerScope() {
+ return scope;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTLinkageSpecification.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTLinkageSpecification.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTLinkageSpecification.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTLinkageSpecification.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,59 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTLinkageSpecification
+ extends ASTDeclaration
+ implements IASTDeclaration, IASTLinkageSpecification, IASTQScope {
+
+ private final String linkage;
+
+ public ASTLinkageSpecification( IASTScope scope, String linkage )
+ {
+ super( scope );
+ this.linkage = linkage;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification#getLinkageString()
+ */
+ public String getLinkageString() {
+ return linkage;
+ }
+
+ private List declarations = new ArrayList();
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return declarations.iterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQScope#addDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
+ */
+ public void addDeclaration(IASTDeclaration declaration) {
+ declarations.add( declaration );
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNamespaceDefinition.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNamespaceDefinition.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNamespaceDefinition.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTNamespaceDefinition.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,99 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.internal.core.parser.ast.NamedOffsets;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTNamespaceDefinition extends ASTDeclaration implements IASTNamespaceDefinition, IASTQScope {
+
+ private final String name;
+ private NamedOffsets offsets = new NamedOffsets();
+
+ public ASTNamespaceDefinition( IASTScope scope, String name )
+ {
+ super( scope );
+ this.name = name;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getName()
+ */
+ public String getName() {
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#getElementNameOffset()
+ */
+ public int getElementNameOffset() {
+ return offsets.getElementNameOffset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement#setNameOffset(int)
+ */
+ public void setNameOffset(int o) {
+ offsets.setNameOffset( o );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setStartingOffset(int)
+ */
+ public void setStartingOffset(int o) {
+ offsets.setStartingOffset(o);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#setEndingOffset(int)
+ */
+ public void setEndingOffset(int o) {
+ offsets.setEndingOffset(o);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementStartingOffset()
+ */
+ public int getElementStartingOffset() {
+ return offsets.getElementStartingOffset();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTOffsetableElement#getElementEndingOffset()
+ */
+ public int getElementEndingOffset() {
+ return offsets.getElementEndingOffset();
+ }
+
+ private List declarations = new ArrayList();
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTScope#getDeclarations()
+ */
+ public Iterator getDeclarations() {
+ return declarations.iterator();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.quick.IASTQScope#addDeclaration(org.eclipse.cdt.core.parser.ast.IASTDeclaration)
+ */
+ public void addDeclaration(IASTDeclaration declaration) {
+ declarations.add( declaration );
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDeclaration.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTUsingDeclaration
+ extends ASTDeclaration
+ implements IASTUsingDeclaration {
+
+ private final boolean isTypename;
+ private final String mappingName;
+
+ public ASTUsingDeclaration( IASTScope scope, boolean isTypeName, String mappingName )
+ {
+ super( scope );
+ isTypename = isTypeName;
+ this.mappingName = mappingName;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#isTypename()
+ */
+ public boolean isTypename() {
+ return isTypename;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration#usingTypeName()
+ */
+ public String usingTypeName() {
+ return mappingName;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDirective.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDirective.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDirective.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/ASTUsingDirective.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,38 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class ASTUsingDirective
+ extends ASTDeclaration
+ implements IASTUsingDirective {
+
+
+ public ASTUsingDirective( IASTScope scope, String name )
+ {
+ super( scope );
+ this.namespaceName = name;
+ }
+ private final String namespaceName;
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTUsingDirective#getNamespaceName()
+ */
+ public String getNamespaceName() {
+ return namespaceName;
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQScope.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQScope.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQScope.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/IASTQScope.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,23 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+
+/**
+ * @author jcamelon
+ *
+ */
+public interface IASTQScope extends IASTScope {
+
+ public void addDeclaration( IASTDeclaration declaration );
+}
Index: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
diff -N parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/ast/quick/QuickParseASTFactory.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,79 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.ast.quick;
+
+import org.eclipse.cdt.core.parser.ast.IASTASMDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTCompilationUnit;
+import org.eclipse.cdt.core.parser.ast.IASTFactory;
+import org.eclipse.cdt.core.parser.ast.IASTLinkageSpecification;
+import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
+import org.eclipse.cdt.core.parser.ast.IASTScope;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDeclaration;
+import org.eclipse.cdt.core.parser.ast.IASTUsingDirective;
+import org.eclipse.cdt.internal.core.parser.TokenDuple;
+import org.eclipse.cdt.internal.core.parser.Parser.Backtrack;
+import org.eclipse.cdt.internal.core.parser.ast.BaseASTFactory;
+
+/**
+ * @author jcamelon
+ *
+ */
+public class QuickParseASTFactory extends BaseASTFactory implements IASTFactory {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createUsingDirective(org.eclipse.cdt.internal.core.parser.ast.IASTScope, org.eclipse.cdt.internal.core.parser.TokenDuple)
+ */
+ public IASTUsingDirective createUsingDirective(IASTScope scope, TokenDuple duple) throws Backtrack {
+ return new ASTUsingDirective( scope, duple.toString() );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createASMDefinition(org.eclipse.cdt.internal.core.parser.ast.IASTScope, java.lang.String, int, int)
+ */
+ public IASTASMDefinition createASMDefinition(IASTScope scope, String assembly, int first, int last) {
+ IASTASMDefinition definition = new ASTASMDefinition( scope, assembly );
+ definition.setStartingOffset( first );
+ definition.setEndingOffset( last );
+ return definition;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createNamespaceDefinition(int, java.lang.String, int)
+ */
+ public IASTNamespaceDefinition createNamespaceDefinition(IASTScope scope, String identifier, int first, int nameOffset) {
+ IASTNamespaceDefinition definition = new ASTNamespaceDefinition( scope, identifier );
+ definition.setStartingOffset( first );
+ definition.setNameOffset( nameOffset );
+ return definition;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createCompilationUnit()
+ */
+ public IASTCompilationUnit createCompilationUnit() {
+ return new ASTCompilationUnit();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.internal.core.parser.ast.IASTFactory#createLinkageSpecification(java.lang.String)
+ */
+ public IASTLinkageSpecification createLinkageSpecification(IASTScope scope, String spec) {
+ return new ASTLinkageSpecification( scope, spec );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ast.IASTFactory#createUsingDeclaration(org.eclipse.cdt.core.parser.ast.IASTScope, boolean, org.eclipse.cdt.internal.core.parser.TokenDuple)
+ */
+ public IASTUsingDeclaration createUsingDeclaration(IASTScope scope, boolean isTypeName, TokenDuple name) {
+ return new ASTUsingDeclaration( scope, isTypeName, name.toString() );
+ }
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/IContainerSymbol.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * 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 Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on May 9, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.internal.core.parser.pst;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface IContainerSymbol extends ISymbol {
+
+ public void addSymbol( ISymbol symbol ) throws ParserSymbolTableException;
+
+ public boolean hasUsingDirectives();
+ public List getUsingDirectives();
+ public void addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException;
+
+ public ISymbol addUsingDeclaration( String name ) throws ParserSymbolTableException;
+ public ISymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException;
+
+ public Map getContainedSymbols();
+
+ public ISymbol ElaboratedLookup( TypeInfo.eType type, String name ) throws ParserSymbolTableException;
+ public ISymbol Lookup( String name ) throws ParserSymbolTableException;
+ public ISymbol LookupMemberForDefinition( String name ) throws ParserSymbolTableException;
+ public IContainerSymbol LookupNestedNameSpecifier( String name ) throws ParserSymbolTableException;
+ public ISymbol QualifiedLookup( String name ) throws ParserSymbolTableException;
+ public IParameterizedSymbol UnqualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
+ public IParameterizedSymbol MemberFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException;
+
+ public TemplateInstance TemplateLookup( String name, LinkedList arguments ) throws ParserSymbolTableException;
+ public TemplateInstance instantiate( LinkedList arguments ) throws ParserSymbolTableException;
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/IDerivableContainerSymbol.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * 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 Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on May 9, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.internal.core.parser.pst;
+
+import java.util.List;
+
+import org.eclipse.cdt.core.parser.ast.AccessVisibility;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface IDerivableContainerSymbol extends IContainerSymbol {
+
+ public void addParent( ISymbol parent );
+ public void addParent( ISymbol parent, boolean virtual, AccessVisibility visibility );
+ public List getParents();
+ public boolean hasParents();
+
+ public interface IParentSymbol{
+ public void setParent( ISymbol parent );
+ public ISymbol getParent();
+ public boolean isVirtual();
+ public void setVirtual( boolean virtual );
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/IParameterizedSymbol.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * 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 Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on May 9, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.internal.core.parser.pst;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface IParameterizedSymbol extends IContainerSymbol {
+
+ public void addParameter( ISymbol param );
+ public void addParameter( TypeInfo.eType type, int info, TypeInfo.PtrOp ptrOp, boolean hasDefault );
+ public void addParameter( ISymbol typeSymbol, TypeInfo.PtrOp ptrOp, boolean hasDefault );
+
+ public void addArgument( ISymbol arg );
+ public LinkedList getArgumentList();
+ public void setArgumentList( LinkedList list );
+
+ public HashMap getParameterMap();
+ public LinkedList getParameterList();
+ public void setParameterList( LinkedList list );
+
+ public boolean hasSameParameters(IParameterizedSymbol newDecl);
+
+ public void setReturnType( ISymbol type );
+ public ISymbol getReturnType();
+
+ public boolean hasSpecializations();
+ public void addSpecialization( IParameterizedSymbol spec );
+ public LinkedList getSpecializations();
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ISpecializedSymbol.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2003 IBM Corporation and others.
+ * 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 Corp. - Rational Software - initial implementation
+ ******************************************************************************/
+/*
+ * Created on May 9, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.eclipse.cdt.internal.core.parser.pst;
+
+/**
+ * @author aniefer
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface ISpecializedSymbol extends IParameterizedSymbol {
+
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ISymbol.java 13 Jun 2003 14:58:11 -0000
@@ -0,0 +1,82 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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 Rational Software - Initial API and implementation
+***********************************************************************/
+package org.eclipse.cdt.internal.core.parser.pst;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+
+import org.eclipse.cdt.internal.core.parser.ast.full.IPSTSymbolExtension;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TemplateInstance;
+import org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable.TypeInfo;
+/**
+ * @author jcamelon
+ *
+ */
+public interface ISymbol {
+
+ public ParserSymbolTable getSymbolTable();
+
+ public Object clone();
+
+ public IPSTSymbolExtension getASTNode();
+ public void setASTNode( IPSTSymbolExtension obj );
+
+ public String getName();
+
+ public IContainerSymbol getContainingSymbol();
+ public void setContainingSymbol( IContainerSymbol containing );
+
+ public boolean isType( TypeInfo.eType type );
+ public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType );
+ public TypeInfo.eType getType();
+ public void setType(TypeInfo.eType t);
+ public TypeInfo getTypeInfo();
+ public void setTypeInfo( TypeInfo info );
+ public ISymbol getTypeSymbol();
+ public void setTypeSymbol( ISymbol type );
+
+ public int compareCVQualifiersTo( ISymbol symbol );
+ public LinkedList getPtrOperators();
+ public void addPtrOperator( TypeInfo.PtrOp ptrOp );
+
+ public boolean isTemplateMember();
+ public void setIsTemplateMember( boolean isMember );
+ public ISymbol getTemplateInstance();
+ public HashMap getArgumentMap();
+ public void setTemplateInstance( TemplateInstance instance );
+
+ /*public interface ITypeInfo {
+ public boolean checkBit(int mask);
+ public void setBit(boolean b, int mask);
+ public boolean isType( int type );
+ public boolean isType( int type, int upperType );
+ public int getType();
+ public ISymbol getTypeSymbol();
+
+ public int getCVQualifier();
+ public void addCVQualifier( int cvQual );
+ public String getPtrOperator();
+ public void addPtrOperator( String ptrOp );
+ public void setType(int i);
+ public void setTypeSymbol(ISymbol typeSymbol);
+
+ public int getTypeInfo();
+ public void setTypeInfo( int typeInfo );
+ public void setPtrOperator(String string);
+ public boolean canHold(ITypeInfo src);
+ public String getInvertedPtrOperator();
+ public void setCVQualifier(int i);
+ public boolean getHasDefault();
+ public void setHasDefault(boolean hasDefault);
+ }
+ */
+ public int getDepth();
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTable.java 13 Jun 2003 14:58:13 -0000
@@ -0,0 +1,3573 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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:
+ * Rational Software - Initial API and implementation
+ *
+***********************************************************************/
+
+
+package org.eclipse.cdt.internal.core.parser.pst;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.core.parser.ast.AccessVisibility;
+import org.eclipse.cdt.internal.core.parser.ast.full.IPSTSymbolExtension;
+
+/**
+ * @author aniefer
+ */
+
+public class ParserSymbolTable {
+
+ /**
+ * Constructor for ParserSymbolTable.
+ */
+ public ParserSymbolTable() {
+ super();
+ _compilationUnit = new Declaration("");
+ _compilationUnit.setType( TypeInfo.t_namespace );
+ }
+
+ public IContainerSymbol getCompilationUnit(){
+ return _compilationUnit;
+ }
+
+ public IContainerSymbol newContainerSymbol( String name ){
+ return new Declaration( name );
+ }
+ public IContainerSymbol newContainerSymbol( String name, TypeInfo.eType type ){
+ return new Declaration( name, type );
+ }
+
+ public ISymbol newSymbol( String name ){
+ return new BasicSymbol( name );
+ }
+ public ISymbol newSymbol( String name, TypeInfo.eType type ){
+ return new BasicSymbol( name, type );
+ }
+
+ public IDerivableContainerSymbol newDerivableContainerSymbol( String name ){
+ return new Declaration( name );
+ }
+ public IDerivableContainerSymbol newDerivableContainerSymbol( String name, TypeInfo.eType type ){
+ return new Declaration( name, type );
+ }
+ public IParameterizedSymbol newParameterizedSymbol( String name ){
+ return new Declaration( name );
+ }
+ public IParameterizedSymbol newParameterizedSymbol( String name, TypeInfo.eType type ){
+ return new Declaration( name, type );
+ }
+ public ISpecializedSymbol newSpecializedSymbol( String name ){
+ return new Declaration( name );
+ }
+ public ISpecializedSymbol newSpecializedSymbol( String name, TypeInfo.eType type ){
+ return new Declaration( name, type );
+ }
+ /**
+ * Lookup the name from LookupData starting in the inDeclaration
+ * @param data
+ * @param inDeclaration
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ */
+ static private void Lookup( LookupData data, IContainerSymbol inSymbol ) throws ParserSymbolTableException
+ {
+ if( data.type != TypeInfo.t_any && data.type.compareTo(TypeInfo.t_class) < 0 && data.upperType.compareTo(TypeInfo.t_union) > 0 ){
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
+ }
+
+ ISymbol symbol = null; //the return value
+ LinkedList transitives = new LinkedList(); //list of transitive using directives
+
+ //if this name define in this scope?
+ LookupInContained( data, inSymbol );
+
+ if( !data.ignoreUsingDirectives ){
+ //check nominated namespaces
+ //the transitives list is populated in LookupInNominated, and then
+ //processed in ProcessDirectives
+
+ data.visited.clear(); //each namesapce is searched at most once, so keep track
+
+ LookupInNominated( data, inSymbol, transitives );
+
+ //if we are doing a qualified lookup, only process using directives if
+ //we haven't found the name yet (and if we aren't ignoring them).
+ if( !data.qualified || data.foundItems == null ){
+ ProcessDirectives( inSymbol, data, transitives );
+
+ if( inSymbol.hasUsingDirectives() ){
+ ProcessDirectives( inSymbol, data, inSymbol.getUsingDirectives() );
+ }
+
+ while( data.usingDirectives != null && data.usingDirectives.get( inSymbol ) != null ){
+ transitives.clear();
+
+ LookupInNominated( data, inSymbol, transitives );
+
+ if( !data.qualified || data.foundItems == null ){
+ ProcessDirectives( inSymbol, data, transitives );
+ }
+ }
+ }
+ }
+
+ if( data.foundItems != null || data.stopAt == inSymbol ){
+ return;
+ }
+
+ if( inSymbol instanceof IDerivableContainerSymbol ){
+ //if we still havn't found it, check any parents we have
+ data.visited.clear(); //each virtual base class is searched at most once
+ symbol = LookupInParents( data, (IDerivableContainerSymbol)inSymbol );
+
+ //there is a resolveAmbiguities inside LookupInParents, which means if we found
+ //something the foundItems set will be non-null, but empty. So, add the decl into
+ //the foundItems set
+ if( symbol != null ){
+ data.foundItems.add( symbol );
+ }
+ }
+
+ //if still not found, check our containing scope.
+ if( data.foundItems == null && inSymbol.getContainingSymbol() != null ){
+ Lookup( data, inSymbol.getContainingSymbol() );
+ }
+
+ return;
+ }
+
+ /**
+ * function LookupInNominated
+ * @param data
+ * @param transitiveDirectives
+ * @return List
+ *
+ * for qualified:
+ * 3.4.3.2-2 "let S be the set of all declarations of m in X
+ * and in the transitive closure of all namespaces nominated by using-
+ * directives in X and its used namespaces, except that using-directives are
+ * ignored in any namespace, including X, directly containing one or more
+ * declarations of m."
+ *
+ * for unqualified:
+ * 7.3.4-2 The using-directive is transitive: if a scope contains a using
+ * directive that nominates a second namespace that itself contains using-
+ * directives, the effect is as if the using-directives from the second
+ * namespace also appeared in the first.
+ */
+ static private void LookupInNominated( LookupData data, IContainerSymbol symbol, LinkedList transitiveDirectives ){
+ //if the data.usingDirectives is empty, there is nothing to do.
+ if( data.usingDirectives == null ){
+ return;
+ }
+
+ //local variables
+ LinkedList directives = null; //using directives association with declaration
+ Iterator iter = null;
+ IContainerSymbol temp = null;
+
+ boolean foundSomething = false;
+ int size = 0;
+
+ directives = (LinkedList) data.usingDirectives.remove( symbol );
+
+ if( directives == null ){
+ return;
+ }
+
+ iter = directives.iterator();
+ size = directives.size();
+ for( int i = size; i > 0; i-- ){
+ temp = (IContainerSymbol) iter.next();
+
+ //namespaces are searched at most once
+ if( !data.visited.contains( temp ) ){
+ data.visited.add( temp );
+
+ foundSomething = LookupInContained( data, temp );
+
+ //only consider the transitive using directives if we are an unqualified
+ //lookup, or we didn't find the name in decl
+ if( (!data.qualified || !foundSomething ) && temp.getUsingDirectives() != null ){
+ //name wasn't found, add transitive using directives for later consideration
+ transitiveDirectives.addAll( temp.getUsingDirectives() );
+ }
+ }
+ }
+
+ return;
+ }
+
+ /**
+ * function LookupInContained
+ * @param data
+ * @return List
+ *
+ * Look for data.name in our collection _containedDeclarations
+ */
+ private static boolean LookupInContained( LookupData data, IContainerSymbol lookIn ){
+
+ boolean foundSomething = false;
+ ISymbol temp = null;
+ Object obj = null;
+
+ if( data.associated != null ){
+ //we are looking in lookIn, remove it from the associated scopes list
+ data.associated.remove( lookIn );
+ }
+
+ Map declarations = lookIn.getContainedSymbols();
+
+ obj = ( declarations != null ) ? declarations.get( data.name ) : null;
+
+ if( obj != null ){
+ //the contained declarations map either to a Declaration object, or to a list
+ //of declaration objects.
+ if( obj instanceof ISymbol ){
+ temp = (ISymbol) obj;
+ //if( ((ISymbol)obj).isType( data.type, data.upperType ) ){
+ if( checkType( data, temp, data.type, data.upperType ) ){
+ if( data.foundItems == null ){
+ data.foundItems = new HashSet();
+ }
+ if( temp.isTemplateMember() )
+ data.foundItems.add( temp.getSymbolTable().new TemplateInstance( temp, data.templateInstance.getArgumentMap() ) );
+ else
+ data.foundItems.add( temp );
+
+ foundSomething = true;
+ }
+ } else {
+ //we have to filter on type so can't just add the list whole to the fount set
+ LinkedList objList = (LinkedList)obj;
+ Iterator iter = objList.iterator();
+ int size = objList.size();
+
+ for( int i = 0; i < size; i++ ){
+ temp = (ISymbol) iter.next();
+
+ //if( temp.isType( data.type, data.upperType ) ){
+ if( checkType( data, temp, data.type, data.upperType ) ){
+ if( data.foundItems == null ){
+ data.foundItems = new HashSet();
+ }
+ if( temp.isTemplateMember() )
+ data.foundItems.add( temp.getSymbolTable().new TemplateInstance( temp, data.templateInstance.getArgumentMap() ) );
+ else
+ data.foundItems.add(temp);
+ foundSomething = true;
+ }
+ }
+ }
+ }
+
+ if( foundSomething ){
+ return foundSomething;
+ }
+
+ if( lookIn instanceof IParameterizedSymbol ){
+ Map parameters = ((IParameterizedSymbol)lookIn).getParameterMap();
+ if( parameters != null ){
+ obj = parameters.get( data.name );
+ //if( obj != null && ((ISymbol)obj).isType( data.type, data.upperType ) ){
+ if( obj != null && checkType( data, (ISymbol)obj, data.type, data.upperType ) ){
+ if( data.foundItems == null ){
+ data.foundItems = new HashSet();
+ }
+ ISymbol symbol = (ISymbol) obj;
+
+ if( symbol.isTemplateMember() && data.templateInstance != null ){
+ data.foundItems.add( symbol.getSymbolTable().new TemplateInstance( symbol, data.templateInstance.getArgumentMap() ) );
+ } else {
+ data.foundItems.add( symbol );
+ }
+
+ foundSomething = true;
+ }
+ }
+ }
+
+ return foundSomething;
+ }
+
+ private static boolean checkType( LookupData data, ISymbol symbol, TypeInfo.eType type, TypeInfo.eType upperType ){
+ if( data.templateInstance != null && symbol.isTemplateMember() ){
+ if( symbol.isType( TypeInfo.t_type ) ){
+ symbol = symbol.getTypeSymbol();
+ }
+ if( symbol.isType( TypeInfo.t_undef ) && symbol.getContainingSymbol().isType( TypeInfo.t_template ) ){
+ TypeInfo info = (TypeInfo) data.templateInstance.getArgumentMap().get( symbol );
+ return info.isType( type, upperType );
+ }
+ }
+ return symbol.isType( type, upperType );
+ }
+
+ /**
+ *
+ * @param data
+ * @param lookIn
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ */
+ private static ISymbol LookupInParents( LookupData data, ISymbol lookIn ) throws ParserSymbolTableException{
+ IDerivableContainerSymbol container = null;
+ if( lookIn instanceof TemplateInstance ){
+
+ } else if( lookIn instanceof IDerivableContainerSymbol ){
+ container = (IDerivableContainerSymbol) lookIn;
+ } else{
+ throw new ParserSymbolTableException();
+ }
+
+ List scopes = container.getParents();
+ boolean foundSomething = false;
+ ISymbol temp = null;
+ ISymbol symbol = null;
+
+ Iterator iterator = null;
+ IDerivableContainerSymbol.IParentSymbol wrapper = null;
+
+ if( scopes == null )
+ return null;
+
+ //use data to detect circular inheritance
+ if( data.inheritanceChain == null )
+ data.inheritanceChain = new HashSet();
+
+ data.inheritanceChain.add( container );
+
+ iterator = scopes.iterator();
+
+ int size = scopes.size();
+
+ for( int i = size; i > 0; i-- )
+ {
+ wrapper = (IDerivableContainerSymbol.IParentSymbol) iterator.next();
+ ISymbol parent = wrapper.getParent();
+ if( parent.isType( TypeInfo.t_undef ) && parent.getContainingSymbol().isType( TypeInfo.t_template ) ){
+ TypeInfo info = (TypeInfo) data.templateInstance.getArgumentMap().get( parent );
+ if( info.getTypeSymbol() instanceof IDerivableContainerSymbol ){
+ parent = (IDerivableContainerSymbol) info.getTypeSymbol();
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
+ }
+ }
+ if( !wrapper.isVirtual() || !data.visited.contains( parent ) ){
+ if( wrapper.isVirtual() ){
+ data.visited.add( parent );
+ }
+
+ //if the inheritanceChain already contains the parent, then that
+ //is circular inheritance
+ if( ! data.inheritanceChain.contains( parent ) ){
+ //is this name define in this scope?
+ if( parent instanceof TemplateInstance ){
+ ISymbol tempInstance = data.templateInstance;
+ data.templateInstance = (TemplateInstance) parent;
+ ISymbol instance = ((TemplateInstance)parent).getInstantiatedSymbol();
+ if( instance instanceof IContainerSymbol )
+ LookupInContained( data, (IContainerSymbol)instance );
+ else
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
+ data.templateInstance = tempInstance;
+ } else if( parent instanceof IDerivableContainerSymbol ){
+ LookupInContained( data, (IDerivableContainerSymbol) parent );
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
+ }
+ temp = ResolveAmbiguities( data );
+ if( temp == null ){
+ temp = LookupInParents( data, parent );
+ }
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_CircularInheritance );
+ }
+ }
+
+ if( temp != null && temp.isType( data.type ) ){
+
+ if( symbol == null ){
+ symbol = temp;
+ } else if ( temp != null ) {
+ //it is not ambiguous if temp & decl are the same thing and it is static
+ //or an enumerator
+ TypeInfo type = temp.getTypeInfo();
+
+ if( symbol == temp && ( type.checkBit( TypeInfo.isStatic ) || type.isType( TypeInfo.t_enumerator ) ) ){
+ temp = null;
+ } else {
+ throw( new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous ) );
+ }
+
+ }
+ } else {
+ temp = null; //reset temp for next iteration
+ }
+ }
+
+ data.inheritanceChain.remove( container );
+
+ return symbol;
+ }
+
+ /**
+ * function isValidOverload
+ * @param origDecl
+ * @param newDecl
+ * @return boolean
+ *
+ * 3.3.7 "A class name or enumeration name can be hidden by the name of an
+ * object, function or enumerator declared in the same scope"
+ *
+ * 3.4-1 "Name lookup may associate more than one declaration with a name if
+ * it finds the name to be a function name"
+ */
+ private static boolean isValidOverload( ISymbol origSymbol, ISymbol newSymbol ){
+ TypeInfo.eType origType = origSymbol.getType();
+ TypeInfo.eType newType = newSymbol.getType();
+
+ if( (origType.compareTo(TypeInfo.t_class) >= 0 && origType.compareTo(TypeInfo.t_enumeration) <= 0) && //class name or enumeration ...
+ ( newType == TypeInfo.t_type || (newType.compareTo( TypeInfo.t_function ) >= 0 /*&& newType <= TypeInfo.typeMask*/) ) ){
+
+ return true;
+ }
+ //if the origtype is not a class-name or enumeration name, then the only other
+ //allowable thing is if they are both functions.
+ if( origSymbol instanceof IParameterizedSymbol && newSymbol instanceof IParameterizedSymbol )
+ return isValidFunctionOverload( (IParameterizedSymbol) origSymbol, (IParameterizedSymbol) newSymbol );
+ else
+ return false;
+ }
+
+ private static boolean isValidOverload( LinkedList origList, ISymbol newSymbol ){
+ if( origList.size() == 1 ){
+ return isValidOverload( (ISymbol)origList.getFirst(), newSymbol );
+ } else if ( origList.size() > 1 ){
+
+ //the first thing can be a class-name or enumeration name, but the rest
+ //must be functions. So make sure the newDecl is a function before even
+ //considering the list
+ if( newSymbol.getType() != TypeInfo.t_function ){
+ return false;
+ }
+
+ Iterator iter = origList.iterator();
+ ISymbol symbol = (ISymbol) iter.next();
+ boolean valid = ( (symbol.getType().compareTo( TypeInfo.t_class ) >= 0 ) && (symbol.getType().compareTo( TypeInfo.t_enumeration ) <= 0 ) );
+ if( !valid && (symbol instanceof IParameterizedSymbol) )
+ valid = isValidFunctionOverload( (IParameterizedSymbol)symbol, (IParameterizedSymbol)newSymbol );
+
+ while( valid && iter.hasNext() ){
+ symbol = (ISymbol) iter.next();
+ valid = ( symbol instanceof IParameterizedSymbol) && isValidFunctionOverload( (IParameterizedSymbol)symbol, (IParameterizedSymbol)newSymbol );
+ }
+
+ return valid;
+ }
+
+ //empty list, return true
+ return true;
+ }
+
+ private static boolean isValidFunctionOverload( IParameterizedSymbol origSymbol, IParameterizedSymbol newSymbol ){
+ if( origSymbol.getType() != TypeInfo.t_function || newSymbol.getType() != TypeInfo.t_function ){
+ return false;
+ }
+
+ if( origSymbol.hasSameParameters( newSymbol ) ){
+ //functions with the same name and same parameter types cannot be overloaded if any of them
+ //is static
+ if( origSymbol.getTypeInfo().checkBit( TypeInfo.isStatic ) || newSymbol.getTypeInfo().checkBit( TypeInfo.isStatic ) ){
+ return false;
+ }
+
+ //if none of them are static, then the function can be overloaded if they differ in the type
+ //of their implicit object parameter.
+ if( origSymbol.compareCVQualifiersTo( newSymbol ) != 0 ){
+ return true;
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ * @param data
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ *
+ * Resolve the foundItems set down to one declaration and return that
+ * declaration.
+ * If we successfully resolve, then the data.foundItems list will be
+ * cleared. If however, we were not able to completely resolve the set,
+ * then the data.foundItems set will be left with those items that
+ * survived the partial resolution and we will return null. (currently,
+ * this case applies to when we have overloaded functions and no parameter
+ * information)
+ *
+ * NOTE: data.parameters == null means there is no parameter information at
+ * all, when looking for functions with no parameters, an empty list must be
+ * provided in data.parameters.
+ */
+ static private ISymbol ResolveAmbiguities( LookupData data ) throws ParserSymbolTableException{
+ ISymbol decl = null;
+ ISymbol obj = null;
+ IContainerSymbol cls = null;
+
+ if( data.foundItems == null ){
+ return null;
+ }
+
+ int size = data.foundItems.size();
+ Iterator iter = data.foundItems.iterator();
+
+ boolean needDecl = true;
+
+ if( size == 0){
+ return null;
+ } else if (size == 1) {
+ decl = (ISymbol) iter.next();
+ //if it is a function we need to check its parameters
+ if( !decl.isType( TypeInfo.t_function ) ){
+ data.foundItems.clear();
+ return decl;
+ }
+ needDecl = false;
+ }
+
+ LinkedList functionList = null;
+
+ for( int i = size; i > 0; i-- ){
+ //if we
+ if( needDecl ){
+ decl = (ISymbol) iter.next();
+ } else {
+ needDecl = true;
+ }
+
+ if( decl.isType( TypeInfo.t_function ) ){
+ if( functionList == null){
+ functionList = new LinkedList();
+ }
+ functionList.add( decl );
+ } else {
+ //if this is a class-name, other stuff hides it
+ if( decl.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) ){
+ if( cls == null ) {
+ cls = (IContainerSymbol) decl;
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
+ }
+ } else {
+ //an object, can only have one of these
+ if( obj == null ){
+ obj = decl;
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
+ }
+ }
+ }
+
+ decl = null;
+ }
+
+ data.foundItems.clear();
+
+ int numFunctions = ( functionList == null ) ? 0 : functionList.size();
+
+ boolean ambiguous = false;
+
+ if( cls != null ){
+ //the class is only hidden by other stuff if they are from the same scope
+ if( obj != null && cls.getContainingSymbol() != obj.getContainingSymbol()){
+ ambiguous = true;
+ }
+ if( functionList != null ){
+ Iterator fnIter = functionList.iterator();
+ IParameterizedSymbol fn = null;
+ for( int i = numFunctions; i > 0; i-- ){
+ fn = (IParameterizedSymbol) fnIter.next();
+ if( cls.getContainingSymbol()!= fn.getContainingSymbol()){
+ ambiguous = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if( obj != null && !ambiguous ){
+ if( numFunctions > 0 ){
+ ambiguous = true;
+ } else {
+ return obj;
+ }
+ } else if( numFunctions > 0 ) {
+ if( data.parameters == null ){
+ //we have no parameter information, if we only have one function, return
+ //that, otherwise we can't decide between them
+ if( numFunctions == 1){
+ return (ISymbol) functionList.getFirst();
+ } else {
+ data.foundItems.addAll( functionList );
+ return null;
+ }
+ } else {
+ return ResolveFunction( data, functionList );
+ }
+ }
+
+ if( ambiguous ){
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
+ } else {
+ return cls;
+ }
+ }
+
+ static private IParameterizedSymbol ResolveFunction( LookupData data, LinkedList functions ) throws ParserSymbolTableException{
+
+ ReduceToViable( data, functions );
+
+ int numSourceParams = ( data.parameters == null ) ? 0 : data.parameters.size();
+ int numFns = functions.size();
+
+ if( numSourceParams == 0 ){
+ //no parameters
+ //if there is only 1 viable function, return it, if more than one, its ambiguous
+ if( numFns == 0 ){
+ return null;
+ } else if ( numFns == 1 ){
+ return (IParameterizedSymbol)functions.getFirst();
+ } else{
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
+ }
+ }
+
+ IParameterizedSymbol bestFn = null; //the best function
+ IParameterizedSymbol currFn = null; //the function currently under consideration
+ Cost [] bestFnCost = null; //the cost of the best function
+ Cost [] currFnCost = null; //the cost for the current function
+
+ Iterator iterFns = functions.iterator();
+ Iterator sourceParams = null;
+ Iterator targetParams = null;
+
+ int numTargetParams = 0;
+ int numParams = 0;
+ int comparison;
+ Cost cost = null;
+ Cost temp = null;
+
+ TypeInfo source = null;
+ TypeInfo target = null;
+
+ boolean hasWorse = false;
+ boolean hasBetter = false;
+ boolean ambiguous = false;
+ boolean currHasAmbiguousParam = false;
+ boolean bestHasAmbiguousParam = false;
+
+ for( int i = numFns; i > 0; i-- ){
+ currFn = (IParameterizedSymbol) iterFns.next();
+
+ sourceParams = data.parameters.iterator();
+ targetParams = currFn.getParameterList().iterator();
+
+ //number of parameters in the current function
+ numTargetParams = currFn.getParameterList().size();
+
+ //we only need to look at the smaller number of parameters
+ //(a larger number in the Target means default parameters, a larger
+ //number in the source means ellipses.)
+ numParams = ( numTargetParams < numSourceParams ) ? numTargetParams : numSourceParams;
+
+ if( currFnCost == null ){
+ currFnCost = new Cost [ numParams ];
+ }
+
+ comparison = 0;
+
+ for( int j = 0; j < numParams; j++ ){
+ source = (TypeInfo) sourceParams.next();
+ target = ((ISymbol)targetParams.next()).getTypeInfo();
+ if( source.equals( target ) ){
+ cost = new Cost( source, target );
+ cost.rank = 0; //exact match, no cost
+ } else {
+ cost = checkStandardConversionSequence( source, target );
+
+ if( cost.rank == -1){
+ temp = checkUserDefinedConversionSequence( source, target );
+ if( temp != null ){
+ cost = temp;
+ }
+ }
+ }
+
+ currFnCost[ j ] = cost;
+ }
+
+
+ hasWorse = false;
+ hasBetter = false;
+
+ for( int j = 0; j < numParams; j++ ){
+ if( currFnCost[ j ].rank < 0 ){
+ hasWorse = true;
+ hasBetter = false;
+ break;
+ }
+
+ currHasAmbiguousParam = ( currFnCost[ j ].userDefined == 1 );
+
+ if( bestFnCost != null ){
+ comparison = currFnCost[ j ].compare( bestFnCost[ j ] );
+ hasWorse |= ( comparison < 0 );
+ hasBetter |= ( comparison > 0 );
+ } else {
+ hasBetter = true;
+ }
+ }
+
+ ambiguous |= ( hasWorse && hasBetter ) || ( !hasWorse && !hasBetter );
+
+ if( !hasWorse ){
+ if( hasBetter ){
+ ambiguous = false;
+ bestFnCost = currFnCost;
+ bestHasAmbiguousParam = currHasAmbiguousParam;
+ currFnCost = null;
+ bestFn = currFn;
+ }
+ }
+ }
+
+ if( ambiguous || bestHasAmbiguousParam ){
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_Ambiguous );
+ }
+
+ return bestFn;
+ }
+
+ static private void ReduceToViable( LookupData data, LinkedList functions ){
+ int numParameters = ( data.parameters == null ) ? 0 : data.parameters.size();
+ int num;
+
+ //Trim the list down to the set of viable functions
+ IParameterizedSymbol function;
+ Iterator iter = functions.iterator();
+ while( iter.hasNext() ){
+ function = (IParameterizedSymbol) iter.next();
+ num = ( function.getParameterList() == null ) ? 0 : function.getParameterList().size();
+
+ //if there are m arguments in the list, all candidate functions having m parameters
+ //are viable
+ if( num == numParameters ){
+ continue;
+ }
+ //A candidate function having fewer than m parameters is viable only if it has an
+ //ellipsis in its parameter list.
+ else if( num < numParameters ) {
+ //TODO ellipsis
+ //not enough parameters, remove it
+ iter.remove();
+ }
+ //a candidate function having more than m parameters is viable only if the (m+1)-st
+ //parameter has a default argument
+ else {
+ ListIterator listIter = function.getParameterList().listIterator( num );
+ TypeInfo param;
+ for( int i = num; i > ( numParameters - num + 1); i-- ){
+ param = ((ISymbol)listIter.previous()).getTypeInfo();
+ if( !param.getHasDefault() ){
+ iter.remove();
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * function ProcessDirectives
+ * @param Declaration decl
+ * @param LookupData data
+ * @param LinkedList directives
+ *
+ * Go through the directives and for each nominated namespace find the
+ * closest enclosing declaration for that namespace and decl, then add the
+ * nominated namespace to the lookup data for consideration when we reach
+ * the enclosing declaration.
+ */
+ static private void ProcessDirectives( IContainerSymbol symbol, LookupData data, List directives ){
+ IContainerSymbol enclosing = null;
+ IContainerSymbol temp = null;
+
+ int size = directives.size();
+ Iterator iter = directives.iterator();
+
+ for( int i = size; i > 0; i-- ){
+ temp = (IContainerSymbol) iter.next();
+
+ //namespaces are searched at most once
+ if( !data.visited.contains( temp ) ){
+ enclosing = getClosestEnclosingDeclaration( symbol, temp );
+
+ //the data.usingDirectives is a map from enclosing declaration to
+ //a list of namespaces to consider when we reach that enclosing
+ //declaration
+ LinkedList list = (data.usingDirectives == null )
+ ? null
+ : (LinkedList) data.usingDirectives.get( enclosing );
+ if ( list == null ){
+ list = new LinkedList();
+ list.add( temp );
+ if( data.usingDirectives == null ){
+ data.usingDirectives = new HashMap();
+ }
+ data.usingDirectives.put( enclosing, list );
+ } else {
+ list.add( temp );
+ }
+ }
+ }
+ }
+
+ /**
+ * function getClosestEnclosingDeclaration
+ * @param decl1
+ * @param decl2
+ * @return Declaration
+ *
+ * 7.3.4-1 "During unqualified lookup, the names appear as if they were
+ * declared in the nearest enclosing namespace which contains both the
+ * using-directive and the nominated namespace"
+ *
+ * TBD: Consider rewriting this iteratively instead of recursively, for
+ * performance
+ */
+ static private IContainerSymbol getClosestEnclosingDeclaration( ISymbol symbol1, ISymbol symbol2 ){
+ if( symbol1 == symbol2 ){
+ return ( symbol1 instanceof IContainerSymbol ) ? (IContainerSymbol) symbol1 : symbol1.getContainingSymbol();
+ }
+
+ if( symbol1.getDepth() == symbol2.getDepth() ){
+ return getClosestEnclosingDeclaration( symbol1.getContainingSymbol(), symbol2.getContainingSymbol() );
+ } else if( symbol1.getDepth() > symbol2.getDepth() ) {
+ return getClosestEnclosingDeclaration( symbol1.getContainingSymbol(), symbol2 );
+ } else {
+ return getClosestEnclosingDeclaration( symbol1, symbol2.getContainingSymbol() );
+ }
+ }
+
+ /**
+ *
+ * @param obj
+ * @param base
+ * @return int
+ * figure out if base is a base class of obj, and return the "distance" to
+ * the base class.
+ * ie:
+ * A -> B -> C
+ * the distance from A to B is 1 and from A to C is 2. This distance is used
+ * to rank standard pointer conversions.
+ *
+ * TBD: Consider rewriting iteratively for performance.
+ */
+ static private int hasBaseClass( ISymbol obj, ISymbol base ){
+ if( obj == base ){
+ return 0;
+ }
+ IDerivableContainerSymbol symbol = null;
+ TemplateInstance instance = null;
+ if( obj instanceof TemplateInstance ){
+ instance = (TemplateInstance) obj;
+ ISymbol temp = instance.getInstantiatedSymbol();
+ if( temp instanceof IDerivableContainerSymbol ){
+ symbol = (IDerivableContainerSymbol) temp;
+ } else {
+ return -1;
+ }
+ } else if( obj instanceof IDerivableContainerSymbol ){
+ symbol = (IDerivableContainerSymbol) obj;
+ } else {
+ return -1;
+ }
+
+ if( symbol.hasParents() ){
+ ISymbol temp = null;
+ IDerivableContainerSymbol parent = null;
+ IDerivableContainerSymbol.IParentSymbol wrapper;
+
+ Iterator iter = symbol.getParents().iterator();
+ int size = symbol.getParents().size();
+
+ for( int i = size; i > 0; i-- ){
+ wrapper = (IDerivableContainerSymbol.IParentSymbol) iter.next();
+ temp = wrapper.getParent();
+
+ if( temp instanceof TemplateInstance ){
+ instance = (TemplateInstance) temp;
+ if( instance.getInstantiatedSymbol() instanceof IDerivableContainerSymbol ){
+ if( instance.getInstantiatedSymbol() == base ){
+ return 1;
+ } else {
+ int n = hasBaseClass( instance, base );
+ if( n > 0 ){
+ return n + 1;
+ }
+ }
+ }
+ } else {
+ if( temp.isType( TypeInfo.t_undef ) && temp.getContainingSymbol().isType( TypeInfo.t_template ) ){
+ if( instance == null ) continue;
+ TypeInfo info = (TypeInfo) instance.getArgumentMap().get( temp );
+ if( info == null || !info.isType( TypeInfo.t_class, TypeInfo.t_struct ) ){
+ continue;
+ }
+ parent = (IDerivableContainerSymbol) info.getTypeSymbol();
+ }
+ else if ( temp instanceof IDerivableContainerSymbol ){
+ parent = (IDerivableContainerSymbol)temp;
+ } else {
+ continue;
+ }
+ if( parent == base ){
+ return 1;
+ } else {
+ int n = hasBaseClass( parent, base );
+ if( n > 0 ){
+ return n + 1;
+ }
+ }
+ }
+ }
+ }
+
+ return -1;
+ }
+
+ static private void getAssociatedScopes( ISymbol symbol, HashSet associated ){
+ if( symbol == null ){
+ return;
+ }
+ //if T is a class type, its associated classes are the class itself,
+ //and its direct and indirect base classes. its associated Namespaces are the
+ //namespaces in which its associated classes are defined
+ //if( symbol.getType() == TypeInfo.t_class ){
+ if( symbol instanceof IDerivableContainerSymbol ){
+ associated.add( symbol );
+ getBaseClassesAndContainingNamespaces( (IDerivableContainerSymbol) symbol, associated );
+ }
+ //if T is a union or enumeration type, its associated namespace is the namespace in
+ //which it is defined. if it is a class member, its associated class is the member's
+ //class
+ else if( symbol.getType() == TypeInfo.t_union || symbol.getType() == TypeInfo.t_enumeration ){
+ associated.add( symbol.getContainingSymbol() );
+ }
+ }
+
+ static private void getBaseClassesAndContainingNamespaces( IDerivableContainerSymbol obj, HashSet classes ){
+ if( obj.getParents() != null ){
+ if( classes == null ){
+ return;
+ }
+
+ Iterator iter = obj.getParents().iterator();
+ int size = obj.getParents().size();
+ Declaration.ParentWrapper wrapper;
+ IDerivableContainerSymbol base;
+
+ for( int i = size; i > 0; i-- ){
+ wrapper = (Declaration.ParentWrapper) iter.next();
+ base = (Declaration) wrapper.parent;
+ classes.add( base );
+ if( base.getContainingSymbol().getType() == TypeInfo.t_namespace ){
+ classes.add( base.getContainingSymbol());
+ }
+
+ getBaseClassesAndContainingNamespaces( base, classes );
+ }
+ }
+ }
+
+ static private boolean okToAddUsingDeclaration( ISymbol obj, IContainerSymbol context ){
+ boolean okToAdd = false;
+
+ //7.3.3-5 A using-declaration shall not name a template-id
+ if( obj.isTemplateMember() && obj.getContainingSymbol().isType( TypeInfo.t_template ) ){
+ okToAdd = false;
+ }
+ //7.3.3-4
+ else if( context.isType( TypeInfo.t_class, TypeInfo.t_struct ) ){
+ IContainerSymbol container = obj.getContainingSymbol();
+ //a member of a base class
+ if( obj.getContainingSymbol().getType() == context.getType() ){
+ okToAdd = ( hasBaseClass( (IDerivableContainerSymbol) context, (IDerivableContainerSymbol) container ) > 0 );
+ }
+ else if ( obj.getContainingSymbol().getType() == TypeInfo.t_union ) {
+ // TODO : must be an _anonymous_ union
+ container = container.getContainingSymbol();
+ okToAdd = ( container instanceof IDerivableContainerSymbol )
+ ? ( hasBaseClass( (IDerivableContainerSymbol)context, (IDerivableContainerSymbol) container ) > 0 )
+ : false;
+ }
+ //an enumerator for an enumeration
+ else if ( obj.getType() == TypeInfo.t_enumerator ){
+ container = container.getContainingSymbol();
+ okToAdd = ( container instanceof IDerivableContainerSymbol )
+ ? ( hasBaseClass( (IDerivableContainerSymbol)context, (IDerivableContainerSymbol) container ) > 0 )
+ : false;
+ }
+ } else {
+ okToAdd = true;
+ }
+
+ return okToAdd;
+ }
+
+ static private Cost lvalue_to_rvalue( TypeInfo source, TypeInfo target ){
+
+ //lvalues will have type t_type
+ if( source.isType( TypeInfo.t_type ) ){
+ source = getFlatTypeInfo( source );
+ }
+
+ Cost cost = new Cost( source, target );
+ TypeInfo.PtrOp op = null;
+
+ if( cost.source.hasPtrOperators() ){
+ LinkedList sourcePtrs = cost.source.getPtrOperators();
+ TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)sourcePtrs.getFirst();
+
+ if( ptr.getType() == TypeInfo.PtrOp.t_reference ){
+ sourcePtrs.removeFirst();
+ }
+ int size = sourcePtrs.size();
+ Iterator iter = sourcePtrs.iterator();
+
+ for( int i = size; i > 0; i-- ){
+ op = (TypeInfo.PtrOp) iter.next();
+ if( op.getType() == TypeInfo.PtrOp.t_array ){
+ op.setType( TypeInfo.PtrOp.t_pointer );
+ }
+ }
+ }
+
+ if( cost.target.hasPtrOperators() ){
+ LinkedList targetPtrs = cost.target.getPtrOperators();
+ TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)targetPtrs.getFirst();
+
+ if( ptr.getType() == TypeInfo.PtrOp.t_reference ){
+ targetPtrs.removeFirst();
+ }
+ int size = targetPtrs.size();
+ Iterator iter = targetPtrs.iterator();
+
+ for( int i = size; i > 0; i-- ){
+ op = (TypeInfo.PtrOp) iter.next();
+ if( op.getType() == TypeInfo.PtrOp.t_array ){
+ op.setType( TypeInfo.PtrOp.t_pointer );
+ }
+ }
+ }
+
+ return cost;
+ }
+
+ static private void qualificationConversion( Cost cost ){
+ int size = cost.source.hasPtrOperators() ? cost.source.getPtrOperators().size() : 0;
+ int size2 = cost.target.hasPtrOperators() ? cost.target.getPtrOperators().size() : 0;
+
+ TypeInfo.PtrOp op1 = null, op2 = null;
+ boolean canConvert = true;
+
+ Iterator iter1 = cost.source.hasPtrOperators() ? cost.source.getPtrOperators().iterator() : null;
+ Iterator iter2 = cost.target.hasPtrOperators() ? cost.target.getPtrOperators().iterator() : null;
+
+ if( size != size2 ){
+ cost.qualification = 0;
+ return;
+ } else if ( size == 1 ){
+ op1 = (TypeInfo.PtrOp) iter1.next();
+ op2 = (TypeInfo.PtrOp) iter2.next();
+
+ if( ( op1.isConst() && !op2.isConst() ) ||
+ ( op1.isVolatile() && !op2.isVolatile() ) )
+ {
+ cost.qualification = 0;
+ return;
+ }
+ canConvert = true;
+ } else if( size > 0 ){
+ op1 = (TypeInfo.PtrOp) iter1.next();
+ op2 = (TypeInfo.PtrOp) iter2.next();
+
+ boolean constInEveryCV2k = true;
+
+ for( int j= 1; j < size; j++ ){
+ op1 = (TypeInfo.PtrOp) iter1.next();
+ op2 = (TypeInfo.PtrOp) iter2.next();
+
+ //pointer types are similar
+ if( op1.getType() != op2.getType() ){
+ canConvert = false;
+ break;
+ }
+ //if const is in cv1,j then const is in cv2,j. Similary for volatile
+ if( ( op1.isConst() && !op2.isConst() ) ||
+ ( op1.isVolatile() && !op2.isVolatile() ) )
+ {
+ canConvert = false;
+ break;
+ }
+
+ //if cv1,j and cv2,j are different then const is in every cv2,k for 0<k<j
+ if( ( op1.compareCVTo( op2 ) != 0 ) && !constInEveryCV2k ){
+ canConvert = false;
+ break;
+ }
+
+ constInEveryCV2k &= op2.isConst();
+ }
+ }
+
+ if( canConvert == true ){
+ cost.qualification = 1;
+ cost.rank = 0;
+ } else {
+ cost.qualification = 0;
+ }
+ }
+
+ /**
+ *
+ * @param source
+ * @param target
+ * @return int
+ *
+ * 4.5-1 char, signed char, unsigned char, short int or unsigned short int
+ * can be converted to int if int can represent all the values of the source
+ * type, otherwise they can be converted to unsigned int.
+ * 4.5-2 wchar_t or an enumeration can be converted to the first of the
+ * following that can hold it: int, unsigned int, long unsigned long.
+ * 4.5-4 bool can be promoted to int
+ * 4.6 float can be promoted to double
+ */
+ static private void promotion( Cost cost ){
+ TypeInfo src = cost.source;
+ TypeInfo trg = cost.target;
+
+ int mask = TypeInfo.isShort | TypeInfo.isLong | TypeInfo.isUnsigned;
+
+ if( (src.isType( TypeInfo.t_bool, TypeInfo.t_float ) || src.isType( TypeInfo.t_enumeration )) &&
+ (trg.isType( TypeInfo.t_int ) || trg.isType( TypeInfo.t_double )) )
+ {
+ if( src.getType() == trg.getType() && (( src.getTypeInfo() & mask) == (trg.getTypeInfo() & mask)) ){
+ //same, no promotion needed
+ return;
+ }
+
+ if( src.isType( TypeInfo.t_float ) ){
+ cost.promotion = trg.isType( TypeInfo.t_double ) ? 1 : 0;
+ } else {
+ cost.promotion = ( trg.isType( TypeInfo.t_int ) && trg.canHold( src ) ) ? 1 : 0;
+ }
+
+ } else {
+ cost.promotion = 0;
+ }
+
+ cost.rank = (cost.promotion > 0 ) ? 1 : -1;
+ }
+
+ /**
+ *
+ * @param source
+ * @param target
+ * @return int
+ *
+ */
+ static private void conversion( Cost cost ){
+ TypeInfo src = cost.source;
+ TypeInfo trg = cost.target;
+
+ int temp;
+
+ cost.conversion = 0;
+ cost.detail = 0;
+
+ if( !src.hasSamePtrs( trg ) ){
+ return;
+ }
+ if( src.hasPtrOperators() && src.getPtrOperators().size() == 1 ){
+ TypeInfo.PtrOp ptr = (TypeInfo.PtrOp)src.getPtrOperators().getFirst();
+ ISymbol srcDecl = src.isType( TypeInfo.t_type ) ? src.getTypeSymbol() : null;
+ ISymbol trgDecl = trg.isType( TypeInfo.t_type ) ? trg.getTypeSymbol() : null;
+ if( ptr.getType() == TypeInfo.PtrOp.t_pointer ){
+ if( srcDecl == null || (trgDecl == null && !trg.isType( TypeInfo.t_void )) ){
+ return;
+ }
+
+ //4.10-2 an rvalue of type "pointer to cv T", where T is an object type can be
+ //converted to an rvalue of type "pointer to cv void"
+ if( trg.isType( TypeInfo.t_void ) ){
+ cost.rank = 2;
+ cost.conversion = 1;
+ cost.detail = 2;
+ return;
+ }
+
+ cost.detail = 1;
+
+ //4.10-3 An rvalue of type "pointer to cv D", where D is a class type can be converted
+ // to an rvalue of type "pointer to cv B", where B is a base class of D.
+ if( (srcDecl instanceof IDerivableContainerSymbol) && trgDecl.isType( srcDecl.getType() ) ){
+ temp = hasBaseClass( (IDerivableContainerSymbol) srcDecl, (IDerivableContainerSymbol) trgDecl );
+ cost.rank = 2;
+ cost.conversion = ( temp > -1 ) ? temp : 0;
+ cost.detail = 1;
+ return;
+ }
+ } else if( ptr.getType() == TypeInfo.PtrOp.t_memberPointer ){
+ //4.11-2 An rvalue of type "pointer to member of B of type cv T", where B is a class type,
+ //can be converted to an rvalue of type "pointer to member of D of type cv T" where D is a
+ //derived class of B
+ if( srcDecl == null || trgDecl == null ){
+ return;
+ }
+
+ TypeInfo.PtrOp srcPtr = trg.hasPtrOperators() ? (TypeInfo.PtrOp)trg.getPtrOperators().getFirst() : null;
+ if( trgDecl.isType( srcDecl.getType() ) && srcPtr != null && srcPtr.getType() == TypeInfo.PtrOp.t_memberPointer ){
+ temp = hasBaseClass( (IDerivableContainerSymbol)ptr.getMemberOf(), (IDerivableContainerSymbol)srcPtr.getMemberOf() );
+ cost.rank = 2;
+ cost.detail = 1;
+ cost.conversion = ( temp > -1 ) ? temp : 0;
+ return;
+ }
+ }
+ } else if( !src.hasPtrOperators() ) {
+ //4.7 An rvalue of an integer type can be converted to an rvalue of another integer type.
+ //An rvalue of an enumeration type can be converted to an rvalue of an integer type.
+ if( src.isType( TypeInfo.t_bool, TypeInfo.t_int ) ||
+ src.isType( TypeInfo.t_float, TypeInfo.t_double ) ||
+ src.isType( TypeInfo.t_enumeration ) )
+ {
+ if( trg.isType( TypeInfo.t_bool, TypeInfo.t_int ) ||
+ trg.isType( TypeInfo.t_float, TypeInfo.t_double ) )
+ {
+ cost.rank = 2;
+ cost.conversion = 1;
+ }
+ }
+ }
+ }
+
+ static private Cost checkStandardConversionSequence( TypeInfo source, TypeInfo target ){
+ Cost cost = lvalue_to_rvalue( source, target );
+
+ if( cost.source.equals( cost.target ) ){
+ cost.rank = 0;
+ return cost;
+ }
+
+ qualificationConversion( cost );
+
+ //if we can't convert the qualifications, then we can't do anything
+ if( cost.qualification == 0 ){
+ return cost;
+ }
+
+ promotion( cost );
+ if( cost.promotion > 0 || cost.rank > -1 ){
+ return cost;
+ }
+
+ conversion( cost );
+
+ return cost;
+ }
+
+ static private Cost checkUserDefinedConversionSequence( TypeInfo source, TypeInfo target ) throws ParserSymbolTableException {
+ Cost cost = null;
+ Cost constructorCost = null;
+ Cost conversionCost = null;
+
+ ISymbol targetDecl = null;
+ ISymbol sourceDecl = null;
+ IParameterizedSymbol constructor = null;
+ IParameterizedSymbol conversion = null;
+
+ //constructors
+ if( target.getType() == TypeInfo.t_type ){
+ targetDecl = target.getTypeSymbol();
+ if( targetDecl.isType( TypeInfo.t_class, TypeInfo.t_union ) ){
+ LookupData data = new LookupData( "", TypeInfo.t_function, null );
+ LinkedList params = new LinkedList();
+ params.add( source );
+ data.parameters = params;
+ if( targetDecl instanceof TemplateInstance ){
+ data.templateInstance = targetDecl;
+ TemplateInstance instance = (TemplateInstance) targetDecl;
+ LookupInContained( data, (IContainerSymbol) instance.getInstantiatedSymbol() );
+ } else {
+ LookupInContained( data, (IContainerSymbol) targetDecl );
+ }
+
+ constructor = (IParameterizedSymbol)ResolveAmbiguities( data );
+ }
+ }
+
+ //conversion operators
+ if( source.getType() == TypeInfo.t_type ){
+ source = getFlatTypeInfo( source );
+ sourceDecl = source.getTypeSymbol();
+
+ if( sourceDecl != null && (sourceDecl instanceof IContainerSymbol) ){
+ String name = target.toString();
+
+ if( !name.equals("") ){
+ LookupData data = new LookupData( "operator " + name, TypeInfo.t_function, null );
+ LinkedList params = new LinkedList();
+ data.parameters = params;
+
+ LookupInContained( data, (IContainerSymbol) sourceDecl );
+ conversion = (IParameterizedSymbol)ResolveAmbiguities( data );
+ }
+ }
+ }
+
+ if( constructor != null ){
+ constructorCost = checkStandardConversionSequence( (TypeInfo) new TypeInfo( TypeInfo.t_type, 0, constructor.getContainingSymbol() ), target );
+ }
+ if( conversion != null ){
+ conversionCost = checkStandardConversionSequence( (TypeInfo) new TypeInfo( target.getType(), 0, target.getTypeSymbol() ), target );
+ }
+
+ //if both are valid, then the conversion is ambiguous
+ if( constructorCost != null && constructorCost.rank != -1 &&
+ conversionCost != null && conversionCost.rank != -1 )
+ {
+ cost = constructorCost;
+ cost.userDefined = 1;
+ cost.rank = 3;
+ } else {
+ if( constructorCost != null && constructorCost.rank != -1 ){
+ cost = constructorCost;
+ cost.userDefined = constructor.hashCode();
+ cost.rank = 3;
+ } else if( conversionCost != null && conversionCost.rank != -1 ){
+ cost = conversionCost;
+ cost.userDefined = conversion.hashCode();
+ cost.rank = 3;
+ }
+ }
+
+ return cost;
+ }
+
+ /**
+ *
+ * @param decl
+ * @return TypeInfo
+ * The top level TypeInfo represents modifications to the object and the
+ * remaining TypeInfo's represent the object.
+ */
+ // TODO move this to ITypeInfo ?
+ static private TypeInfo getFlatTypeInfo( TypeInfo topInfo ){
+ TypeInfo returnInfo = topInfo;
+ TypeInfo info = null;
+
+ if( topInfo.getType() == TypeInfo.t_type ){
+ returnInfo = (TypeInfo)new TypeInfo();
+
+ ISymbol typeSymbol = topInfo.getTypeSymbol();
+
+ info = topInfo.getTypeSymbol().getTypeInfo();
+
+ while( info.getType() == TypeInfo.t_type ){
+ typeSymbol = info.getTypeSymbol();
+
+ //returnInfo.addCVQualifier( info.getCVQualifier() );
+ returnInfo.addPtrOperator( info.getPtrOperators() );
+
+ info = info.getTypeSymbol().getTypeInfo();
+ }
+
+ if( info.isType( TypeInfo.t_class, TypeInfo.t_enumeration ) ){
+ returnInfo.setType( TypeInfo.t_type );
+ returnInfo.setTypeSymbol( typeSymbol );
+ } else {
+ returnInfo.setTypeInfo( info.getTypeInfo() );
+ returnInfo.setType( info.getType() );
+ returnInfo.setTypeSymbol( null );
+ }
+
+ returnInfo.applyPtrsAsUnaryOperators( topInfo.getPtrOperators() );
+ }
+
+ return returnInfo;
+ }
+
+ static private IParameterizedSymbol matchTemplatePartialSpecialization( IParameterizedSymbol template, LinkedList args ){
+ if( template == null ){
+ return null;
+ }
+
+ LinkedList specs = template.getSpecializations();
+ int size = ( specs != null ) ? specs.size() : 0;
+ if( size == 0 ){
+ return template;
+ }
+
+ IParameterizedSymbol bestMatch = null;
+ boolean bestMatchIsBest = true;
+ Iterator iter = specs.iterator();
+ IParameterizedSymbol spec = null;
+ LinkedList specArgs = null;
+ for( int i = size; i > 0; i-- ){
+ spec = (IParameterizedSymbol) iter.next();
+ specArgs = spec.getArgumentList();
+ if( specArgs == null || specArgs.size() != args.size() ){
+ continue;
+ }
+
+ ISymbol sym1 = null, sym2 = null;
+ Iterator iter1 = specArgs.iterator();
+ Iterator iter2 = args.iterator();
+
+ HashMap map = new HashMap();
+ String name = null;
+ boolean match = true;
+ for( int j = specArgs.size(); j > 0; j-- ){
+ sym1 = (ISymbol)iter1.next();
+ TypeInfo info2 = (TypeInfo) iter2.next();
+ if( info2.isType( TypeInfo.t_type ) ){
+ sym2 = sym2.getTypeSymbol();
+ } else {
+ sym2 = template.getSymbolTable().newSymbol( "" );
+ sym2.setTypeInfo( info2 );
+ }
+
+ if( !deduceTemplateArgument( map, sym1, sym2, null ) ){
+ match = false;
+ break;
+ }
+ /*
+ name = sym1.getName();
+ if( name.equals( "" ) ){
+ //no name, only type
+ } else if( map.containsKey( name ) ) {
+ ISymbol val = (ISymbol) map.get( name );
+ if( val.getType() != sym2.getType() ){
+ match = false;
+ break;
+ }
+ } else {
+ map.put( name, sym2 );
+ }
+ */
+ }
+ if( match ){
+ int compare = orderSpecializations( bestMatch, spec );
+ if( compare == 0 ){
+ bestMatchIsBest = false;
+ } else if( compare < 0 ) {
+ bestMatch = spec;
+ bestMatchIsBest = true;
+ }
+ }
+ }
+
+ return bestMatchIsBest ? bestMatch : null;
+ }
+
+ /**
+ * Compare spec1 to spec2. Return > 0 if spec1 is more specialized, < 0 if spec2
+ * is more specialized, = 0 otherwise.
+ * @param spec1
+ * @param spec2
+ * @return
+ */
+ static private int orderSpecializations( IParameterizedSymbol spec1, IParameterizedSymbol spec2 ){
+ if( spec1 == null ){
+ return -1;
+ }
+
+ Iterator iter = spec1.getContainedSymbols().keySet().iterator();
+ ISymbol decl = (ISymbol) spec1.getContainedSymbols().get( iter.next() );
+
+ //to order class template specializations, we need to transform them into function templates
+ if( decl.isType( TypeInfo.t_class ) ) {
+ spec1 = classTemplateSpecializationToFunctionTemplate( spec1 );
+ spec2 = classTemplateSpecializationToFunctionTemplate( spec2 );
+ }
+
+ TemplateInstance transformed1 = transformFunctionTemplateForOrdering( spec1 );
+ TemplateInstance transformed2 = transformFunctionTemplateForOrdering( spec2 );
+
+ //Using the transformed parameter list, perform argument deduction against the other
+ //function template
+ boolean d1 = deduceTemplateArguments( spec2, transformed1 );
+ boolean d2 = deduceTemplateArguments( spec1, transformed2 );
+
+ //The transformed template is at least as specialized as the other iff the deduction
+ //succeeds and the deduced parameter types are an exact match
+ //A template is more specialized than another iff it is at least as specialized as the
+ //other template and that template is not at least as specialized as the first.
+ if( d1 && d2 || !d1 && !d2 )
+ return 0;
+ else if( d1 && !d2 )
+ return 1;
+ else
+ return -1;
+ }
+
+ /**
+ *
+ * @param template
+ * @param args
+ * @return
+ *
+ * A type that is specified in terms of template parameters (P) is compared with an actual
+ * type (A), and an attempt is made to find template argument vaules that will make P,
+ * after substitution of the deduced values, compatible with A.
+ */
+ static private boolean deduceTemplateArguments( IParameterizedSymbol template, TemplateInstance argSource ){
+ if( template.getContainedSymbols() == null || template.getContainedSymbols().size() != 1 ){
+ return false;
+ }
+ Iterator iter = template.getContainedSymbols().keySet().iterator();
+ ISymbol templateSymbol = (ISymbol) template.getContainedSymbols().get( iter.next() );
+ if( !templateSymbol.isType( TypeInfo.t_function ) ){
+ return false;
+ }
+
+ IParameterizedSymbol argTemplate = (IParameterizedSymbol)argSource.getInstantiatedSymbol();
+ iter = argTemplate.getContainedSymbols().keySet().iterator();
+ ISymbol argFunction = (ISymbol) argTemplate.getContainedSymbols().get( iter.next() );
+ if( !argFunction.isType( TypeInfo.t_function ) ){
+ return false;
+ }
+
+ LinkedList args = ((IParameterizedSymbol) argFunction).getParameterList();
+
+ IParameterizedSymbol function = (IParameterizedSymbol) templateSymbol;
+
+ if( function.getParameterList() == null || function.getParameterList().size() != args.size() ){
+ return false;
+ }
+
+ HashMap map = new HashMap();
+
+ Iterator pIter = function.getParameterList().iterator();
+ Iterator aIter = args.iterator();
+ while( pIter.hasNext() ){
+ if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), (ISymbol) aIter.next(), argSource.getArgumentMap() ) ){
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ static private boolean deduceTemplateArgument( HashMap map, ISymbol p, ISymbol a, HashMap argumentMap ){
+ if( argumentMap != null && argumentMap.containsKey( a ) ){
+ a = (ISymbol) argumentMap.get( a );
+ }
+
+ ISymbol pSymbol = p, aSymbol = a;
+
+ if( p.isType( TypeInfo.t_type ) ){
+ pSymbol = p.getTypeSymbol();
+ aSymbol = a.isType( TypeInfo.t_type ) ? a.getTypeSymbol() : a;
+ return deduceTemplateArgument( map, pSymbol, aSymbol, argumentMap );
+ } else {
+ if( pSymbol.isTemplateMember() && pSymbol.isType( TypeInfo.t_undef ) ){
+ //T* or T& or T[ const ]
+ //also
+ LinkedList pPtrs = pSymbol.getPtrOperators();
+ LinkedList aPtrs = aSymbol.getPtrOperators();
+
+ if( pPtrs != null ){
+ TypeInfo.PtrOp pOp = (TypeInfo.PtrOp) pPtrs.getFirst();
+ TypeInfo.PtrOp aOp = ( aPtrs != null ) ? (TypeInfo.PtrOp)aPtrs.getFirst() : null;
+
+ if( pOp != null && aOp != null && pOp.getType() == aOp.getType() ){
+ if( pOp.getType() == TypeInfo.PtrOp.t_memberPointer ){
+
+ } else {
+ TypeInfo type = new TypeInfo( aSymbol.getTypeInfo() );
+ type.getPtrOperators().clear();
+ map.put( pSymbol.getName(), type );
+ return true;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ //T
+ map.put( pSymbol.getName(), a.getTypeInfo() );
+ return true;
+ }
+
+
+ }
+ //template-name<T> or template-name<i>
+ else if( pSymbol.isType( TypeInfo.t_template ) && aSymbol.isType( TypeInfo.t_template ) ){
+ LinkedList pArgs = ((IParameterizedSymbol)pSymbol).getArgumentList();
+ LinkedList aArgs = ((IParameterizedSymbol)aSymbol).getArgumentList();
+
+ if( pArgs == null || aArgs == null || pArgs.size() != aArgs.size()){
+ return false;
+ }
+ Iterator pIter = pArgs.iterator();
+ Iterator aIter = aArgs.iterator();
+ while( pIter.hasNext() ){
+ if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), (ISymbol) aIter.next(), argumentMap ) ){
+ return false;
+ }
+ }
+ }
+ //T (*) ( ), T ( T::* ) ( T ), & variations
+ else if( pSymbol.isType( TypeInfo.t_function ) && aSymbol.isType( TypeInfo.t_function ) ){
+ IParameterizedSymbol pFunction = (IParameterizedSymbol)pSymbol;
+ IParameterizedSymbol aFunction = (IParameterizedSymbol)aSymbol;
+
+ if( !deduceTemplateArgument( map, aFunction.getReturnType(), pFunction.getReturnType(), argumentMap ) ){
+ return false;
+ }
+ if( pSymbol.getPtrOperators() != null ){
+ LinkedList ptrs = pSymbol.getPtrOperators();
+ TypeInfo.PtrOp op = (TypeInfo.PtrOp) ptrs.getFirst();
+ if( op.getType() == TypeInfo.PtrOp.t_memberPointer ){
+ if( !deduceTemplateArgument( map, op.getMemberOf(), pFunction.getContainingSymbol(), argumentMap ) ){
+ return false;
+ }
+ }
+ }
+
+ LinkedList pParams = pFunction.getParameterList();
+ LinkedList aParams = aFunction.getParameterList();
+ if( pParams.size() != aParams.size() ){
+ return false;
+ } else {
+ Iterator pIter = pParams.iterator();
+ Iterator aIter = aParams.iterator();
+ while( pIter.hasNext() ){
+ if( !deduceTemplateArgument( map, (ISymbol) pIter.next(), (ISymbol) aIter.next(), argumentMap ) ){
+ return false;
+ }
+ }
+ }
+
+ } else if( pSymbol.getType() == aSymbol.getType() ){
+ if( pSymbol.getTypeInfo().getHasDefault() ){
+ if( !aSymbol.getTypeInfo().getHasDefault() ||
+ aSymbol.getTypeInfo().getDefault().equals( pSymbol.getTypeInfo().getDefault() ) )
+ {
+ return false;
+ }
+ }
+ //value
+ map.put( pSymbol.getName(), aSymbol.getTypeInfo() );
+ return true;
+ }
+ }
+
+ return false;
+ }
+ /**
+ * transform the class template to a function template as described in the spec
+ * 14.5.4.2-1
+ * @param template
+ * @return IParameterizedSymbol
+ * the function template has the same template parameters as the partial specialization and
+ * has a single function parameter whose type is a class template specialization with the template
+ * arguments of the partial specialization
+ */
+ static private IParameterizedSymbol classTemplateSpecializationToFunctionTemplate( IParameterizedSymbol template ){
+ IParameterizedSymbol transformed = (IParameterizedSymbol) template.clone();
+ transformed.setArgumentList( null );
+ transformed.getContainedSymbols().clear();
+
+ IParameterizedSymbol function = template.getSymbolTable().newParameterizedSymbol( transformed.getName(), TypeInfo.t_function );
+ try{
+ transformed.addSymbol( function );
+ } catch ( ParserSymbolTableException e ){
+ //we shouldn't get this because there aren't any other symbols in the template
+ }
+
+ function.addParameter( template );
+
+ return transformed;
+ }
+
+ /**
+ * transform a function template for use in partial ordering, as described in the
+ * spec 14.5.5.2-3
+ * @param template
+ * @return
+ * -for each type template parameter, synthesize a unique type and substitute that for each
+ * occurence of that parameter in the function parameter list
+ * -for each non-type template parameter, synthesize a unique value of the appropriate type and
+ * susbstitute that for each occurence of that parameter in the function parameter list
+ * for each template template parameter, synthesize a unique class template and substitute that
+ * for each occurence of that parameter in the function parameter list
+ */
+ static private TemplateInstance transformFunctionTemplateForOrdering( IParameterizedSymbol template ){
+
+ LinkedList paramList = template.getParameterList();
+
+ int size = ( paramList != null ) ? paramList.size() : 0;
+ if( size == 0 ){
+ return null;
+ }
+
+ HashMap map = new HashMap();
+ for( Iterator iterator = paramList.iterator(); iterator.hasNext(); ) {
+ ISymbol param = (ISymbol) iterator.next();
+ ISymbol val = template.getSymbolTable().newSymbol( "", TypeInfo.t_type );
+ if( false /* is value */ ){
+ //val.getTypeInfo().setHasDefault()
+ }
+ map.put( param, val );
+ }
+
+ return template.getSymbolTable().new TemplateInstance( template, map );
+ }
+
+ //private Stack _contextStack = new Stack();
+ private Declaration _compilationUnit;
+ private LinkedList undoList = new LinkedList();
+ private HashSet markSet = new HashSet();
+
+ private void pushCommand( Command command ){
+ undoList.addFirst( command );
+ }
+
+ public Mark setMark(){
+ Mark mark = new Mark();
+ undoList.addFirst( mark );
+ markSet.add( mark );
+ return mark;
+ }
+
+ public boolean rollBack( Mark toMark ){
+ if( markSet.contains( toMark ) ){
+ markSet.remove( toMark );
+ Command command = ( Command )undoList.removeFirst();
+ while( command != toMark ){
+ command.undoIt();
+ command = ( Command ) undoList.removeFirst();
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean commit( Mark toMark ){
+ if( markSet.contains( toMark ) ){
+ markSet.remove( toMark );
+ Command command = ( Command )undoList.removeLast();
+ while( command != toMark ){
+ command = (Command) undoList.removeLast();
+ }
+ return true;
+ }
+
+ return false;
+ }
+
+ static abstract private class Command{
+ abstract public void undoIt();
+ }
+
+ static public class Mark extends Command{
+ public void undoIt(){ };
+ }
+
+ static private class AddDeclarationCommand extends Command{
+ AddDeclarationCommand( BasicSymbol newDecl, Declaration context, boolean removeThis ){
+ _decl = newDecl;
+ _context = context;
+ _removeThis = removeThis;
+ }
+ public void undoIt(){
+ Object obj = _context.getContainedSymbols().get( _decl.getName() );
+
+ if( obj instanceof LinkedList ){
+ LinkedList list = (LinkedList)obj;
+ ListIterator iter = list.listIterator();
+ int size = list.size();
+ Declaration item = null;
+ for( int i = 0; i < size; i++ ){
+ item = (Declaration)iter.next();
+ if( item == _decl ){
+ iter.remove();
+ break;
+ }
+ }
+ if( list.size() == 1 ){
+ _context.getContainedSymbols().remove( _decl.getName() );
+ _context.getContainedSymbols().put( _decl.getName(), list.getFirst() );
+ }
+ } else if( obj instanceof BasicSymbol ){
+ _context.getContainedSymbols().remove( _decl.getName() );
+ }
+ if( _removeThis ){
+ _context.getContainedSymbols().remove( "this" );
+ }
+ }
+
+ private BasicSymbol _decl;
+ private Declaration _context;
+ private boolean _removeThis;
+ }
+
+ static private class AddParentCommand extends Command{
+ public AddParentCommand( Declaration container, Declaration.ParentWrapper wrapper ){
+ _decl = container;
+ _wrapper = wrapper;
+ }
+
+ public void undoIt(){
+ List parents = _decl.getParents();
+ parents.remove( _wrapper );
+ }
+
+ private Declaration _decl;
+ private Declaration.ParentWrapper _wrapper;
+ }
+
+ static private class AddParameterCommand extends Command{
+ public AddParameterCommand( Declaration container, BasicSymbol parameter ){
+ _decl = container;
+ _param = parameter;
+ }
+
+ public void undoIt(){
+ _decl.getParameterList().remove( _param );
+
+ String name = _param.getName();
+ if( name != null && !name.equals("") )
+ {
+ _decl.getParameterMap().remove( name );
+ }
+ }
+
+ private Declaration _decl;
+ private BasicSymbol _param;
+ }
+
+ static private class AddArgumentCommand extends Command{
+ public AddArgumentCommand( Declaration container, BasicSymbol arg ){
+ _decl = container;
+ _arg = arg;
+ }
+ public void undoIt(){
+ _decl.getArgumentList().remove( _arg );
+ }
+
+ private Declaration _decl;
+ private BasicSymbol _arg;
+ }
+
+ static private class AddUsingDirectiveCommand extends Command{
+ public AddUsingDirectiveCommand( Declaration container, Declaration namespace ){
+ _decl = container;
+ _namespace = namespace;
+ }
+ public void undoIt(){
+ _decl.getUsingDirectives().remove( _namespace );
+ }
+ private Declaration _decl;
+ private Declaration _namespace;
+ }
+
+ static private class LookupData
+ {
+
+ public String name;
+ public Map usingDirectives;
+ public Set visited = new HashSet(); //used to ensure we don't visit things more than once
+
+ public HashSet inheritanceChain; //used to detect circular inheritance
+
+ public LinkedList parameters; //parameter info for resolving functions
+ public HashSet associated; //associated namespaces for argument dependant lookup
+ public ISymbol stopAt; //stop looking along the stack once we hit this declaration
+
+ public TypeInfo.eType type = TypeInfo.t_any;
+ public TypeInfo.eType upperType = TypeInfo.t_undef;
+ public boolean qualified = false;
+ public boolean ignoreUsingDirectives = false;
+
+ public HashSet foundItems = null;
+
+ public ISymbol templateInstance = null;
+
+ public LookupData( String n, TypeInfo.eType t, ISymbol i ){
+ name = n;
+ type = t;
+ templateInstance = i;
+ }
+ }
+
+ static private class Cost
+ {
+ public Cost( TypeInfo s, TypeInfo t ){
+ source = s;
+ target = t;
+ }
+
+ public TypeInfo source;
+ public TypeInfo target;
+
+ public int lvalue;
+ public int promotion;
+ public int conversion;
+ public int qualification;
+ public int userDefined;
+ public int rank = -1;
+ public int detail;
+
+ public int compare( Cost cost ){
+ int result = 0;
+
+ if( rank != cost.rank ){
+ return cost.rank - rank;
+ }
+
+ if( userDefined != 0 || cost.userDefined != 0 ){
+ if( userDefined == 0 || cost.userDefined == 0 ){
+ return cost.userDefined - userDefined;
+ } else {
+ if( (userDefined == 1 || cost.userDefined == 1) ||
+ (userDefined != cost.userDefined ) )
+ {
+ return 0;
+ }
+ // else they are the same constructor/conversion operator and are ranked
+ //on the standard conversion sequence
+ }
+ }
+
+ if( promotion > 0 || cost.promotion > 0 ){
+ result = cost.promotion - promotion;
+ }
+ if( conversion > 0 || cost.conversion > 0 ){
+ if( detail == cost.detail ){
+ result = cost.conversion - conversion;
+ } else {
+ result = cost.detail - detail;
+ }
+ }
+
+ if( result == 0 ){
+ if( cost.qualification != qualification ){
+ return cost.qualification - qualification;
+ } else if( (cost.qualification == qualification) && qualification == 0 ){
+ return 0;
+ } else {
+ int size = cost.target.hasPtrOperators() ? cost.target.getPtrOperators().size() : 0;
+ int size2 = target.hasPtrOperators() ? target.getPtrOperators().size() : 0;
+
+ ListIterator iter1 = cost.target.getPtrOperators().listIterator( size );
+ ListIterator iter2 = target.getPtrOperators().listIterator( size2 );
+
+ TypeInfo.PtrOp op1 = null, op2 = null;
+
+ int subOrSuper = 0;
+ for( int i = ( size < size2 ) ? size : size2; i > 0; i-- ){
+ op1 = (TypeInfo.PtrOp)iter1.previous();
+ op2 = (TypeInfo.PtrOp)iter2.previous();
+
+ if( subOrSuper == 0)
+ subOrSuper = op1.compareCVTo( op2 );
+ else if( ( subOrSuper > 0 && ( op1.compareCVTo( op2 ) < 0 )) ||
+ ( subOrSuper < 0 && ( op1.compareCVTo( op2 ) > 0 )) )
+ {
+ result = -1;
+ break;
+ }
+ }
+ if( result == -1 ){
+ result = 0;
+ } else {
+ if( size == size2 ){
+ result = subOrSuper;
+ } else {
+ result = size - size2;
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+ }
+
+ public class BasicSymbol implements Cloneable, ISymbol
+ {
+ public BasicSymbol( String name ){
+ super();
+ _name = name;
+ _typeInfo = new TypeInfo();
+ }
+
+ public BasicSymbol( String name, IPSTSymbolExtension obj ){
+ super();
+ _name = name;
+ _object = obj;
+ _typeInfo = new TypeInfo();
+ }
+
+ public BasicSymbol( String name, TypeInfo.eType typeInfo )
+ {
+ super();
+ _name = name;
+ _typeInfo = new TypeInfo( typeInfo, 0, this );
+ }
+
+ public ParserSymbolTable getSymbolTable(){
+ return ParserSymbolTable.this;
+ }
+
+ public Object clone(){
+ BasicSymbol copy = null;
+ try{
+ copy = (BasicSymbol)super.clone();
+ } catch ( CloneNotSupportedException e ){
+ //should not happen
+ return null;
+ }
+ copy._object = null;
+ return copy;
+ }
+
+ public String getName() { return _name; }
+ public void setName(String name) { _name = name; }
+
+ public IPSTSymbolExtension getASTNode() { return _object; }
+ public void setASTNode( IPSTSymbolExtension obj ) { _object = obj; }
+
+ public IContainerSymbol getContainingSymbol() { return _containingScope; }
+ public void setContainingSymbol( IContainerSymbol scope ){
+ _containingScope = ( Declaration )scope;
+ _depth = scope.getDepth() + 1;
+ }
+
+ public void setType(TypeInfo.eType t){
+ _typeInfo.setType( t );
+ }
+
+ public TypeInfo.eType getType(){
+ return _typeInfo.getType();
+ }
+
+ public boolean isType( TypeInfo.eType type ){
+ return _typeInfo.isType( type, TypeInfo.t_undef );
+ }
+
+ public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ){
+ return _typeInfo.isType( type, upperType );
+ }
+
+ public ISymbol getTypeSymbol(){
+ return _typeInfo.getTypeSymbol();
+ }
+
+ public void setTypeSymbol( ISymbol type ){
+ _typeInfo.setTypeSymbol( type );
+ }
+
+ public TypeInfo getTypeInfo(){
+ return _typeInfo;
+ }
+
+ public void setTypeInfo( TypeInfo info ) {
+ _typeInfo = info;
+ }
+
+ /**
+ * returns 0 if same, non zero otherwise
+ */
+ public int compareCVQualifiersTo( ISymbol symbol ){
+ int size = symbol.getTypeInfo().hasPtrOperators() ? symbol.getTypeInfo().getPtrOperators().size() : 0;
+ int size2 = getTypeInfo().hasPtrOperators() ? getTypeInfo().getPtrOperators().size() : 0;
+
+ if( size != size2 ){
+ return size2 - size;
+ } else {
+ Iterator iter1 = symbol.getTypeInfo().getPtrOperators().iterator();
+ Iterator iter2 = getTypeInfo().getPtrOperators().iterator();
+
+ TypeInfo.PtrOp op1 = null, op2 = null;
+
+ int subOrSuper = 0;
+ for( int i = size; i > 0; i-- ){
+ op1 = (TypeInfo.PtrOp)iter1.next();
+ op2 = (TypeInfo.PtrOp)iter2.next();
+
+ if( op1.compareCVTo( op2 ) != 0 ){
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+ }
+
+ public LinkedList getPtrOperators(){
+ return _typeInfo.getPtrOperators();
+ }
+ public void addPtrOperator( TypeInfo.PtrOp ptrOp ){
+ _typeInfo.addPtrOperator( ptrOp );
+ }
+
+ public int getDepth(){
+ return _depth;
+ }
+
+ public boolean isTemplateMember(){
+ return _isTemplateMember;
+ }
+ public void setIsTemplateMember( boolean isMember ){
+ _isTemplateMember = isMember;
+ }
+ public ISymbol getTemplateInstance(){
+ return _templateInstance;
+ }
+ public void setTemplateInstance( TemplateInstance instance ){
+ _templateInstance = instance;
+ }
+ public HashMap getArgumentMap(){
+ return null;
+ }
+ private String _name; //our name
+ private IPSTSymbolExtension _object; //the object associated with us
+ private TypeInfo _typeInfo; //our type info
+ private Declaration _containingScope; //the scope that contains us
+ private int _depth; //how far down the scope stack we are
+
+ private boolean _isTemplateMember = false;
+ private TemplateInstance _templateInstance;
+ }
+
+ public class TemplateInstance extends BasicSymbol
+ {
+ protected TemplateInstance( ISymbol symbol, HashMap argMap ){
+ super("");
+ _instantiatedSymbol = symbol;
+ symbol.setTemplateInstance( this );
+ _argumentMap = argMap;
+ }
+
+ public boolean equals( Object t ){
+ if( t == null || !( t instanceof TemplateInstance ) ){
+ return false;
+ }
+
+ TemplateInstance instance = (TemplateInstance) t;
+
+ if( _instantiatedSymbol != instance._instantiatedSymbol ){
+ return false;
+ }
+
+ //check arg map
+ Iterator iter1 = _argumentMap.keySet().iterator();
+ Iterator iter2 = instance._argumentMap.keySet().iterator();
+ int size = _argumentMap.size();
+ int size2 = instance._argumentMap.size();
+ ISymbol t1 = null, t2 = null;
+ if( size == size2 ){
+ for( int i = size; i > 0; i-- ){
+ t1 = (ISymbol)iter1.next();
+ t2 = (ISymbol)iter2.next();
+ if( t1 != t2 || !_argumentMap.get(t1).equals( instance._argumentMap.get(t2) ) ){
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+ public ISymbol getInstantiatedSymbol(){
+ _instantiatedSymbol.setTemplateInstance( this );
+ return _instantiatedSymbol;
+ }
+
+ public TypeInfo.eType getType(){
+ ISymbol symbol = _instantiatedSymbol;
+ TypeInfo.eType returnType = _instantiatedSymbol.getType();
+ if( returnType == TypeInfo.t_type ){
+ symbol = symbol.getTypeSymbol();
+ TypeInfo info = null;
+ while( symbol != null && symbol.getType() == TypeInfo.t_undef && symbol.getContainingSymbol().getType() == TypeInfo.t_template ){
+ info = (TypeInfo) _argumentMap.get( symbol );
+ if( !info.isType( TypeInfo.t_type ) ){
+ break;
+ }
+ symbol = info.getTypeSymbol();
+ }
+
+ return ( info != null ) ? info.getType() : TypeInfo.t_type;
+ }
+
+ return returnType;
+ }
+
+ public boolean isType( TypeInfo.eType type ){
+ return ( type == TypeInfo.t_any || getType() == type );
+ }
+
+ public boolean isType( TypeInfo.eType type, TypeInfo.eType upperType ){
+ if( type == TypeInfo.t_any )
+ return true;
+
+ if( upperType == TypeInfo.t_undef ){
+ return ( getType() == type );
+ } else {
+ return ( getType().compareTo( type ) >= 0 && getType().compareTo( upperType ) <= 0 );
+ }
+ }
+
+ public ISymbol getTypeSymbol(){
+ ISymbol symbol = _instantiatedSymbol.getTypeSymbol();
+ if( symbol != null && symbol.getType() == TypeInfo.t_undef &&
+ symbol.getContainingSymbol().getType() == TypeInfo.t_template )
+ {
+ TypeInfo info = (TypeInfo) _argumentMap.get( symbol );
+ return ( info != null ) ? info.getTypeSymbol() : null;
+ }
+
+ return symbol;
+ }
+
+ public TypeInfo getTypeInfo(){
+ ISymbol symbol = _instantiatedSymbol.getTypeSymbol();
+ if( symbol != null && symbol.getType() == TypeInfo.t_undef &&
+ symbol.getContainingSymbol().getType() == TypeInfo.t_template )
+ {
+ TypeInfo info = (TypeInfo) _argumentMap.get( symbol );
+ return info;
+ }
+
+ return _instantiatedSymbol.getTypeInfo();
+ }
+
+ public HashMap getArgumentMap(){
+ return _argumentMap;
+ }
+
+
+ private ISymbol _instantiatedSymbol;
+ //private LinkedList _arguments;
+ private HashMap _argumentMap;
+ private Object _callbackExtension;
+
+ }
+
+ public class Declaration extends BasicSymbol implements Cloneable,
+ IContainerSymbol,
+ IDerivableContainerSymbol,
+ IParameterizedSymbol,
+ ISpecializedSymbol
+ {
+
+ public Declaration( String name ){
+ super( name );
+ }
+
+ public Declaration( String name, IPSTSymbolExtension obj ){
+ super( name, obj );
+ }
+
+ public Declaration( String name, TypeInfo.eType typeInfo )
+ {
+ super( name, typeInfo );
+ }
+
+ /**
+ * clone
+ * @see java.lang.Object#clone()
+ *
+ * implement clone for the purposes of using declarations.
+ * int _typeInfo; //by assignment
+ * String _name; //by assignment
+ * Object _object; //null this out
+ * Declaration _typeDeclaration; //by assignment
+ * Declaration _containingScope; //by assignment
+ * LinkedList _parentScopes; //shallow copy
+ * LinkedList _usingDirectives; //shallow copy
+ * HashMap _containedDeclarations; //shallow copy
+ * int _depth; //by assignment
+ */
+ public Object clone(){
+ Declaration copy = (Declaration)super.clone();
+
+ copy._parentScopes = ( _parentScopes != null ) ? (LinkedList) _parentScopes.clone() : null;
+ copy._usingDirectives = ( _usingDirectives != null ) ? (LinkedList) _usingDirectives.clone() : null;
+ copy._containedDeclarations = ( _containedDeclarations != null ) ? (HashMap) _containedDeclarations.clone() : null;
+ copy._parameterList = ( _parameterList != null ) ? (LinkedList) _parameterList.clone() : null;
+ copy._parameterHash = ( _parameterHash != null ) ? (HashMap) _parameterHash.clone() : null;
+
+ return copy;
+ }
+
+ public void addParent( ISymbol parent ){
+ addParent( parent, false, AccessVisibility.v_public );
+ }
+ public void addParent( ISymbol parent, boolean virtual, AccessVisibility visibility ){
+ if( _parentScopes == null ){
+ _parentScopes = new LinkedList();
+ }
+
+ ParentWrapper wrapper = new ParentWrapper( parent, virtual, visibility );
+ _parentScopes.add( wrapper );
+
+ Command command = new AddParentCommand( this, wrapper );
+ pushCommand( command );
+ }
+
+ public void addParent( IDerivableContainerSymbol.IParentSymbol wrapper ){
+ if( _parentScopes == null ){
+ _parentScopes = new LinkedList();
+ }
+
+ //ParentWrapper wrapper = new ParentWrapper( parent, virtual );
+ _parentScopes.add( wrapper );
+
+ Command command = new AddParentCommand( this, (ParentWrapper) wrapper );
+ pushCommand( command );
+ }
+
+ public Map getContainedSymbols(){
+ return _containedDeclarations;
+ }
+
+ public Map createContained(){
+ if( _containedDeclarations == null )
+ _containedDeclarations = new HashMap();
+
+ return _containedDeclarations;
+ }
+
+ public boolean hasParents(){
+ return ( _parentScopes != null && !_parentScopes.isEmpty() );
+ }
+
+ public List getParents(){
+ return _parentScopes;
+ }
+
+ public boolean needsDefinition(){
+ return _needsDefinition;
+ }
+ public void setNeedsDefinition( boolean need ) {
+ _needsDefinition = need;
+ }
+
+
+
+ //public void addPtrOperator( String ptrStr, boolean isConst, boolean isVolatile ){
+ // _typeInfo.addPtrOperator( ptrStr, isConst, isVolatile );
+ //}
+
+ public ISymbol getReturnType(){
+ return _returnType;
+ }
+
+ public void setReturnType( ISymbol type ){
+ _returnType = type;
+ }
+
+ public LinkedList getParameterList(){
+ return _parameterList;
+ }
+
+ public void setParameterList( LinkedList list ){
+ _parameterList = list;
+ }
+
+ public HashMap getParameterMap(){
+ return _parameterHash;
+ }
+
+ public LinkedList getArgumentList(){
+ return _argumentList;
+ }
+ public void setArgumentList( LinkedList list ){
+ _argumentList = list;
+ }
+ public void addArgument( ISymbol arg ){
+ if( _argumentList == null ){
+ _argumentList = new LinkedList();
+ }
+ _argumentList.addLast( arg );
+
+ arg.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
+
+ Command command = new AddArgumentCommand( this, (BasicSymbol) arg );
+ pushCommand( command );
+ }
+
+ public void addParameter( ISymbol param ){
+ if( _parameterList == null )
+ _parameterList = new LinkedList();
+
+ _parameterList.addLast( param );
+ String name = param.getName();
+ if( name != null && !name.equals("") )
+ {
+ if( _parameterHash == null )
+ _parameterHash = new HashMap();
+
+ if( !_parameterHash.containsKey( name ) )
+ _parameterHash.put( name, param );
+ }
+ param.setContainingSymbol( this );
+ param.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
+
+ Command command = new AddParameterCommand( this, (BasicSymbol)param );
+ pushCommand( command );
+ }
+
+ public void addParameter( ISymbol typeSymbol, TypeInfo.PtrOp ptrOp, boolean hasDefault ){
+ BasicSymbol param = new BasicSymbol("");
+
+ TypeInfo info = param.getTypeInfo();
+ info.setType( TypeInfo.t_type );
+ info.setTypeSymbol( typeSymbol );
+ info.addPtrOperator( ptrOp );
+ info.setHasDefault( hasDefault );
+
+ addParameter( param );
+ }
+
+ public void addParameter( TypeInfo.eType type, int info, TypeInfo.PtrOp ptrOp, boolean hasDefault ){
+ BasicSymbol param = new BasicSymbol("");
+
+ TypeInfo t = param.getTypeInfo();
+ t.setTypeInfo( info );
+ t.setType( type );
+ t.addPtrOperator( ptrOp );
+ t.setHasDefault( hasDefault );
+
+ addParameter( param );
+ }
+
+ public boolean hasSameParameters( IParameterizedSymbol function ){
+ if( function.getType() != getType() ){
+ return false;
+ }
+
+ int size = getParameterList().size();
+ if( function.getParameterList().size() != size ){
+ return false;
+ }
+
+ Iterator iter = getParameterList().iterator();
+ Iterator fIter = function.getParameterList().iterator();
+
+ TypeInfo info = null;
+ TypeInfo fInfo = null;
+
+ for( int i = size; i > 0; i-- ){
+ info = ((BasicSymbol)iter.next()).getTypeInfo();
+ fInfo = ((BasicSymbol) fIter.next()).getTypeInfo();
+
+ if( !info.equals( fInfo ) ){
+ return false;
+ }
+ }
+
+
+ return true;
+ }
+
+ public void addSymbol( ISymbol obj ) throws ParserSymbolTableException{
+ Declaration containing = this;
+
+ //handle enumerators
+ if( obj.getType() == TypeInfo.t_enumerator ){
+ //a using declaration of an enumerator will not be contained in a
+ //enumeration.
+ if( containing.getType() == TypeInfo.t_enumeration ){
+ //Following the closing brace of an enum-specifier, each enumerator has the type of its
+ //enumeration
+ obj.setTypeSymbol( containing );
+ //Each enumerator is declared in the scope that immediately contains the enum-specifier
+ containing = (Declaration) containing.getContainingSymbol();
+ }
+ }
+
+ //Templates contain 1 declaration
+ if( getType() == TypeInfo.t_template ){
+ //declaration must be a class or a function
+ if( ( obj.getType() != TypeInfo.t_class && obj.getType() != TypeInfo.t_function ) ||
+ ( getContainedSymbols() != null && getContainedSymbols().size() == 1 ) )
+ {
+ //throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
+ }
+ }
+
+ Map declarations = containing.getContainedSymbols();
+
+ boolean unnamed = obj.getName().equals( "" );
+
+ Object origObj = null;
+
+ obj.setContainingSymbol( containing );
+
+ if( declarations == null ){
+ declarations = containing.createContained();
+ } else {
+ //does this name exist already?
+ origObj = declarations.get( obj.getName() );
+ }
+
+ if( origObj != null )
+ {
+ Declaration origDecl = null;
+ LinkedList origList = null;
+
+ if( origObj.getClass() == Declaration.class ){
+ origDecl = (Declaration)origObj;
+ } else if( origObj.getClass() == LinkedList.class ){
+ origList = (LinkedList)origObj;
+ } else {
+ throw new ParserSymbolTableException();
+ }
+
+ if( unnamed || ((origList == null) ? isValidOverload( origDecl, obj ) : isValidOverload( origList, obj ) )){
+ if( origList == null ){
+ origList = new LinkedList();
+ origList.add( origDecl );
+ origList.add( obj );
+
+ declarations.remove( obj );
+ declarations.put( obj.getName(), origList );
+ } else {
+ origList.add( obj );
+ //origList is already in _containedDeclarations
+ }
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_InvalidOverload );
+ }
+ } else {
+ declarations.put( obj.getName(), obj );
+ }
+
+ obj.setIsTemplateMember( isTemplateMember() || getType() == TypeInfo.t_template );
+
+ //take care of the this pointer
+ TypeInfo type = obj.getTypeInfo();
+ boolean addedThis = false;
+ if( type.isType( TypeInfo.t_function ) && !type.checkBit( TypeInfo.isStatic ) ){
+ addThis( (Declaration) obj );
+ addedThis = true;
+ }
+
+ Command command = new AddDeclarationCommand( (BasicSymbol) obj, containing, addedThis );
+ pushCommand( command );
+ }
+
+ /**
+ *
+ * @param obj
+ * @throws ParserSymbolTableException
+ * 9.3.2-1 In the body of a nonstatic member function... the type of this of
+ * a class X is X*. If the member function is declared const, the type of
+ * this is const X*, if the member function is declared volatile, the type
+ * of this is volatile X*....
+ */
+ private void addThis( Declaration obj ){
+ TypeInfo type = obj.getTypeInfo();
+ if( !type.isType( TypeInfo.t_function ) || type.checkBit( TypeInfo.isStatic ) ){
+ return;
+ }
+
+ if( obj.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) ){
+ //check to see if there is already a this object, since using declarations
+ //of function will have them from the original declaration
+ LookupData data = new LookupData( "this", TypeInfo.t_any, null );
+ LookupInContained( data, obj );
+ //if we didn't find "this" then foundItems will still be null, no need to actually
+ //check its contents
+ if( data.foundItems == null ){
+ Declaration thisObj = new Declaration("this");
+ thisObj.setType( TypeInfo.t_type );
+ thisObj.setTypeSymbol( obj.getContainingSymbol() );
+ //thisObj.setCVQualifier( obj.getCVQualifier() );
+ TypeInfo.PtrOp ptr = new TypeInfo.PtrOp();
+ ptr.setType( TypeInfo.PtrOp.t_pointer );
+ if( obj.getTypeInfo().hasPtrOperators() ){
+ ptr.setConst( ((TypeInfo.PtrOp) obj.getPtrOperators().getFirst()).isConst() );
+ ptr.setVolatile( ((TypeInfo.PtrOp) obj.getPtrOperators().getFirst()).isVolatile() );
+ }
+
+ thisObj.addPtrOperator(ptr);
+
+ try{
+ obj.addSymbol( thisObj );
+ } catch ( ParserSymbolTableException e ) {
+ //won't happen because we checked that "this" didn't exist already
+ }
+
+ }
+ }
+ }
+
+ /**
+ *
+ * @param name
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ *
+ * 7.3.1.2-3 If a friend declaration in a non-local class first declares a
+ * class or function, the friend class or function is a member of the
+ * innermost enclosing namespace.
+ *
+ * TODO: if/when the parser symbol table starts caring about visibility
+ * (public/protected/private) we will need to do more to record friendship.
+ */
+ public Declaration addFriend( String name ) throws ParserSymbolTableException{
+ Declaration friend = LookupForFriendship( name );
+
+ if( friend == null ){
+ friend = new Declaration( name );
+ friend.setNeedsDefinition( true );
+
+ Declaration containing = (Declaration)getContainingSymbol();
+ //find innermost enclosing namespace
+ while( containing != null && containing.getType() != TypeInfo.t_namespace ){
+ containing = (Declaration)containing.getContainingSymbol();
+ }
+
+ Declaration namespace = ( containing == null ) ? (Declaration)ParserSymbolTable.this.getCompilationUnit() : containing;
+ namespace.addSymbol( friend );
+ }
+
+ return friend;
+ }
+
+ /**
+ * LookupForFriendship
+ * @param name
+ * @return Declaration
+ * 7.3.1.2-3 When looking for a prior declaration of a class or a function
+ * declared as a friend, scopes outside the innermost enclosing namespace
+ * scope are not considered.
+ * 11.4-9 If a friend declaration appears in a local class and the name
+ * specified is an unqualified name, a prior declaration is looked up
+ * without considering scopes that are outside the innermost enclosing non-
+ * class scope.
+ */
+ private Declaration LookupForFriendship( String name ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
+
+ boolean inClass = ( getType() == TypeInfo.t_class);
+
+ Declaration enclosing = (Declaration) getContainingSymbol();
+ while( enclosing != null && (inClass ? enclosing.getType() != TypeInfo.t_class
+ : enclosing.getType() == TypeInfo.t_namespace) )
+ {
+ enclosing = (Declaration) enclosing.getContainingSymbol();
+ }
+
+ data.stopAt = enclosing;
+
+ ParserSymbolTable.Lookup( data, this );
+ return (Declaration)ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ /**
+ * addUsingDeclaration
+ * @param obj
+ * @throws ParserSymbolTableException
+ *
+ * 7.3.3-9 The entity declared by a using-declaration shall be known in the
+ * context using it according to its definition at the point of the using-
+ * declaration. Definitions added to the namespace after the using-
+ * declaration are not considered when a use of the name is made.
+ *
+ * 7.3.3-4 A using-declaration used as a member-declaration shall refer to a
+ * member of a base class of the class being defined, shall refer to a
+ * member of an anonymous union that is a member of a base class of the
+ * class being defined, or shall refer to an enumerator for an enumeration
+ * type that is a member of a base class of the class being defined.
+ */
+ public ISymbol addUsingDeclaration( String name ) throws ParserSymbolTableException {
+ return addUsingDeclaration( name, null );
+ }
+
+ public ISymbol addUsingDeclaration( String name, IContainerSymbol declContext ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, TypeInfo.t_any, null );
+
+ if( declContext != null ){
+ data.qualified = true;
+ data.templateInstance = declContext.getTemplateInstance();
+ ParserSymbolTable.Lookup( data, declContext );
+ } else {
+ ParserSymbolTable.Lookup( data, this );
+ }
+
+ //figure out which declaration we are talking about, if it is a set of functions,
+ //then they will be in data.foundItems (since we provided no parameter info);
+ BasicSymbol obj = (BasicSymbol)ParserSymbolTable.ResolveAmbiguities( data );
+
+ if( data.foundItems == null ){
+ throw new ParserSymbolTableException();
+ }
+
+ BasicSymbol clone = null;
+
+ //if obj != null, then that is the only object to consider, so size is 1,
+ //otherwise we consider the foundItems set
+ int size = ( obj == null ) ? data.foundItems.size() : 1;
+ Iterator iter = data.foundItems.iterator();
+ for( int i = size; i > 0; i-- ){
+ obj = ( obj != null && size == 1 ) ? obj : (Declaration) iter.next();
+
+ if( ParserSymbolTable.okToAddUsingDeclaration( obj, this ) ){
+ clone = (BasicSymbol) obj.clone(); //7.3.3-9
+ addSymbol( clone );
+ } else {
+ throw new ParserSymbolTableException();
+ }
+ }
+
+ return ( size == 1 ) ? clone : null;
+ }
+
+ public void addUsingDirective( IContainerSymbol namespace ) throws ParserSymbolTableException{
+ if( namespace.getType() != TypeInfo.t_namespace ){
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTypeInfo );
+ }
+
+ if( _usingDirectives == null ){
+ _usingDirectives = new LinkedList();
+ }
+
+ _usingDirectives.add( namespace );
+
+ Command command = new AddUsingDirectiveCommand( this, (Declaration)namespace );
+ pushCommand( command );
+ }
+
+ public boolean hasUsingDirectives(){
+ return ( _usingDirectives != null && !_usingDirectives.isEmpty() );
+ }
+
+ public List getUsingDirectives(){
+ return _usingDirectives;
+ }
+
+ public ISymbol ElaboratedLookup( TypeInfo.eType type, String name ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, type, getTemplateInstance() );
+
+ ParserSymbolTable.Lookup( data, this );
+
+ return ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ public ISymbol Lookup( String name ) throws ParserSymbolTableException {
+ LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
+
+ ParserSymbolTable.Lookup( data, this );
+
+ return ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ /**
+ * LookupMemberForDefinition
+ * @param name
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ *
+ * In a definition for a namespace member in which the declarator-id is a
+ * qualified-id, given that the qualified-id for the namespace member has
+ * the form "nested-name-specifier unqualified-id", the unqualified-id shall
+ * name a member of the namespace designated by the nested-name-specifier.
+ *
+ * ie:
+ * you have this:
+ * namespace A{
+ * namespace B{
+ * void f1(int);
+ * }
+ * using namespace B;
+ * }
+ *
+ * if you then do this
+ * void A::f1(int) { ... } //ill-formed, f1 is not a member of A
+ * but, you can do this (Assuming f1 has been defined elsewhere)
+ * A::f1( 1 ); //ok, finds B::f1
+ *
+ * ie, We need a seperate lookup function for looking up the member names
+ * for a definition.
+ */
+ public ISymbol LookupMemberForDefinition( String name ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
+ data.qualified = true;
+
+ ParserSymbolTable.LookupInContained( data, this );
+
+ return ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ /**
+ * Method LookupNestedNameSpecifier.
+ * @param name
+ * @return Declaration
+ * The name of a class or namespace member can be referred to after the ::
+ * scope resolution operator applied to a nested-name-specifier that
+ * nominates its class or namespace. During the lookup for a name preceding
+ * the ::, object, function and enumerator names are ignored. If the name
+ * is not a class-name or namespace-name, the program is ill-formed
+ */
+ public IContainerSymbol LookupNestedNameSpecifier( String name ) throws ParserSymbolTableException {
+ return LookupNestedNameSpecifier( name, this );
+ }
+ private Declaration LookupNestedNameSpecifier(String name, Declaration inDeclaration ) throws ParserSymbolTableException{
+ Declaration foundDeclaration = null;
+
+ LookupData data = new LookupData( name, TypeInfo.t_namespace, getTemplateInstance() );
+ data.upperType = TypeInfo.t_union;
+
+ ParserSymbolTable.LookupInContained( data, inDeclaration );
+
+ if( data.foundItems != null ){
+ foundDeclaration = (Declaration) ParserSymbolTable.ResolveAmbiguities( data );//, data.foundItems );
+ }
+
+ if( foundDeclaration == null && inDeclaration.getContainingSymbol() != null ){
+ foundDeclaration = LookupNestedNameSpecifier( name, (Declaration)inDeclaration.getContainingSymbol() );
+ }
+
+ return foundDeclaration;
+ }
+
+ /**
+ * MemberFunctionLookup
+ * @param name
+ * @param parameters
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ *
+ * Member lookup really proceeds as an unqualified lookup, but doesn't
+ * include argument dependant scopes
+ */
+ public IParameterizedSymbol MemberFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, TypeInfo.t_function, getTemplateInstance() );
+ //if parameters == null, thats no parameters, but we need to distinguish that from
+ //no parameter information at all, so make an empty list.
+ data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
+
+ ParserSymbolTable.Lookup( data, (IContainerSymbol) this );
+ return (IParameterizedSymbol) ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ public IParameterizedSymbol QualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, TypeInfo.t_function, getTemplateInstance() );
+ data.qualified = true;
+ //if parameters == null, thats no parameters, but we need to distinguish that from
+ //no parameter information at all, so make an empty list.
+ data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
+
+ ParserSymbolTable.Lookup( data, (IContainerSymbol)this );
+
+ return (IParameterizedSymbol) ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ public ISymbol QualifiedLookup( String name ) throws ParserSymbolTableException{
+ LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
+ data.qualified = true;
+ ParserSymbolTable.Lookup( data, this );
+
+ return ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ public TemplateInstance TemplateLookup( String name, LinkedList arguments ) throws ParserSymbolTableException
+ {
+ LookupData data = new LookupData( name, TypeInfo.t_any, getTemplateInstance() );
+ data.parameters = arguments;
+
+ ParserSymbolTable.Lookup( data, (IContainerSymbol) this );
+ ISymbol found = ParserSymbolTable.ResolveAmbiguities( data );
+ if( found.isType( TypeInfo.t_template ) ){
+ return ((IParameterizedSymbol) found).instantiate( arguments );
+ }
+ return null;
+ }
+
+ /**
+ * UnqualifiedFunctionLookup
+ * @param name
+ * @param parameters
+ * @return Declaration
+ * @throws ParserSymbolTableException
+ *
+ * 3.4.2-1 When an unqualified name is used as the post-fix expression in a
+ * function call, other namespaces not consdiered during the usual
+ * unqualified lookup may be searched.
+ *
+ * 3.4.2-2 For each argument type T in the function call, there is a set of
+ * zero or more associated namespaces and a set of zero or more associated
+ * classes to be considered.
+ *
+ * If the ordinary unqualified lookup of the name find the declaration of a
+ * class member function, the associated namespaces and classes are not
+ * considered. Otherwise, the set of declarations found by the lookup of
+ * the function name is the union of the set of declarations found using
+ * ordinary unqualified lookup and the set of declarations found in the
+ * namespaces and classes associated with the argument types.
+ */
+ public IParameterizedSymbol UnqualifiedFunctionLookup( String name, LinkedList parameters ) throws ParserSymbolTableException{
+ //figure out the set of associated scopes first, so we can remove those that are searched
+ //during the normal lookup to avoid doing them twice
+ HashSet associated = new HashSet();
+
+ //collect associated namespaces & classes.
+ int size = ( parameters == null ) ? 0 : parameters.size();
+ Iterator iter = ( parameters == null ) ? null : parameters.iterator();
+
+ TypeInfo param = null;
+ ISymbol paramType = null;
+ for( int i = size; i > 0; i-- ){
+ param = (TypeInfo) iter.next();
+ paramType = ParserSymbolTable.getFlatTypeInfo( param ).getTypeSymbol();
+
+ ParserSymbolTable.getAssociatedScopes( paramType, associated );
+
+ //if T is a pointer to a data member of class X, its associated namespaces and classes
+ //are those associated with the member type together with those associated with X
+ if( param.hasPtrOperators() && param.getPtrOperators().size() == 1 ){
+ TypeInfo.PtrOp op = (TypeInfo.PtrOp)param.getPtrOperators().getFirst();
+ if( op.getType() == TypeInfo.PtrOp.t_pointer &&
+ paramType.getContainingSymbol().isType( TypeInfo.t_class, TypeInfo.t_union ) )
+ {
+ ParserSymbolTable.getAssociatedScopes( paramType.getContainingSymbol(), associated );
+ }
+ }
+ }
+
+ LookupData data = new LookupData( name, TypeInfo.t_function, getTemplateInstance() );
+ //if parameters == null, thats no parameters, but we need to distinguish that from
+ //no parameter information at all, so make an empty list.
+ data.parameters = ( parameters == null ) ? new LinkedList() : parameters;
+ data.associated = associated;
+
+ ParserSymbolTable.Lookup( data, this );
+
+ Declaration found = (Declaration)ResolveAmbiguities( data );
+
+ //if we haven't found anything, or what we found is not a class member, consider the
+ //associated scopes
+ if( found == null || found.getContainingSymbol().getType() != TypeInfo.t_class ){
+ if( found != null ){
+ data.foundItems.add( found );
+ }
+
+ Declaration decl;
+ Declaration temp;
+
+ //dump the hash to an array and iterate over the array because we
+ //could be removing items from the collection as we go and we don't
+ //want to get ConcurrentModificationExceptions
+ Object [] scopes = associated.toArray();
+
+ size = associated.size();
+
+ for( int i = 0; i < size; i++ ){
+ decl = (Declaration) scopes[ i ];
+ if( associated.contains( decl ) ){
+ data.qualified = true;
+ data.ignoreUsingDirectives = true;
+ ParserSymbolTable.Lookup( data, decl );
+ }
+ }
+
+ found = (Declaration)ParserSymbolTable.ResolveAmbiguities( data );
+ }
+
+ return found;
+ }
+
+ public boolean hasSpecializations(){
+ return ( _specializations != null && !_specializations.isEmpty() );
+ }
+
+ public LinkedList getSpecializations(){
+ return _specializations;
+ }
+
+ public void addSpecialization( IParameterizedSymbol spec ){
+ if( _specializations == null ){
+ _specializations = new LinkedList();
+ }
+ _specializations.add( spec );
+ }
+
+ public TemplateInstance instantiate( LinkedList arguments ) throws ParserSymbolTableException{
+ if( getType() != TypeInfo.t_template ){
+ return null;
+ }
+
+ //TODO uncomment when template specialization matching & ordering is working
+ //IParameterizedSymbol template = ParserSymbolTable.matchTemplatePartialSpecialization( this, arguments );
+ IParameterizedSymbol template = null;
+
+ if( template == null ){
+ template = this;
+ }
+
+ List paramList = template.getParameterList();
+ int numParams = ( paramList != null ) ? paramList.size() : 0;
+
+ if( numParams == 0 ){
+ return null;
+ }
+
+ HashMap map = new HashMap();
+ Iterator paramIter = paramList.iterator();
+ Iterator argIter = arguments.iterator();
+
+ ISymbol param = null;
+ TypeInfo arg = null;
+ for( int i = 0; i < numParams; i++ ){
+ param = (ISymbol) paramIter.next();
+
+ if( argIter.hasNext() ){
+ arg = (TypeInfo) argIter.next();
+ map.put( param, arg );
+ } else {
+ Object obj = param.getTypeInfo().getDefault();
+ if( obj != null && obj instanceof TypeInfo ){
+ map.put( param, obj );
+ } else {
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
+ }
+ }
+ }
+
+ if( template.getContainedSymbols().size() != 1 ){
+ throw new ParserSymbolTableException( ParserSymbolTableException.r_BadTemplate );
+ }
+
+ Iterator iter = template.getContainedSymbols().keySet().iterator();
+ IContainerSymbol symbol = (IContainerSymbol) template.getContainedSymbols().get( iter.next() );
+
+ TemplateInstance instance = new TemplateInstance( symbol, map );
+ return instance;
+ }
+
+
+ private boolean _needsDefinition; //this name still needs to be defined
+
+
+ private LinkedList _parentScopes; //inherited scopes (is base classes)
+ private LinkedList _usingDirectives; //collection of nominated namespaces
+ private HashMap _containedDeclarations; //declarations contained by us.
+
+ private LinkedList _specializations; //template specializations
+ private LinkedList _argumentList; //template specialization arguments
+
+ private LinkedList _parameterList; //have my cake
+ private HashMap _parameterHash; //and eat it too
+
+ private ISymbol _returnType;
+
+
+
+ public class ParentWrapper implements IDerivableContainerSymbol.IParentSymbol
+ {
+ public ParentWrapper( ISymbol p, boolean v, AccessVisibility s ){
+ parent = p;
+ isVirtual = v;
+ access = s;
+ }
+
+ public void setParent( ISymbol parent ){
+ this.parent = (Declaration) parent;
+ }
+
+ public ISymbol getParent(){
+ return parent;
+ }
+
+ public boolean isVirtual(){
+ return isVirtual;
+ }
+
+ public void setVirtual( boolean virtual ){
+ isVirtual = virtual;
+ }
+
+ private boolean isVirtual = false;
+ private ISymbol parent = null;
+ private final AccessVisibility access;
+ /**
+ * @return
+ */
+ public AccessVisibility getAccess() {
+ return access;
+ }
+
+ }
+ }
+
+ static public class TypeInfo {
+ public TypeInfo(){
+ super();
+ }
+
+ public TypeInfo( eType type, int info, ISymbol symbol ){
+ super();
+ _typeInfo = info;
+ _type = type;
+ _typeDeclaration = symbol;
+ }
+
+ public TypeInfo( eType type, int info, ISymbol symbol, PtrOp op, boolean hasDefault ){
+ super();
+ _typeInfo = info;
+ _type = type;
+ _typeDeclaration = symbol;
+ if( op != null ){
+ _ptrOperators = new LinkedList();
+ _ptrOperators.add( op );
+ } else {
+ _ptrOperators = null;
+ }
+ _hasDefaultValue = hasDefault;
+ }
+
+ public TypeInfo( eType type, int info, ISymbol symbol, PtrOp op, Object def ){
+ super();
+ _typeInfo = info;
+ _type = type;
+ _typeDeclaration = symbol;
+ if( op != null ){
+ _ptrOperators = new LinkedList();
+ _ptrOperators.add( op );
+ } else {
+ _ptrOperators = null;
+ }
+ _hasDefaultValue = true;
+ setDefault( def );
+ }
+
+ public TypeInfo( TypeInfo info ){
+ super();
+
+ _typeInfo = info._typeInfo;
+ _type = info._type;
+ _typeDeclaration = info._typeDeclaration;
+ _ptrOperators = ( info._ptrOperators == null ) ? null : (LinkedList)info._ptrOperators.clone();
+ _hasDefaultValue = info._hasDefaultValue;
+ }
+
+ public static final int typeMask = 0x001f;
+ public static final int isAuto = 0x0020;
+ public static final int isRegister = 0x0040;
+ public static final int isStatic = 0x0080;
+ public static final int isExtern = 0x0100;
+ public static final int isMutable = 0x0200;
+ public static final int isInline = 0x0400;
+ public static final int isVirtual = 0x0800;
+ public static final int isExplicit = 0x1000;
+ public static final int isTypedef = 0x2000;
+ public static final int isFriend = 0x4000;
+ public static final int isConst = 0x8000;
+ public static final int isVolatile = 0x10000;
+ public static final int isUnsigned = 0x20000;
+ public static final int isShort = 0x40000;
+ public static final int isLong = 0x80000;
+
+ // Types (maximum type is typeMask
+ // Note that these should be considered ordered and if you change
+ // the order, you should consider the ParserSymbolTable uses
+ public static final eType t_any = new eType( -1 ); //don't care
+ public static final eType t_undef = new eType( 0 ); //not specified
+ public static final eType t_type = new eType( 1 ); //Type Specifier
+ public static final eType t_namespace = new eType( 2 );
+ public static final eType t_class = new eType( 3 );
+ public static final eType t_struct = new eType( 4 );
+ public static final eType t_union = new eType( 5 );
+ public static final eType t_enumeration = new eType( 6 );
+ public static final eType t_function = new eType( 7 );
+ public static final eType t_bool = new eType( 8 );
+ public static final eType t_char = new eType( 9 );
+ public static final eType t_wchar_t = new eType( 10 );
+ public static final eType t_int = new eType( 11 );
+ public static final eType t_float = new eType( 12 );
+ public static final eType t_double = new eType( 13 );
+ public static final eType t_void = new eType( 14 );
+ public static final eType t_enumerator = new eType( 15 );
+ public static final eType t_block = new eType( 16 );
+ public static final eType t_template = new eType( 17 );
+ public static final eType t_asm = new eType( 18 );
+ public static final eType t_linkage = new eType( 19 );
+ //public static final eType t_templateParameter = new eType( 18 );
+
+ public static class eType implements Comparable{
+ private eType( int v ){
+ _val = v;
+ }
+
+ public int compareTo( Object o ){
+ eType t = (eType) o;
+ return _val - t._val;
+ }
+
+ public int toInt(){
+ return _val;
+ }
+
+ private int _val;
+ }
+
+ public static class PtrOp {
+ public PtrOp( eType type ){
+ this.type = type;
+ }
+ public PtrOp( eType type, boolean isConst, boolean isVolatile ){
+ this.type = type;
+ this.isConst = isConst;
+ this.isVolatile = isVolatile;
+ }
+ public PtrOp( ISymbol memberOf, boolean isConst, boolean isVolatile ){
+ this.type = t_memberPointer;
+ this.isConst = isConst;
+ this.isVolatile = isVolatile;
+ this.memberOf = memberOf;
+ }
+
+ public PtrOp(){
+ super();
+ }
+
+ public static final eType t_undef = new eType( 0 );
+ public static final eType t_pointer = new eType( 1 );
+ public static final eType t_reference = new eType( 2 );
+ public static final eType t_array = new eType( 3 );
+ public static final eType t_memberPointer = new eType( 4 );
+
+ public eType getType() { return type; }
+ public void setType( eType type ) { this.type = type; }
+
+ public boolean isConst() { return isConst; }
+ public boolean isVolatile() { return isVolatile; }
+ public void setConst( boolean isConst ) { this.isConst = isConst; }
+ public void setVolatile(boolean isVolatile) { this.isVolatile = isVolatile; }
+
+ public ISymbol getMemberOf() { return memberOf; }
+ public void setMemberOf( ISymbol member ) { this.memberOf = member; }
+
+ public int compareCVTo( PtrOp ptr ){
+ int cv1 = ( isConst() ? 1 : 0 ) + ( isVolatile() ? 1 : 0 );
+ int cv2 = ( ptr.isConst() ? 1 : 0 ) + ( ptr.isVolatile() ? 1 : 0 );
+
+ return cv1 - cv2;
+ }
+ public boolean equals( Object o ){
+ if( o == null || !(o instanceof PtrOp) ){
+ return false;
+ }
+ PtrOp op = (PtrOp)o;
+
+ return ( isConst() == op.isConst() &&
+ isVolatile() == op.isVolatile() &&
+ getType() == op.getType() );
+ }
+
+ private eType type = t_undef;
+ private boolean isConst = false;
+ private boolean isVolatile = false;
+ private ISymbol memberOf = null;
+ }
+
+ private static final String _image[] = { "",
+ "",
+ "namespace",
+ "template",
+ "class",
+ "struct",
+ "union",
+ "enum",
+ "",
+ "bool",
+ "char",
+ "wchar_t",
+ "int",
+ "float",
+ "double",
+ "void",
+ ""
+ };
+ //Partial ordering :
+ // none < const
+ // none < volatile
+ // none < const volatile
+ // const < const volatile
+ // volatile < const volatile
+ public static final int cvConst = 2;
+ public static final int cvVolatile = 3;
+ public static final int cvConstVolatile = 5;
+
+ // Convenience methods
+ public void setBit(boolean b, int mask){
+ if( b ){
+ _typeInfo = _typeInfo | mask;
+ } else {
+ _typeInfo = _typeInfo & ~mask;
+ }
+ }
+
+ public boolean checkBit(int mask){
+ return (_typeInfo & mask) != 0;
+ }
+
+ public void setType( eType t){
+ _type = t;
+ }
+
+ public eType getType(){
+ return _type;
+ }
+
+ public boolean isType( eType type ){
+ return isType( type, t_undef );
+ }
+
+ public int getTypeInfo(){
+ return _typeInfo;
+ }
+
+ public void setTypeInfo( int typeInfo ){
+ _typeInfo = typeInfo;
+ }
+
+ /**
+ *
+ * @param type
+ * @param upperType
+ * @return boolean
+ *
+ * type checking, check that this declaration's type is between type and
+ * upperType (inclusive). upperType of 0 means no range and our type must
+ * be type.
+ */
+ public boolean isType( eType type, eType upperType ){
+ //type of -1 means we don't care
+ if( type == t_any )
+ return true;
+
+ //upperType of 0 means no range
+ if( upperType == t_undef ){
+ return ( getType() == type );
+ } else {
+ return ( getType().compareTo( type ) >= 0 && getType().compareTo( upperType ) <= 0 );
+ }
+ }
+
+ public ISymbol getTypeSymbol(){
+ return _typeDeclaration;
+ }
+
+ public void setTypeSymbol( ISymbol type ){
+ _typeDeclaration = type;
+ }
+
+ public boolean hasPtrOperators(){
+ return ( _ptrOperators != null && _ptrOperators.size() > 0 );
+ }
+
+ public LinkedList getPtrOperators(){
+ return _ptrOperators;
+ }
+
+ public boolean hasSamePtrs( TypeInfo type ){
+ int size = hasPtrOperators() ? getPtrOperators().size() : 0;
+ int size2 = type.hasPtrOperators() ? type.getPtrOperators().size() : 0;
+ if( size == size2 ){
+ if( size > 0 ){
+ Iterator iter1 = getPtrOperators().iterator();
+ Iterator iter2 = type.getPtrOperators().iterator();
+ PtrOp ptr1 = null, ptr2 = null;
+ for( int i = size; i > 0; i-- ){
+ ptr1 = (PtrOp)iter1.next();
+ ptr2 = (PtrOp)iter2.next();
+ if( ptr1.getType() != ptr2.getType() ){
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public void applyPtrsAsUnaryOperators( LinkedList ptrs ){
+ if( ptrs == null || ptrs.isEmpty() )
+ return;
+
+ int size = ptrs.size();
+ Iterator iter = ptrs.iterator();
+ PtrOp op = null;
+ for( int i = size; i > 0; i-- ){
+ op = (PtrOp)iter.next();
+ if( op.getType() == PtrOp.t_pointer ){
+ //indirection operator, can only be applied to a pointer
+ if( hasPtrOperators() ){
+ PtrOp first = (PtrOp)getPtrOperators().getFirst();
+ if( first.getType() == PtrOp.t_pointer )
+ {
+ getPtrOperators().removeFirst();
+ if( op.isConst() || op.isVolatile() ){
+
+ if( hasPtrOperators() ){
+ ((PtrOp)getPtrOperators().getFirst()).setConst( op.isConst() );
+ ((PtrOp)getPtrOperators().getFirst()).setVolatile( op.isVolatile() );
+ } else {
+ PtrOp newOp = new PtrOp( PtrOp.t_undef, op.isConst(), op.isVolatile() );
+ addPtrOperator( newOp );
+ }
+ }
+ }
+ } else {
+ //???
+ }
+ } else if( op.getType() == PtrOp.t_reference ){
+ //Address-of unary operator, results in pointer to T
+ //TODO or pointer to member
+ PtrOp newOp = new PtrOp( PtrOp.t_pointer, op.isConst(), op.isVolatile() );
+ addPtrOperator( newOp );
+ }
+ }
+ }
+
+ public void addPtrOperator( PtrOp ptr ){
+ if( _ptrOperators == null ){
+ _ptrOperators = new LinkedList();
+ }
+ if( ptr != null )
+ _ptrOperators.add( ptr );
+ }
+
+ public void addPtrOperator( List ptrs ){
+ if( _ptrOperators == null ){
+ _ptrOperators = new LinkedList();
+ }
+ if( ptrs != null )
+ _ptrOperators.addAll( ptrs );
+ }
+
+ public boolean getHasDefault(){
+ return _hasDefaultValue;
+ }
+
+ public void setHasDefault( boolean def ){
+ _hasDefaultValue = def;
+ }
+ public void setDefault( Object t ){
+ _defaultValue = t;
+ }
+ public Object getDefault(){
+ return _defaultValue;
+ }
+
+ /**
+ * canHold
+ * @param type
+ * @return boolean
+ * return true is the our type can hold all the values of the passed in
+ * type.
+ * TODO, for now return true if our type is "larger" (based on ordering of
+ * the type values)
+ */
+ public boolean canHold( TypeInfo type ){
+ return getType().compareTo( type.getType() ) >= 0;
+ }
+
+ public boolean equals( Object t ){
+ if( t == null || !(t instanceof TypeInfo) ){
+ return false;
+ }
+
+ TypeInfo type = (TypeInfo)t;
+
+ boolean result = ( _typeInfo == type._typeInfo );
+ result &= ( _type == type._type );
+
+ if( _typeDeclaration instanceof TemplateInstance ){
+ result &= _typeDeclaration.equals( type._typeDeclaration );
+ } else {
+ result &= ( _typeDeclaration == type._typeDeclaration );
+ }
+
+
+ int size1 = (_ptrOperators == null) ? 0 : _ptrOperators.size();
+ int size2 = (type._ptrOperators == null) ? 0 : type._ptrOperators.size();
+ if( size1 == size2 ){
+ if( size1 != 0 ){
+ Iterator iter1 = _ptrOperators.iterator();
+ Iterator iter2 = type._ptrOperators.iterator();
+
+ PtrOp op1 = null, op2 = null;
+ for( int i = size1; i > 0; i-- ){
+ op1 = (PtrOp)iter1.next();
+ op2 = (PtrOp)iter2.next();
+
+ if( !op1.equals(op2) ){
+ return false;
+ }
+ }
+ }
+ } else {
+ return false;
+ }
+
+ return result;
+ }
+
+ public String toString(){
+ if( isType( t_type ) ){
+ return _typeDeclaration.getName();
+ } else {
+ return _image[ getType().toInt() ];
+ }
+ }
+
+ private int _typeInfo = 0;
+ private eType _type = t_undef;
+ private ISymbol _typeDeclaration;
+
+ private boolean _hasDefaultValue = false;
+ private Object _defaultValue = null;
+ private LinkedList _ptrOperators;
+ }
+}
Index: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
===================================================================
RCS file: parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
diff -N parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ parser/org/eclipse/cdt/internal/core/parser/pst/ParserSymbolTableException.java 13 Jun 2003 14:58:13 -0000
@@ -0,0 +1,47 @@
+/**********************************************************************
+ * Copyright (c) 2002,2003 Rational Software Corporation and others.
+ * 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:
+ * Rational Software - Initial API and implementation
+***********************************************************************/
+
+package org.eclipse.cdt.internal.core.parser.pst;
+
+/**
+ * @author aniefer
+ *
+ * To change this generated comment edit the template variable "typecomment":
+ * Window>Preferences>Java>Templates.
+ * To enable and disable the creation of type comments go to
+ * Window>Preferences>Java>Code Generation.
+ */
+public class ParserSymbolTableException extends Exception {
+
+ /**
+ * Constructor for ParserSymbolTableException.
+ */
+ public ParserSymbolTableException() {
+ super();
+ }
+
+ /**
+ * Constructor for ParserSymbolTableException.
+ * @param int r: reason
+ */
+ public ParserSymbolTableException( int r ) {
+ reason = r;
+ }
+
+ public static final int r_Unspecified = -1;
+ public static final int r_Ambiguous = 0;
+ public static final int r_BadTypeInfo = 1;
+ public static final int r_CircularInheritance = 2;
+ public static final int r_InvalidOverload = 3;
+ public static final int r_BadTemplate = 4;
+
+ public int reason = -1;
+}
\ No newline at end of file