mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-25 06:18:05 +02:00
Java-Bytecode und X10
This commit is contained in:
parent
d5ad212703
commit
50080ddea9
8 changed files with 503 additions and 6 deletions
|
@ -14,7 +14,7 @@ Bytecode ist unabhängig von realer Hardware.
|
||||||
\end{definition}
|
\end{definition}
|
||||||
|
|
||||||
\textit{Activation Record} ist ein \textit{Stackframe}.\index{Activation Record|see{Stackframe}}
|
\textit{Activation Record} ist ein \textit{Stackframe}.\index{Activation Record|see{Stackframe}}
|
||||||
\section{Instruktionen}
|
\section{Instruktionen}\xindex{imul@\texttt{imul}}\xindex{iadd@\texttt{iadd}}\xindex{fadd@\texttt{fadd}}\xindex{iaload@\texttt{iaload}}\xindex{faload@\texttt{faload}}\xindex{iastore@\texttt{iastore}}\xindex{fastore@\texttt{fastore}}\xindex{iconst\_<i>@\texttt{iconst\_<i>}}\xindex{fconst\_<f>@\texttt{fconst\_<f>}}\xindex{idiv@\texttt{idiv}}\xindex{fdiv@\texttt{fdiv}}\xindex{imul@\texttt{imul}}%
|
||||||
\begin{table}[h]
|
\begin{table}[h]
|
||||||
\begin{tabular}{p{6cm}|ll}
|
\begin{tabular}{p{6cm}|ll}
|
||||||
\textbf{Beschreibung} & \textbf{int} & \textbf{float} \\ \hline
|
\textbf{Beschreibung} & \textbf{int} & \textbf{float} \\ \hline
|
||||||
|
@ -27,6 +27,62 @@ Bytecode ist unabhängig von realer Hardware.
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\end{table}
|
\end{table}
|
||||||
|
|
||||||
|
Weitere:\xindex{iload\_0@\texttt{iload\_0}}%
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \texttt{iload\_0}: Läd die lokale Variable 0 auf den Stack.
|
||||||
|
\item \texttt{iload\_1}: Läd die lokale Variable 1 auf den Stack.
|
||||||
|
\item \texttt{iload\_2}: Läd die lokale Variable 2 auf den Stack.
|
||||||
|
\item \texttt{iload\_3}: Läd die lokale Variable 3 auf den Stack.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\subsection{if-Abfragen}\xindex{if\_icmp<comperator>@\texttt{if\_icmp<comperator>}}%
|
||||||
|
Im Java-Bytecode gibt es einige verschiedene if-Abfragen. Diese sind immer nach
|
||||||
|
dem Schema \texttt{<if> <label>} aufgebaut. Wenn also \texttt{<if>} wahr ist,
|
||||||
|
wird zu \texttt{<label>} gesprungen.
|
||||||
|
|
||||||
|
Im Folgenden sei $a$ tiefer im Stack als $b$. Die Operation \texttt{push(a)} wurde also
|
||||||
|
vor \texttt{push(b)} durchgeführt.
|
||||||
|
|
||||||
|
Eine Gruppe von if-Abfragen hat folgendes Schema:
|
||||||
|
|
||||||
|
\begin{center}
|
||||||
|
\texttt{if\_icmp<comperator> <label>}
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
Dabei steht das erste \texttt{i} für \enquote{integer} und \texttt{cmp} für
|
||||||
|
\enquote{compare}. \texttt{<comperator>} kann folgende Werte annehmen:
|
||||||
|
|
||||||
|
\xindex{eq@\texttt{eq}}\xindex{ge@\texttt{ge}}\xindex{gt@\texttt{gt}}\xindex{le@\texttt{le}}
|
||||||
|
\xindex{lt@\texttt{lt}}\xindex{ne@\texttt{ne}}%
|
||||||
|
\begin{itemize}
|
||||||
|
\item \texttt{eq}: equal -- $a == b$
|
||||||
|
\item \texttt{ge}: greater equal -- $a \ge b$
|
||||||
|
\item \texttt{gt}: greater than -- $a > b$
|
||||||
|
\item \texttt{le}: less equal -- $a \le b$
|
||||||
|
\item \texttt{lt}: less than -- $a < b$
|
||||||
|
\item \texttt{ne}: not equal -- $a \neq b$
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
Weitere if-Abfragen haben das Schema
|
||||||
|
|
||||||
|
\begin{center}
|
||||||
|
\texttt{if<comperator>} -- $b \text{\texttt{<comperator>}} 0$
|
||||||
|
\end{center}
|
||||||
|
|
||||||
|
\subsection{Konstanten}\xindex{iconst\_<i>@\texttt{iconst\_<i>}}\xindex{iconst\_m1@\texttt{iconst\_m1}}%
|
||||||
|
\begin{itemize}
|
||||||
|
\item \texttt{iconst\_m1}: Lade -1 auf den Stack
|
||||||
|
\item \texttt{iconst\_<i>}, wobei \texttt{<i>} die Werte 0, 1, 2, 3, 4, 5
|
||||||
|
annehmen kann.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\xindex{aload\_<i>@\texttt{aload\_<i>}}
|
||||||
|
\begin{itemize}
|
||||||
|
\item \texttt{aload\_<i>} wobei \texttt{<i>} entweder 0, 1, 2 oder 3 ist: Lade eine
|
||||||
|
Referenz von einer lokalen Variable \texttt{<i>} auf den Stack.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
\section{Polnische Notation}
|
\section{Polnische Notation}
|
||||||
\begin{definition}[Schreibweise von Rechenoperationen]
|
\begin{definition}[Schreibweise von Rechenoperationen]
|
||||||
Sei $f: A \times B \rightarrow C$ eine Funktion, $a \in A$ und $b \in B$.
|
Sei $f: A \times B \rightarrow C$ eine Funktion, $a \in A$ und $b \in B$.
|
||||||
|
@ -75,6 +131,7 @@ Bytecode ist unabhängig von realer Hardware.
|
||||||
|
|
||||||
\section{Weitere Informationen}
|
\section{Weitere Informationen}
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
|
\item \url{https://en.wikipedia.org/wiki/Java_bytecode_instruction_listings}
|
||||||
\item \url{http://cs.au.dk/~mis/dOvs/jvmspec/ref-Java.html}
|
\item \url{http://cs.au.dk/~mis/dOvs/jvmspec/ref-Java.html}
|
||||||
\item \href{http://scanftree.com/Data_Structure/prefix-postfix-infix-online-converter}{scanftree.com}:
|
\item \href{http://scanftree.com/Data_Structure/prefix-postfix-infix-online-converter}{scanftree.com}:
|
||||||
Infix $\leftrightarrow$ Postfix Konverter
|
Infix $\leftrightarrow$ Postfix Konverter
|
||||||
|
|
Binary file not shown.
|
@ -90,6 +90,14 @@ die Klasse.
|
||||||
|
|
||||||
Das folgende Wetter-Beispiel zeigt, wie man Aktoren benutzen kann.
|
Das folgende Wetter-Beispiel zeigt, wie man Aktoren benutzen kann.
|
||||||
|
|
||||||
|
\subsection{Message Passing}\xindex{! (Scala)}%
|
||||||
|
Prozesse können nach dem Schema \texttt{adresse ! Nachricht} Nachrichten austauschen.
|
||||||
|
Dieses Schema ist asynchron.
|
||||||
|
|
||||||
|
Prozesse können mit \texttt{receive{case x => print(x)}} Nachrichten empfangen,
|
||||||
|
wobei in diesem Beispiel \texttt{x} alles matcht. Wenn eine gesendete Nachricht
|
||||||
|
vom Empfänger nicht gematcht wird, bleibt sie dennoch gespeichert.
|
||||||
|
|
||||||
\section{Weiteres}
|
\section{Weiteres}
|
||||||
\texttt{def awaitAll(timeout: Long, fts: Future[Any]*):}\\
|
\texttt{def awaitAll(timeout: Long, fts: Future[Any]*):}\\
|
||||||
\-\hspace{1.8cm}\texttt{List[Option[Any]]}\xindex{awaitAll}\\
|
\-\hspace{1.8cm}\texttt{List[Option[Any]]}\xindex{awaitAll}\\
|
||||||
|
|
|
@ -23,8 +23,11 @@ und Objekte.
|
||||||
|
|
||||||
\begin{itemize}
|
\begin{itemize}
|
||||||
\item \texttt{Place.FIRST\_PLACE} ist der place 0.
|
\item \texttt{Place.FIRST\_PLACE} ist der place 0.
|
||||||
\item \texttt{here} ist der Prozess-eigene place.
|
\item \texttt{here} ist der Prozess-eigene place und \texttt{here.next()} ist
|
||||||
|
der darauf folgende Place.
|
||||||
\item \texttt{main} wird in \texttt{place 0} ausgeführt.
|
\item \texttt{main} wird in \texttt{place 0} ausgeführt.
|
||||||
|
\item \texttt{Place.places()} liefert einen Iterator für alle verfügbaren places.
|
||||||
|
Ein spezifischer Place kann durch \texttt{Place(n)} ausgewählt werden.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\section{Erste Schritte}
|
\section{Erste Schritte}
|
||||||
|
@ -64,6 +67,33 @@ Methoden können atomar gemacht werden.
|
||||||
|
|
||||||
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/x10/atomic-example.x10}
|
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/x10/atomic-example.x10}
|
||||||
|
|
||||||
|
\subsection[Bedingtes Warten]{Bedingtes Warten\footnote{WS 2013/2014, Kapitel 43, Folie 22}}\xindex{when}%
|
||||||
|
Durch \texttt{when (E) S} kann eine Aktivität warten, bis die Bedingung \texttt{E}
|
||||||
|
wahr ist um dann das Statement \texttt{S} auszuführen.
|
||||||
|
|
||||||
|
An \texttt{E} werden einige Forderungen gestellt:
|
||||||
|
|
||||||
|
\begin{itemize}
|
||||||
|
\item \texttt{E} muss ein boolescher Ausdruck sein.
|
||||||
|
\item \texttt{E} darf nicht blockieren.
|
||||||
|
\item \texttt{E} darf keine nebenläufigen Aktivitäten erstellen, muss also
|
||||||
|
sequenziell laufen.
|
||||||
|
\item \texttt{E} darf nicht auf \textit{remote data} zugreifen, muss also
|
||||||
|
lokal arbeiten.
|
||||||
|
\item \texttt{E} muss frei von Seiteneffekten sein.
|
||||||
|
\end{itemize}
|
||||||
|
|
||||||
|
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/x10/when-example.x10}
|
||||||
|
|
||||||
|
\subsection{Lokalisierung}\footnote{WS 2013/2014, Kapitel 43, Folie 23}\xindex{at}%
|
||||||
|
Durch \texttt{at (p) S} wird sichergestellt, dass das Statement \texttt{S} auf
|
||||||
|
dem place \texttt{p} ausgeführt wird. Dabei ist zu beachten, dass die Eltern-Aktivität
|
||||||
|
so lange blockiert, bis \texttt{S} beendet.
|
||||||
|
|
||||||
|
Es wird eine Deep-Copy des lokalen Objektgraphen auf den place \texttt{p} erstellt.
|
||||||
|
|
||||||
|
\inputminted[numbersep=5pt, tabsize=4]{scala}{scripts/x10/at-example.x10}
|
||||||
|
|
||||||
\section{Datentypen}
|
\section{Datentypen}
|
||||||
Byte, UByte, Short, UShort, Char, Int, UInt, Long, ULong, Float, Double, Boolean,
|
Byte, UByte, Short, UShort, Char, Int, UInt, Long, ULong, Float, Double, Boolean,
|
||||||
Complex, String, Point, Region, Dist, Array
|
Complex, String, Point, Region, Dist, Array
|
||||||
|
|
376
documents/Programmierparadigmen/scripts/x10/Fibonacci.java
Normal file
376
documents/Programmierparadigmen/scripts/x10/Fibonacci.java
Normal file
|
@ -0,0 +1,376 @@
|
||||||
|
@x10.runtime.impl.java.X10Generated
|
||||||
|
public class Fibonacci extends x10.core.Ref implements x10.serialization.X10JavaSerializable
|
||||||
|
{
|
||||||
|
public static final x10.rtt.RuntimeType<Fibonacci> $RTT =
|
||||||
|
x10.rtt.NamedType.<Fibonacci> make("Fibonacci",
|
||||||
|
Fibonacci.class);
|
||||||
|
|
||||||
|
public x10.rtt.RuntimeType<?> $getRTT() { return $RTT; }
|
||||||
|
|
||||||
|
public x10.rtt.Type<?> $getParam(int i) { return null; }
|
||||||
|
|
||||||
|
public static x10.serialization.X10JavaSerializable $_deserialize_body(Fibonacci $_obj, x10.serialization.X10JavaDeserializer $deserializer) throws java.io.IOException {
|
||||||
|
if (x10.runtime.impl.java.Runtime.TRACE_SER) { x10.runtime.impl.java.Runtime.printTraceMessage("X10JavaSerializable: $_deserialize_body() of " + Fibonacci.class + " calling"); }
|
||||||
|
return $_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static x10.serialization.X10JavaSerializable $_deserializer(x10.serialization.X10JavaDeserializer $deserializer) throws java.io.IOException {
|
||||||
|
Fibonacci $_obj = new Fibonacci((java.lang.System[]) null);
|
||||||
|
$deserializer.record_reference($_obj);
|
||||||
|
return $_deserialize_body($_obj, $deserializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void $_serialize(x10.serialization.X10JavaSerializer $serializer) throws java.io.IOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor just for allocation
|
||||||
|
public Fibonacci(final java.lang.System[] $dummy) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#line 3 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
public static long fib$O(final long n) {
|
||||||
|
|
||||||
|
//#line 4 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final boolean t$121 = ((n) < (((long)(2L))));
|
||||||
|
|
||||||
|
//#line 4 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
if (t$121) {
|
||||||
|
|
||||||
|
//#line 5 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#line 8 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long f1;
|
||||||
|
|
||||||
|
//#line 9 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long f2;
|
||||||
|
{
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
x10.lang.Runtime.ensureNotInAtomic();
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final x10.lang.FinishState x10$__var0 = x10.lang.Runtime.startFinish();
|
||||||
|
{
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long[] $f1$158 = new long[1];
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long[] $f2$159 = new long[1];
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
try {{
|
||||||
|
{
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
x10.lang.Runtime.runAsync(((x10.core.fun.VoidFun_0_0)(new Fibonacci.$Closure$0(n, $f1$158))));
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
x10.lang.Runtime.runAsync(((x10.core.fun.VoidFun_0_0)(new Fibonacci.$Closure$1(n, $f2$159))));
|
||||||
|
}
|
||||||
|
}}catch (java.lang.Throwable __lowerer__var__0__) {
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
x10.lang.Runtime.pushException(((java.lang.Throwable)(__lowerer__var__0__)));
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
throw new java.lang.RuntimeException();
|
||||||
|
}finally {{
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
x10.lang.Runtime.stopFinish(((x10.lang.FinishState)(x10$__var0)));
|
||||||
|
}}
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
f1 = ((long)$f1$158[(int)0]);
|
||||||
|
|
||||||
|
//#line 10 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
f2 = ((long)$f2$159[(int)0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//#line 14 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$126 = ((f1) + (((long)(f2))));
|
||||||
|
|
||||||
|
//#line 14 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
return t$126;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//#line 17 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
public static class $Main extends x10.runtime.impl.java.Runtime
|
||||||
|
{
|
||||||
|
// java main method
|
||||||
|
public static void main(java.lang.String[] args) {
|
||||||
|
// start native runtime
|
||||||
|
new $Main().start(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
// called by native runtime inside main x10 thread
|
||||||
|
public void runtimeCallback(final x10.core.Rail<java.lang.String> args) {
|
||||||
|
// call the original app-main method
|
||||||
|
Fibonacci.main(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the original app-main method
|
||||||
|
public static void main(final x10.core.Rail<java.lang.String> args) {
|
||||||
|
|
||||||
|
//#line 18 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final x10.io.Printer t$127 = ((x10.io.Printer)(x10.io.Console.get$OUT()));
|
||||||
|
|
||||||
|
//#line 18 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
t$127.println(((java.lang.Object)("This is fibonacci in X10.")));
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
long i$147 = 0L;
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
for (;
|
||||||
|
true;
|
||||||
|
) {
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$148 = i$147;
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final boolean t$149 = ((t$148) < (((long)(10L))));
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
if (!(t$149)) {
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final x10.io.Printer t$139 = ((x10.io.Printer)(x10.io.Console.get$OUT()));
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$140 = i$147;
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final java.lang.String t$141 = (((x10.core.Long.$box(t$140))) + (": "));
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$142 = i$147;
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$143 = Fibonacci.fib$O((long)(t$142));
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final java.lang.String t$144 = ((t$141) + ((x10.core.Long.$box(t$143))));
|
||||||
|
|
||||||
|
//#line 20 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
t$139.println(((java.lang.Object)(t$144)));
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$145 = i$147;
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$146 = ((t$145) + (((long)(1L))));
|
||||||
|
|
||||||
|
//#line 19 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
i$147 = t$146;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//#line 2 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final public Fibonacci Fibonacci$$this$Fibonacci() {
|
||||||
|
|
||||||
|
//#line 2 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
return Fibonacci.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//#line 2 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
// creation method for java code (1-phase java constructor)
|
||||||
|
public Fibonacci() {
|
||||||
|
this((java.lang.System[]) null);
|
||||||
|
Fibonacci$$init$S();
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor for non-virtual call
|
||||||
|
final public Fibonacci Fibonacci$$init$S() {
|
||||||
|
{
|
||||||
|
|
||||||
|
//#line 2 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
|
||||||
|
|
||||||
|
//#line 2 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
this.__fieldInitializers_Fibonacci();
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#line 2 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final public void __fieldInitializers_Fibonacci() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@x10.runtime.impl.java.X10Generated
|
||||||
|
final public static class $Closure$0 extends x10.core.Ref implements x10.core.fun.VoidFun_0_0, x10.serialization.X10JavaSerializable
|
||||||
|
{
|
||||||
|
public static final x10.rtt.RuntimeType<$Closure$0> $RTT =
|
||||||
|
x10.rtt.StaticVoidFunType.<$Closure$0> make($Closure$0.class,
|
||||||
|
new x10.rtt.Type[] {
|
||||||
|
x10.core.fun.VoidFun_0_0.$RTT
|
||||||
|
});
|
||||||
|
|
||||||
|
public x10.rtt.RuntimeType<?> $getRTT() { return $RTT; }
|
||||||
|
|
||||||
|
public x10.rtt.Type<?> $getParam(int i) { return null; }
|
||||||
|
|
||||||
|
public static x10.serialization.X10JavaSerializable $_deserialize_body(Fibonacci.$Closure$0 $_obj, x10.serialization.X10JavaDeserializer $deserializer) throws java.io.IOException {
|
||||||
|
if (x10.runtime.impl.java.Runtime.TRACE_SER) { x10.runtime.impl.java.Runtime.printTraceMessage("X10JavaSerializable: $_deserialize_body() of " + $Closure$0.class + " calling"); }
|
||||||
|
$_obj.n = $deserializer.readLong();
|
||||||
|
$_obj.$f1$158 = $deserializer.readObject();
|
||||||
|
return $_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static x10.serialization.X10JavaSerializable $_deserializer(x10.serialization.X10JavaDeserializer $deserializer) throws java.io.IOException {
|
||||||
|
Fibonacci.$Closure$0 $_obj = new Fibonacci.$Closure$0((java.lang.System[]) null);
|
||||||
|
$deserializer.record_reference($_obj);
|
||||||
|
return $_deserialize_body($_obj, $deserializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void $_serialize(x10.serialization.X10JavaSerializer $serializer) throws java.io.IOException {
|
||||||
|
$serializer.write(this.n);
|
||||||
|
$serializer.write(this.$f1$158);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor just for allocation
|
||||||
|
public $Closure$0(final java.lang.System[] $dummy) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void $apply() {
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
try {{
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$122 = ((this.n) - (((long)(1L))));
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$123 = Fibonacci.fib$O((long)(t$122));
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
this.$f1$158[(int)0]=t$123;
|
||||||
|
}}catch (java.lang.Error __lowerer__var__0__) {
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
throw __lowerer__var__0__;
|
||||||
|
}catch (java.lang.Throwable __lowerer__var__1__) {
|
||||||
|
|
||||||
|
//#line 11 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
throw x10.rtt.Types.EXCEPTION.isInstance(__lowerer__var__1__) ? (java.lang.RuntimeException)(__lowerer__var__1__) : new x10.lang.WrappedThrowable(__lowerer__var__1__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long n;
|
||||||
|
public long[] $f1$158;
|
||||||
|
|
||||||
|
public $Closure$0(final long n, final long[] $f1$158) {
|
||||||
|
{
|
||||||
|
this.n = n;
|
||||||
|
this.$f1$158 = $f1$158;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@x10.runtime.impl.java.X10Generated
|
||||||
|
final public static class $Closure$1 extends x10.core.Ref implements x10.core.fun.VoidFun_0_0, x10.serialization.X10JavaSerializable
|
||||||
|
{
|
||||||
|
public static final x10.rtt.RuntimeType<$Closure$1> $RTT =
|
||||||
|
x10.rtt.StaticVoidFunType.<$Closure$1> make($Closure$1.class,
|
||||||
|
new x10.rtt.Type[] {
|
||||||
|
x10.core.fun.VoidFun_0_0.$RTT
|
||||||
|
});
|
||||||
|
|
||||||
|
public x10.rtt.RuntimeType<?> $getRTT() { return $RTT; }
|
||||||
|
|
||||||
|
public x10.rtt.Type<?> $getParam(int i) { return null; }
|
||||||
|
|
||||||
|
public static x10.serialization.X10JavaSerializable $_deserialize_body(Fibonacci.$Closure$1 $_obj, x10.serialization.X10JavaDeserializer $deserializer) throws java.io.IOException {
|
||||||
|
if (x10.runtime.impl.java.Runtime.TRACE_SER) { x10.runtime.impl.java.Runtime.printTraceMessage("X10JavaSerializable: $_deserialize_body() of " + $Closure$1.class + " calling"); }
|
||||||
|
$_obj.n = $deserializer.readLong();
|
||||||
|
$_obj.$f2$159 = $deserializer.readObject();
|
||||||
|
return $_obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static x10.serialization.X10JavaSerializable $_deserializer(x10.serialization.X10JavaDeserializer $deserializer) throws java.io.IOException {
|
||||||
|
Fibonacci.$Closure$1 $_obj = new Fibonacci.$Closure$1((java.lang.System[]) null);
|
||||||
|
$deserializer.record_reference($_obj);
|
||||||
|
return $_deserialize_body($_obj, $deserializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void $_serialize(x10.serialization.X10JavaSerializer $serializer) throws java.io.IOException {
|
||||||
|
$serializer.write(this.n);
|
||||||
|
$serializer.write(this.$f2$159);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// constructor just for allocation
|
||||||
|
public $Closure$1(final java.lang.System[] $dummy) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void $apply() {
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
try {{
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$124 = ((this.n) - (((long)(2L))));
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
final long t$125 = Fibonacci.fib$O((long)(t$124));
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
this.$f2$159[(int)0]=t$125;
|
||||||
|
}}catch (java.lang.Error __lowerer__var__2__) {
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
throw __lowerer__var__2__;
|
||||||
|
}catch (java.lang.Throwable __lowerer__var__3__) {
|
||||||
|
|
||||||
|
//#line 12 "/home/moose/Downloads/LaTeX-examples/documents/Programmierparadigmen/scripts/x10/Fibonacci.x10"
|
||||||
|
throw x10.rtt.Types.EXCEPTION.isInstance(__lowerer__var__3__) ? (java.lang.RuntimeException)(__lowerer__var__3__) : new x10.lang.WrappedThrowable(__lowerer__var__3__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long n;
|
||||||
|
public long[] $f2$159;
|
||||||
|
|
||||||
|
public $Closure$1(final long n, final long[] $f2$159) {
|
||||||
|
{
|
||||||
|
this.n = n;
|
||||||
|
this.$f2$159 = $f2$159;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// file Fibonacci.x10
|
// file Fibonacci.x10
|
||||||
public class Fibonacci {
|
public class Fibonacci {
|
||||||
public static def fib(n:Int): Int {
|
public static def fib(n:Long): Long {
|
||||||
if (n < 2) {
|
if (n < 2) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
val f1:Int;
|
val f1:Long;
|
||||||
val f2:Int;
|
val f2:Long;
|
||||||
finish {
|
finish {
|
||||||
async f1 = fib(n-1);
|
async f1 = fib(n-1);
|
||||||
async f2 = fib(n-2);
|
async f2 = fib(n-2);
|
||||||
|
@ -16,7 +16,7 @@ public class Fibonacci {
|
||||||
|
|
||||||
public static def main(args:Rail[String]) {
|
public static def main(args:Rail[String]) {
|
||||||
x10.io.Console.OUT.println("This is fibonacci in X10.");
|
x10.io.Console.OUT.println("This is fibonacci in X10.");
|
||||||
for (var i:Int=0; i < 10; ++i) {
|
for (var i:Long=0; i < 10; ++i) {
|
||||||
x10.io.Console.OUT.println(i + ": " + fib(i));
|
x10.io.Console.OUT.println(i + ": " + fib(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
at (Place(1)) { ... }
|
||||||
|
|
||||||
|
val a:Int = 42;
|
||||||
|
|
||||||
|
at (here.next()) {
|
||||||
|
Console.OUT.println(here);
|
||||||
|
Console.OUT.println(a);
|
||||||
|
}
|
18
documents/Programmierparadigmen/scripts/x10/when-example.x10
Normal file
18
documents/Programmierparadigmen/scripts/x10/when-example.x10
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
class OneBuffer {
|
||||||
|
var datum:Object = null;
|
||||||
|
var filled:Boolean = false;
|
||||||
|
def send(v:Object) {
|
||||||
|
when (!filled) {
|
||||||
|
datum = v;
|
||||||
|
filled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def receive():Object {
|
||||||
|
when (filled) {
|
||||||
|
val v = datum;
|
||||||
|
datum = null;
|
||||||
|
filled = false;
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue