summaryrefslogtreecommitdiff
path: root/tutorial/examples/verbose2
diff options
context:
space:
mode:
authorKenny Ballou <kballou@devnulllabs.io>2018-11-19 22:59:50 -0700
committerKenny Ballou <kballou@devnulllabs.io>2018-11-19 22:59:50 -0700
commitea3e1b949dcbdc09518f17eee0bcf21d41d76896 (patch)
tree7ec7a7fb4df67815a9b7bb0e4d95d67c4050e2a2 /tutorial/examples/verbose2
downloadopenjava-ea3e1b949dcbdc09518f17eee0bcf21d41d76896.tar.gz
openjava-ea3e1b949dcbdc09518f17eee0bcf21d41d76896.tar.xz
OJ (aka OpenJava) modernization/mirroring
Signed-off-by: Kenny Ballou <kballou@devnulllabs.io>
Diffstat (limited to 'tutorial/examples/verbose2')
-rw-r--r--tutorial/examples/verbose2/Test.java98
-rw-r--r--tutorial/examples/verbose2/Test.oj73
-rw-r--r--tutorial/examples/verbose2/VerboseClass.java50
3 files changed, 221 insertions, 0 deletions
diff --git a/tutorial/examples/verbose2/Test.java b/tutorial/examples/verbose2/Test.java
new file mode 100644
index 0000000..50848fb
--- /dev/null
+++ b/tutorial/examples/verbose2/Test.java
@@ -0,0 +1,98 @@
+/*
+ * This code was generated by ojc.
+ */
+package examples.verbose2;
+
+
+import java.awt.Panel;
+import java.util.*;
+import java.io.PrintStream;
+
+
+public class Test extends Panel
+{
+
+ private int iii = 0;
+
+ private Test n = null;
+
+ private String str = "string";
+
+ public Test()
+ {
+ super();
+ }
+
+ /**
+ * @param
+ * @return
+ * @exception
+ * @see java.lang.Object
+ */
+ public static void main( String[] argv )
+ {
+ java.lang.System.out.println( "main is called." );
+ PrintStream out = System.out;
+ PrintStream error = java.lang.System.err;
+ out.println( "Hello" + " " + "World" );
+ Test n = new Test();
+ java.lang.System.err.println( "done. " );
+ Test test = new Test();
+ test.hoge();
+ test.foo();
+ }
+
+ public void hoge()
+ {
+ java.lang.System.out.println( "hoge is called." );
+ Local l = new Local();
+ System.out.println( l.foo );
+ System.out.println( l.bar.str );
+ }
+
+ public Test( String str )
+ {
+ this.str = str;
+ n = null;
+ }
+
+ public int foo()
+ {
+ java.lang.System.out.println( "foo is called." );
+ return iii;
+ }
+
+ public String toString()
+ {
+ java.lang.System.out.println( "toString is called." );
+ if (n == null) {
+ return str;
+ }
+ return str + n;
+ }
+
+}
+
+
+class Local
+{
+
+ String foo = null;
+
+ Local2 bar = new Local2();
+
+ public final String getFoo( Integer i )
+ {
+ java.lang.System.out.println( "getFoo is called." );
+ return foo;
+ }
+
+}
+
+
+class Local2
+{
+
+ String str = "" + "TEST";
+
+}
diff --git a/tutorial/examples/verbose2/Test.oj b/tutorial/examples/verbose2/Test.oj
new file mode 100644
index 0000000..c882183
--- /dev/null
+++ b/tutorial/examples/verbose2/Test.oj
@@ -0,0 +1,73 @@
+package examples.verbose2;
+
+
+import java.awt.Panel;
+import java.util.*;
+import java.io.PrintStream;
+
+
+public class Test instantiates VerboseClass
+ extends Panel
+{
+ private int iii = 0;
+
+ private Test n = null;
+
+ private String str = "string";
+
+ public Test() {
+ super();
+ }
+
+ /**
+ * @param
+ * @return
+ * @exception
+ * @see java.lang.Object
+ */
+ public static void main( String[] argv ) {
+ PrintStream out = System.out;
+ PrintStream error = java.lang.System.err;
+ out.println( "Hello" + " " + "World" );
+ Test n = new Test();
+ java.lang.System.err.println( "done. " );
+ Test test = new Test();
+ test.hoge();
+ test.foo();
+ }
+
+ public void hoge() {
+ Local l = new Local();
+ System.out.println( l.foo );
+ System.out.println( l.bar.str );
+ }
+
+ public Test( String str ) {
+ this.str = str;
+ n = null;
+ }
+
+ public int foo() {
+ return iii;
+ }
+
+ public String toString() {
+ if (n == null) return str;
+ return str + n;
+ }
+
+}
+
+class Local instantiates VerboseClass
+{
+ String foo = null;
+ Local2 bar = new Local2();
+ public final String getFoo( Integer i ) {
+ return foo;
+ }
+}
+
+class Local2
+{
+ String str = "" + "TEST";
+}
diff --git a/tutorial/examples/verbose2/VerboseClass.java b/tutorial/examples/verbose2/VerboseClass.java
new file mode 100644
index 0000000..1e6cdf0
--- /dev/null
+++ b/tutorial/examples/verbose2/VerboseClass.java
@@ -0,0 +1,50 @@
+/*
+ * VerboseClass.java
+ *
+ * comments here.
+ *
+ * @author Michiaki Tatsubori
+ * @version %VERSION% %DATE%
+ * @see java.lang.Object
+ *
+ * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
+ */
+package examples.verbose2;
+
+
+import openjava.mop.*;
+import openjava.ptree.*;
+import openjava.syntax.*;
+import openjava.ptree.util.PartialParser;
+
+
+public class VerboseClass extends OJClass
+{
+
+ /* overrides for translation */
+ public void translateDefinition() throws MOPException {
+ OJMethod[] methods = getDeclaredMethods();
+ for (int i = 0; i < methods.length; ++i) {
+ StatementList body = methods[i].getBody();
+ String str = PartialParser.replace(
+ "java.lang.System.out.println( \"#s\" );",
+ methods[i].getName() + " is called."
+ );
+ Statement printer = makeStatement( str );
+ body.insertElementAt( printer, 0 );
+ }
+ }
+
+ /* constructor */
+
+ public VerboseClass( Environment outer_env, OJClass declarer,
+ ClassDeclaration ptree ) {
+ super( outer_env, declarer, ptree );
+ }
+
+ public VerboseClass( Class javaclass, MetaInfo minfo ) {
+ super( javaclass, minfo );
+ }
+
+}
+