java compiler work jk_new_structure
authorhlopkmar
Tue, 03 Apr 2012 12:02:05 +0000
branchjk_new_structure
changeset 1449 797c2aa3bbce
parent 1448 4c9fd027d2d4
child 1450 4817f2a363d6
java compiler work
src/JavaClass.st
src/JavaCompilerTests.st
src/JavaCompiler_Eclipse.st
src/JavaLookup.st
src/Make.proto
src/Make.spec
src/abbrev.stc
src/bc.mak
src/libjava.rc
--- a/src/JavaClass.st	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/JavaClass.st	Tue Apr 03 12:02:05 2012 +0000
@@ -1593,6 +1593,19 @@
     "Created: / 17-03-2012 / 15:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+new: arg1 _: arg2 _: arg3 _: arg4 _: arg5
+    ^ self 
+        new: arg1
+        with: arg2
+        with: arg3
+        with: arg4
+        with: arg5
+
+    "Modified: / 04-11-1998 / 18:04:34 / cg"
+    "Created: / 17-03-2012 / 15:13:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 03-04-2012 / 12:17:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+!
+
 new: arg1 with: arg2
     "create a new instance and call 2-arg constructor"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/JavaCompilerTests.st	Tue Apr 03 12:02:05 2012 +0000
@@ -0,0 +1,82 @@
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+
+ New code and modifications done at SWING Research Group [1]:
+
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+                            SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+     of one of the above copright owners. For exact set of such code,
+     see the differences between this version and version stx:libjava
+     as of 1.9.2010
+"
+"{ Package: 'stx:libjava' }"
+
+TestCase subclass:#JavaCompilerTests
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Languages-Java-Tools-Tests'
+!
+
+!JavaCompilerTests class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1996-2011 by Claus Gittinger
+
+ New code and modifications done at SWING Research Group [1]:
+
+ COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
+                            SWING Research Group, Czech Technical University in Prague
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+
+ [1] Code written at SWING Research Group contains a signature
+     of one of the above copright owners. For exact set of such code,
+     see the differences between this version and version stx:libjava
+     as of 1.9.2010
+
+"
+!
+
+history
+
+    "Created: / 03-04-2012 / 12:02:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Created: #testCompileHelloWorld / 03-04-2012 / 12:15:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaCompilerTests methodsFor:'tests'!
+
+testCompileHelloWorld
+    | content  packageName  filename  compUnit  result |
+    content := ByteArray new.
+    packageName := nil.
+    filename := 'foo.java'.
+    compUnit := JAVA org eclipse jdt internal core BasicCompilationUnit 
+            new: content
+            with: packageName
+            with: filename.
+    result := JavaCompiler_Eclipse compile: compUnit.
+
+    "Created: / 03-04-2012 / 12:15:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+! !
+
+!JavaCompilerTests class methodsFor:'documentation'!
+
+version_SVN
+    ^ '$Id::                                                                                                                        $'
+! !
--- a/src/JavaCompiler_Eclipse.st	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/JavaCompiler_Eclipse.st	Tue Apr 03 12:02:05 2012 +0000
@@ -73,14 +73,13 @@
 !JavaCompiler_Eclipse methodsFor:'compiling'!
 
 compilationResultFor: compilationUnit 
-    ^ (Java 
-        classForName: 'org.eclipse.jdt.internal.compiler.CompilationResult') 
-            new: compilationUnit
-            with: 0
-            with: 0
-            with: 0.
+    ^ (Java classForName: 'org.eclipse.jdt.internal.compiler.CompilationResult') 
+        new: compilationUnit
+        with: 0
+        with: 0
+        with: 0.
 
-    "Modified (format): / 02-04-2012 / 13:19:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 03-04-2012 / 12:39:20 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 compile: compilationUnit 
@@ -90,22 +89,24 @@
     options := self compilerOptions.
     requestor := self compilationResultFor: compilationUnit.
     problemFactory := self problemFactory.
-    "Do not use cached Java class - think about #flushAllJavaResources"
-    compiler := (JAVA org eclipse jdt internal compiler Compiler)
+     "Do not use cached Java class - think about #flushAllJavaResources"
+    compiler := (JAVA org eclipse jdt internal compiler Compiler) 
             new: compEnv
             with: policy
             with: options
             with: requestor
             with: problemFactory.
     compiler compile: compilationUnit.
-    self halt: 'more to come tomorrow'.
+    self breakPoint: #mh.
+    ^ requestor getClassFiles.
 
     "Created: / 02-04-2012 / 13:18:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
     "Modified: / 02-04-2012 / 18:42:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 03-04-2012 / 11:49:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 compilerEnvironment
-    ^(Java classForName: 'stx.libjava.tools.LibjavaCompilerEnv') new.
+    ^ (JAVA stx libjava tools LibjavaCompilerEnv) new.
 
     "Created: / 02-04-2012 / 13:18:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
@@ -113,41 +114,22 @@
 compilerOptions
     ^ (Java classForName: 'org.eclipse.jdt.internal.compiler.impl.CompilerOptions') new.
 
-    "Modified (format): / 02-04-2012 / 13:20:16 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
-!
-
-initCompiler: compilationUnit 
-    | compiler  compEnv  policy  options  requestor  problemFactory |
-    compEnv := nil.
-    policy := self policy.
-    options := self compilerOptions.
-    requestor := self compilationResultFor: compilationUnit.
-    problemFactory := self problemFactory.
-    compiler := ECJCompilerClass 
-            new: compEnv
-            with: policy
-            with: options
-            with: requestor
-            with: problemFactory.
-            ^ compiler.
-
-    "Created: / 02-04-2012 / 13:16:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 03-04-2012 / 12:40:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 policy
-    ^ (Java 
-        classForName: 'org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies') 
-            exitOnFirstError.
+    ^ (Java classForName: 'org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies') 
+        exitOnFirstError.
 
-    "Modified (format): / 02-04-2012 / 13:19:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 03-04-2012 / 12:39:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
 problemFactory
-    ^ (Java 
-        classForName: 'org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory') 
+    ^ (JAVA
+        org eclipse jdt internal compiler problem DefaultProblemFactory) 
             new.
 
-    "Modified (format): / 02-04-2012 / 13:19:24 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
+    "Modified: / 03-04-2012 / 12:27:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaCompiler_Eclipse class methodsFor:'documentation'!
--- a/src/JavaLookup.st	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/JavaLookup.st	Tue Apr 03 12:02:05 2012 +0000
@@ -636,6 +636,7 @@
 
         cls := arg class.
         candidates := candidates select:[:m|
+self breakPoint:#mh.
             self type: cls matches: (m descriptor parameters at: index) javaClass
         ].
     ].
@@ -650,28 +651,23 @@
     self halt: 'Unfinished - ambiguous'
 
     "Created: / 03-01-2012 / 21:40:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-04-2012 / 13:59:13 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 !
 
-type: actual matches: formal
+type: actual matches: formal 
     "Return true, if actual (parameter) type matches given formal (parameter) type"
 
-    formal isJavaPrimitiveType ifTrue:[
-        ^ actual == formal.
+    formal isJavaPrimitiveType ifTrue: [ ^ actual == formal. ].
+    actual isJavaPrimitiveType ifTrue: [
+        ^ formal isJavaWrapperClass and: [ formal javaWrapperClass == actual. ]
     ].
-
-    actual isJavaPrimitiveType ifTrue:[
-        ^ formal isJavaWrapperClass and:[
-            formal javaWrapperClass == actual.
-        ]
+    (actual includesBehavior: String "care about multi-byte strings") ifTrue: [
+        ^ formal name == #'java/lang/String'
     ].
-
-    (actual includesBehavior: String)"care about multi-byte strings" ifTrue:[
-        ^formal name == #'java/lang/String'
-    ].
-
-    ^JavaVM canCast: actual to: formal
+    ^ JavaVM canCast: actual to: formal
 
     "Created: / 03-01-2012 / 22:36:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-04-2012 / 13:59:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
 ! !
 
 !JavaLookup::Smalltalk2Java methodsFor:'utilities (old)'!
--- a/src/Make.proto	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/Make.proto	Tue Apr 03 12:02:05 2012 +0000
@@ -1,7 +1,7 @@
 # $Header$
 #
 # DO NOT EDIT
-# automagically generated from the projectDefinition: stx_libjava at 2012-04-02 13:24:06.262.
+# automagically generated from the projectDefinition: stx_libjava at 2012-04-03 14:02:35.220.
 #
 # Warning: once you modify this file, do not rerun
 # stmkmp or projectDefinition-build again - otherwise, your changes are lost.
--- a/src/Make.spec	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/Make.spec	Tue Apr 03 12:02:05 2012 +0000
@@ -1,7 +1,7 @@
 # $Header$
 #
 # DO NOT EDIT
-# automagically generated from the projectDefinition: stx_libjava at 2012-04-02 13:24:05.549.
+# automagically generated from the projectDefinition: stx_libjava at 2012-04-03 14:02:34.485.
 #
 # Warning: once you modify this file, do not rerun
 # stmkmp or projectDefinition-build again - otherwise, your changes are lost.
--- a/src/abbrev.stc	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/abbrev.stc	Tue Apr 03 12:02:05 2012 +0000
@@ -141,4 +141,5 @@
 ProxyMethodJavaFieldGetter ProxyMethodJavaFieldGetter stx:libjava 'Languages-Java-Interop' 0
 ProxyMethodJavaFieldSetter ProxyMethodJavaFieldSetter stx:libjava 'Languages-Java-Interop' 0
 JavaExceptionTests JavaExceptionTests stx:libjava 'Languages-Java-Tests' 1
+JavaCompilerTests JavaCompilerTests stx:libjava 'Languages-Java-Tools-Tests' 1
 JavaCompiler_Eclipse JavaCompiler_Eclipse stx:libjava 'Languages-Java-Tools-Eclipse' 0
--- a/src/bc.mak	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/bc.mak	Tue Apr 03 12:02:05 2012 +0000
@@ -1,7 +1,7 @@
 # $Header$
 #
 # DO NOT EDIT
-# automagically generated from the projectDefinition: stx_libjava at 2012-04-02 13:24:06.679.
+# automagically generated from the projectDefinition: stx_libjava at 2012-04-03 14:02:35.732.
 #
 # Warning: once you modify this file, do not rerun
 # stmkmp or projectDefinition-build again - otherwise, your changes are lost.
--- a/src/libjava.rc	Mon Apr 02 17:43:24 2012 +0000
+++ b/src/libjava.rc	Tue Apr 03 12:02:05 2012 +0000
@@ -25,7 +25,7 @@
       VALUE "LegalCopyright", "Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011\nCopyright Jan Vrany, Jan Kurs and Marcel Hlopko\b          SWING Research Group, Czech Technical University In Prague\0"
       VALUE "ProductName", "Smalltalk/X\0"
       VALUE "ProductVersion", "6.2.1.1\0"
-      VALUE "ProductDate", "Mon, 02 Apr 2012 11:24:10 GMT\0"
+      VALUE "ProductDate", "Tue, 03 Apr 2012 12:02:40 GMT\0"
     END
 
   END