[PATCH 1/2] stinst: Add a pool look-up test for GNUPlot.GNUPlot like conditions.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/2] stinst: Add a pool look-up test for GNUPlot.GNUPlot like conditions.

Holger Freyther
---
 packages/stinst/parser/PoolResolutionTests.st | 27 +++++++++++++++++++++++++--
 packages/stinst/parser/STSymTable.st          | 25 ++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/packages/stinst/parser/PoolResolutionTests.st b/packages/stinst/parser/PoolResolutionTests.st
index 197fae8..9d6d06c 100644
--- a/packages/stinst/parser/PoolResolutionTests.st
+++ b/packages/stinst/parser/PoolResolutionTests.st
@@ -7,7 +7,7 @@
 
 "======================================================================
 |
-| Copyright (C) 2008 Free Software Foundation, Inc.
+| Copyright (C) 2008,2013 Free Software Foundation, Inc.
 | Written by Stephen Compall.
 |
 | This file is part of the GNU Smalltalk class library.
@@ -38,6 +38,17 @@ superclass only' namespace-walk-stop rule"
 MyLibrary at: #PkgVersion put: 'MyLibrary 1.0'.
 MyProject at: #PkgVersion put: 'MyProject 0.3141'.
 
+
+
+Namespace current: Smalltalk [
+    Namespace current: DoubleName [
+        Object subclass: DoubleName [
+            <comment: 'My name is the name of the namespace. This happens
+            with GNUPlot, Cairo and other packages.'>
+        ]
+    ]
+]
+
 Namespace current: STInST.Tests.MyLibrary [
 
 Eval [
@@ -99,7 +110,7 @@ MyProject.MyLibWrapper.Baz subclass: BackForMore [
 Namespace current: STInST.Tests [
 
 TestCase subclass: TestDefaultPoolResolution [
-    | foo bar baz blah backformore |
+    | foo bar baz blah backformore doubleNameFirst doubleNameLast |
 
     assertVariable: symbol of: pools is: value description: str [
  | binding |
@@ -114,6 +125,11 @@ TestCase subclass: TestDefaultPoolResolution [
  blah := DefaultPoolResolution of: MyLibrary.Blah.
  baz := DefaultPoolResolution of: MyProject.MyLibWrapper.Baz.
  backformore := DefaultPoolResolution of: MyLibrary.BackForMore.
+
+        doubleNameFirst := DefaultPoolResolution of: UndefinedObject.
+        doubleNameFirst addPoolFirst: DoubleName.
+        doubleNameLast := DefaultPoolResolution of: UndefinedObject.
+        doubleNameLast addPoolLast: DoubleName.
     ]
 
     testClassPoolFirst [
@@ -150,6 +166,13 @@ TestCase subclass: TestDefaultPoolResolution [
  self assertVariable: #Scoobs of: backformore is: 785
      description: 'superclass ns pools inherited'.
     ]
+
+    testDoubleName [
+        self assertVariable: #DoubleName of: doubleNameFirst
+            is: Smalltalk.DoubleName.DoubleName description: 'the class is found'.
+        self assertVariable: #DoubleName of: doubleNameLast
+            is: Smalltalk.DoubleName description: 'the name is found'.
+    ]
 ]
 
 TestCase subclass: TestClassicPoolResolution [
diff --git a/packages/stinst/parser/STSymTable.st b/packages/stinst/parser/STSymTable.st
index abf5297..40e5625 100644
--- a/packages/stinst/parser/STSymTable.st
+++ b/packages/stinst/parser/STSymTable.st
@@ -7,7 +7,7 @@
 
 "======================================================================
 |
-| Copyright 1995,1999,2000,2001,2002,2006,2007,2008 Free Software Foundation, Inc.
+| Copyright 1995,1999,2000,2001,2002,2006,2007,2008,2013 Free Software Foundation, Inc.
 | Written by Steve Byrne.
 |
 | This file is part of GNU Smalltalk.
@@ -518,6 +518,13 @@ use compiling methods for that class.'>
  ^addedPool
     ]
 
+    addPoolFirst: poolDictionary [
+ "My implementation does nothing; you must override it if you
+ want it. Look at addPoolLast:"
+ <category: 'overriding'>
+ ^false
+    ]
+
     addPoolLast: poolDictionary [
  "If it is sensible, add poolDictionary to the end of my pool
  search order, setting aside whatever standards I usually use
@@ -569,6 +576,14 @@ PoolResolution subclass: ClassicPoolResolution [
 before the PoolResolution hierarchy was added, and TwistedPools became
 default.'>
 
+    addPoolFirst: poolDictionary [
+ "Add poolDictionary and all superspaces to the end of the
+ search order. Always succeed."
+ <category: 'accessing'>
+ pools addAllFirst: poolDictionary withAllSuperspaces.
+ ^true
+    ]
+
     addPoolLast: poolDictionary [
  "Add poolDictionary and all superspaces to the end of the
  search order. Always succeed."
@@ -611,6 +626,14 @@ expect things to be found in their own namespace first. This is more
 fully explained by my implementation, or at GNU Smalltalk wiki page
 PoolResolution.'>
 
+    addPoolFirst: poolDictionary [
+ "Add poolDictionary and all superspaces to the end of the
+ search order. Always succeed."
+ <category: 'accessing'>
+ pools addAllFirst: poolDictionary withAllSuperspaces.
+ ^true
+    ]
+
     addPoolLast: poolDictionary [
  "Add poolDictionary and all superspaces to the end of the
  search order. Always succeed."
--
1.8.5.1


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] stinst: Resolve GNUPlot.GNUPlot properly

Holger Freyther
Importing the Cairo and GNUPlot (probably other packages too) failed
because of GNUPlot.GNUPlot was looked up wrongly in the current
namespace. Add the current Namespace in front of all the other pools.
---
 packages/stinst/parser/Makefile.frag      |  2 +-
 packages/stinst/parser/STCompiler.st      |  8 ++---
 packages/stinst/parser/STCompilerTests.st | 57 +++++++++++++++++++++++++++++++
 packages/stinst/parser/STSymTable.st      |  7 +++-
 packages/stinst/parser/package.xml        |  2 ++
 5 files changed, 70 insertions(+), 6 deletions(-)
 create mode 100644 packages/stinst/parser/STCompilerTests.st

diff --git a/packages/stinst/parser/Makefile.frag b/packages/stinst/parser/Makefile.frag
index 05ef067..b70055b 100644
--- a/packages/stinst/parser/Makefile.frag
+++ b/packages/stinst/parser/Makefile.frag
@@ -1,5 +1,5 @@
 Parser_FILES = \
-packages/stinst/parser/ChangeLog packages/stinst/parser/DebugInformationTests.st packages/stinst/parser/Exporter.st packages/stinst/parser/Extensions.st packages/stinst/parser/GSTParser.st packages/stinst/parser/GSTParserTests.st packages/stinst/parser/NewSyntaxExporter.st packages/stinst/parser/OldSyntaxExporter.st packages/stinst/parser/OrderedSet.st packages/stinst/parser/ParseTreeSearcher.st packages/stinst/parser/PoolResolutionTests.st packages/stinst/parser/RBFormatter.st packages/stinst/parser/RBParseNodes.st packages/stinst/parser/RBParser.st packages/stinst/parser/RBToken.st packages/stinst/parser/RewriteTests.st packages/stinst/parser/SIFParser.st packages/stinst/parser/SqueakExporter.st packages/stinst/parser/SqueakParser.st packages/stinst/parser/STCompiler.st packages/stinst/parser/STCompLit.st packages/stinst/parser/STDecompiler.st packages/stinst/parser/STEvaluationDriver.st packages/stinst/parser/STFileParser.st packages/stinst/parser/STLoaderObjs.st packages/stinst/
 parser/STLoaderObjsTests.st packages/stinst/parser/STLoader.st packages/stinst/parser/STSymTable.st
+packages/stinst/parser/ChangeLog packages/stinst/parser/DebugInformationTests.st packages/stinst/parser/Exporter.st packages/stinst/parser/Extensions.st packages/stinst/parser/GSTParser.st packages/stinst/parser/GSTParserTests.st packages/stinst/parser/NewSyntaxExporter.st packages/stinst/parser/OldSyntaxExporter.st packages/stinst/parser/OrderedSet.st packages/stinst/parser/ParseTreeSearcher.st packages/stinst/parser/PoolResolutionTests.st packages/stinst/parser/RBFormatter.st packages/stinst/parser/RBParseNodes.st packages/stinst/parser/RBParser.st packages/stinst/parser/RBToken.st packages/stinst/parser/RewriteTests.st packages/stinst/parser/SIFParser.st packages/stinst/parser/SqueakExporter.st packages/stinst/parser/SqueakParser.st packages/stinst/parser/STCompiler.st packages/stinst/parser/STCompilerTests.st packages/stinst/parser/STCompLit.st packages/stinst/parser/STDecompiler.st packages/stinst/parser/STEvaluationDriver.st packages/stinst/parser/STFileParser.st packages/stin
 st/parser/STLoaderObjs.st packages/stinst/parser/STLoaderObjsTests.st packages/stinst/parser/STLoader.st packages/stinst/parser/STSymTable.st
 $(Parser_FILES):
 $(srcdir)/packages/stinst/parser/stamp-classes: $(Parser_FILES)
  touch $(srcdir)/packages/stinst/parser/stamp-classes
diff --git a/packages/stinst/parser/STCompiler.st b/packages/stinst/parser/STCompiler.st
index e8bccac..098437d 100644
--- a/packages/stinst/parser/STCompiler.st
+++ b/packages/stinst/parser/STCompiler.st
@@ -7,7 +7,7 @@
 
 "======================================================================
 |
-| Copyright 1999,2000,2001,2002,2003,2006,2007,2009 Free Software Foundation, Inc.
+| Copyright 1999,2000,2001,2002,2003,2006,2007,2009,2013 Free Software Foundation, Inc.
 | Written by Paolo Bonzini.
 |
 | This file is part of GNU Smalltalk.
@@ -157,7 +157,7 @@ indexed'' bytecode. The resulting stream is
  | compiler method |
  compiler := self new.
  compiler class: aBehavior parser: aParser.
- aNamespace isNil ifFalse: [compiler addPool: aNamespace].
+ aNamespace isNil ifFalse: [compiler addPoolFirst: aNamespace].
  method := compiler visitNode: methodNode.
  aString isNil ifFalse: [ method methodCategory: aString ].
  ^method
@@ -179,9 +179,9 @@ indexed'' bytecode. The resulting stream is
  ^(symTable addLiteral: literal)
     ]
 
-    addPool: aNamespace [
+    addPoolFirst: aNamespace [
  <category: 'accessing'>
- ^symTable addPool: aNamespace
+ ^symTable addPoolFirst: aNamespace
     ]
 
     bytecodesFor: aBlockNode [
diff --git a/packages/stinst/parser/STCompilerTests.st b/packages/stinst/parser/STCompilerTests.st
new file mode 100644
index 0000000..f4ae651
--- /dev/null
+++ b/packages/stinst/parser/STCompilerTests.st
@@ -0,0 +1,57 @@
+"======================================================================
+|
+|   Smalltalk in Smalltalk compiler tests
+|
+|
+ ======================================================================"
+
+"======================================================================
+|
+| Copyright 2013 Free Software Foundation, Inc.
+| Written by Holger Hans Peter Freyther.
+|
+| This file is part of GNU Smalltalk.
+|
+| GNU Smalltalk is free software; you can redistribute it and/or modify it
+| under the terms of the GNU General Public License as published by the Free
+| Software Foundation; either version 2, or (at your option) any later version.
+|
+| GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
+| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+| FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+| details.
+|
+| You should have received a copy of the GNU General Public License along with
+| GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
+| Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
+|
+ ======================================================================"
+
+
+TestCase subclass: TestCompiler [
+    <comment: 'I do basic compiler tests.'>
+
+    doubleName [
+        ^ '
+Namespace current: (Smalltalk addSubspace: #CompilerDoubleName).
+Object subclass: CompilerDoubleName [
+    | one two three |
+    <category: ''bla''>
+]'
+        
+    ]
+
+    testPoolResolution [
+        <category: 'testing'>
+
+        self deny: (Smalltalk includesGlobalNamed: #CompilerDoubleName).
+
+        STEvaluationDriver new
+            parseSmalltalkStream: self doubleName readStream
+            with: GSTFileInParser.
+
+        self assert: (Smalltalk includesGlobalNamed: #CompilerDoubleName).
+        self assert: (CompilerDoubleName includesGlobalNamed: #CompilerDoubleName).
+        self assert: ((Smalltalk at: #CompilerDoubleName) at: #CompilerDoubleName) instVarNames size = 3.
+    ]
+]
diff --git a/packages/stinst/parser/STSymTable.st b/packages/stinst/parser/STSymTable.st
index 40e5625..b6bf7fd 100644
--- a/packages/stinst/parser/STSymTable.st
+++ b/packages/stinst/parser/STSymTable.st
@@ -264,11 +264,16 @@ Object subclass: STSymbolTable [
  ^super new init
     ]
 
-    addPool: poolDictionary [
+    addPoolLast: poolDictionary [
  <category: 'declaring'>
  pools addPoolLast: poolDictionary
     ]
 
+    addPoolFirst: poolDictionary [
+        <category: 'declaring'>
+        pools addPoolFirst: poolDictionary.
+    ]
+
     declareEnvironment: aBehavior [
  <category: 'declaring'>
  | i |
diff --git a/packages/stinst/parser/package.xml b/packages/stinst/parser/package.xml
index 106ce80..6102af7 100644
--- a/packages/stinst/parser/package.xml
+++ b/packages/stinst/parser/package.xml
@@ -37,11 +37,13 @@
    <sunit>STInST.Tests.TestDebugInformation</sunit>
    <sunit>STInST.Tests.TestSTLoaderObjects</sunit>
    <sunit>STInST.Tests.TestGSTParser</sunit>
+   <sunit>STInST.Tests.TestCompiler</sunit>
    <filein>RewriteTests.st</filein>
    <filein>PoolResolutionTests.st</filein>
    <filein>DebugInformationTests.st</filein>
    <filein>STLoaderObjsTests.st</filein>
    <filein>GSTParserTests.st</filein>
+   <filein>STCompilerTests.st</filein>
   </test>
 
   <file>ChangeLog</file>
--
1.8.5.1


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk