• Keine Ergebnisse gefunden

TU Kaiserslautern

N/A
N/A
Protected

Academic year: 2022

Aktie "TU Kaiserslautern"

Copied!
1
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Dr. Annette Bieniusa M.Sc. Peter Zeller

TU Kaiserslautern

Fachbereich Informatik AG Softwaretechnik

Lab 5: Compiler and Language Processing Tools (WS 2018)

Deadline: 22.01.2019, 10:00

1 Translation of Object-oriented constructs (12 points)

Extend your MiniJava to miniLLVM translator with the translation of object oriented constructs. With this step you will have a complete compiler for the MiniJava language.

This exercise is a continuation of exercise 4, so no new material is provided. The material in ex4_material.zip already contains test-inputs with classes in

testdata/translation/classes/.

Hints:

1. Translate method calls to procedure calls, where the address of the procedure is read from the virtual method table of the receiver object.

2. Generate a struct type for every class. The struct type should have a reference to the virtual method table as the first field. Additionally, it should include fields for all the fields from the Java class. Remember that the order of fields is important and that the memory layout of classes has to be compatible with the memory layout of their super-classes.

3. For representing virtual method tables, you can create a struct type and a cor- responding global, constant variable. The fields of the virtual method tables are pointers to procedures, so you have to calculate a corresponding type.

4. Create one constructor-procedure for each class. In the constructor you should allocate memory for the object (allocinstruction) and initialize it. In particular, you have to set the reference to the virtual method table.

5. You can use theSizeOfoperand to calculate the size of a struct-type.

6. Remember, that objects can benull in Java.

7. There is no subtyping between struct types in LLVM, so you will have to use casts (bitcast instruction) in places where Java allows subtyping (assignments, equality checks, method calls, return statements).

Referenzen

ÄHNLICHE DOKUMENTE

As each temporary variable can only be defined once, this means that removing alloca instructions will transform the code into SSA form.. The LLVM tools already contain a tool to

Bei dieser Übung sollen Sie sich überlegen, welche logischen Schlüsse ein Verifikationstool wie OpenJML ziehen muss, um die Korrektheit des Programms zu beweisen. ).. a) In Zeile

Geben Sie jeweils einen konstruktiven Beweis für die beiden folgenden Aussagen an. “Konstruktiv” heißt hier, dass aus dem Beweis hervorgehen soll, wie man die gewünschte

Fachbereich Informatik AG Softwaretechnik. Übungsblatt 13: Logik

Wenn der Rest der Liste die leere Liste ist, kann diese auch weggelassen werden.. Wir wollen in dieser Aufgabe zum Üben unsere eigenen

Fachbereich Informatik AG Softwaretechnik. Übungsblatt 3: Logik

Zeigen Sie, dass sich Beweise in F 0 verallgemeinern lassen: Wenn es einen Beweis mit einer Variablen p gibt, dann lässt sich p durch eine beliebige Formel ersetzen und man erhält

•  Procedures/methods: If the actual parameters have the types of the formal parameters, no type error occurs and the result is of the declared result type.. •  The