jenox / minijava-compiler Goto Github PK
View Code? Open in Web Editor NEWImplementation of a Minijava to x86 compiler in Java and Swift.
Implementation of a Minijava to x86 compiler in Java and Swift.
Da MiniJava auch Lazy Evaluation bei Expressions unterstützt, müssen wir Kurzauswertung implementieren.
(ab Folie 35 im "Transformation"-Foliensatz)
Diese Knoten könnten dabei hilfreich sein:
https://pp.ipd.kit.edu/firm/api_latest/a00168.html
https://pp.ipd.kit.edu/firm/api_latest/a00193.html
May only affect invocations from the main method. Produces the error:
Assertion failed: (pos + 1 < irg->n_loc), function set_r_value, file ir/ir/ircons.c, line 511.
Bis Mittwoch Abend.
Einen Visitor implementieren, welcher den AST abläuft und dessen Elemente in firm-Element übersetzt.
Methodendeklarationen und Felder müssen wohl Entities in firm sein. Entities zeigen auf ihren Besitzer (die Klasse).
https://pp.ipd.kit.edu/firm/tutorial/#creating-the-entities
Mehr zu Entities: https://pp.ipd.kit.edu/firm/api_latest/a00005.html#details
Vielleicht entspricht in firm die Kategorie "Type System" den Deklarationen im AST?
https://pp.ipd.kit.edu/firm/tutorial/#constructing-function-graphs
*Methodendeklarationen bekommen ihre eigenen Graphen
handleBody
aufgerufenMehr über den Methodentypen in firm: https://pp.ipd.kit.edu/firm/api_latest/a00133.html#details
https://pp.ipd.kit.edu/firm/tutorial/#handling-expressions
https://pp.ipd.kit.edu/firm/tutorial/#id1
Für die BinaryOperations braucht man wohl einen Procedure Graph https://pp.ipd.kit.edu/firm/api_latest/a00109.html#details.
In dem kann man dann Knoten erstellen, welche einer BinaryOperation entsprechen, wie z.B. hier der Add-Knoten: https://pp.ipd.kit.edu/firm/api_latest/a00143.html
https://pp.ipd.kit.edu/firm/tutorial/#id2
Deren Sprache hat keine lokale Variablen, wir müssen das da anders umsetzen.
Have a symbol table class that can be used by the name and type analysis visitors.
Offer the following methods:
Nicht nur für Declarations und References.
Classes and functionality to translate the abstract syntrax tree into an unfilled attributed syntrax tree.
There should be a superclass Declaration
.
The following classes should extend it:
There should be a superclass Reference
with an attribute decl
of type Declaration
.
The following classes could extend it:
Not sure: should only IdentifierExpression and IdentifierAndArgumentsExpression be references?
All statements and expressions should get a type
attribute.
They should have a superclass, for example: TypeableNode
.
All nodes should extend a superclass VisitableNode
(which offers a accept(Visitor v)
method).
array_summation
Verify warning: Proj P[104:10](Summator.sum[98]): expected mode (null) but found P
Speed-collector uses Docker to run your binaries, and Docker requires that all scripts have a an explicit shebang (e.g. see section "exec format error" in http://kimh.github.io/blog/en/docker/gotchas-in-writing-dockerfile-en/)
Implement a visitor class that performs name analysis.
Desired output: Attributed Syntax Tree where all references have their decl
attribute filled out.
accept
method)The tree needs to be traversed twice, because MiniJava allows use-before-declare.
** Though, maybe it's still possible to compute the whole thing with one traversal?**
decl
attribute for all references. Check for undefined variables or variable use out of scope.This can be implemented via Visitor Pattern whereby the Visitor owns the symbol table with the declarations.
if
else
try
catch
etc. auf eigene Zeilethis
-2147483647
und -/*comment*/2147483647
gültig, aber -(2147483647)
nichtSystem == System
und System.out == System.out
ungültigreturn this.f()
aus void-Methode, wenn f
void
zurück gibt, ungültigmain
in secondary classImplement a visitor class that performs type analysis.
Desired output: Attributed Syntax Tree where for all statements and expressions their type
attribute is filled out.
Don't know how many traversals are needed here
boolean
.integer
.void
.decl
attribute -> look up type
attribute of Declaration).decl
attribute)null
matches matches any UserDefinedTypes and Array Expressions (does it match anything else?).When types are incosistent, it is necessary to give helpful errors (with location).
Needs fixes for calls to finishLayout
, layoutFields
etc.
Da unsere Sprache auch Rekursion unterstützt, brauchen wir Activation Records.
(ab Folie 71 im "Transformation"-Foliensatz)
firm bietet dazu den Frame Type an, um Stack Frames / Activation-Records zu repräsentieren.
firm berechnet dabei auch schon automatisch die Offsets für den Zugriff der Elemente des Frames.
Bei jedem Methodenaufruf muss ein Activation Record erzeugt und nach dem Durchlauf zerstört werden.
https://pp.ipd.kit.edu/firm/api_latest/a00140.html
Funktionalität, welche die primitiven und benutzerdefinierten Typen übersetzt in Typen von firm.
(ab Folie 53 im "Transformation"-Foliensatz)
Für die verschiedenen Typen von Expressions müssen tarvals (target machine values) erstellt werden.
Ich weiß nicht, ob firm auch schon automatisch dabei Offset und Alignment berechnet.
Könnte sein, dass man das auch noch machen muss.
Falls das nicht richtig berechnet wird, macht es den x86-Code langsamer.
https://pp.ipd.kit.edu/firm/api_latest/a00127.html#details
Tarvals können dann als Parameter benutzt werden, um Knoten im Graphen zu erstellen.
Hier zum Beispiel ein Constknoten für Integerkonstanten:
https://pp.ipd.kit.edu/firm/api_latest/a00157.html
Split into
+++
=> increment, plus
*/
=> multiply, divide
Aktuell globale System
-Variable und dummy MethodDeclarations
für write
, flush
etc. Für System.out.write(5)
ist dann aber wirklich MethodInvocation(ExplicitFieldAccess(VariableAccess(System), out), write, 5)
im AST.
Ich glaube nicht, dass es in dieser Form in die Transformation gehen sollte. Wir könnten stattdessen neue Expressions für die verschiedenen Syscalls einführen und in der semantischen Analyse den AST dann minimal umbauen.
Aufgabe 4 und 5 von Aufgabenblatt 6.
k
bestimmen sodass SLL(k)
First_k
und Follow_k
bestimmenINT_MIN / 1
should produce INT_MIN
Requires #67.
Also see test case field_init.mj
(may also be invalid).
Handle according to libFirm documentation:
In a correct graph any potentially endless loop needs:
- At least 1 block in the loop must be referenced by a keep-alive-edge
- There must be at least 1 Phi node with memory mode which is referenced by a keep-alive-edge
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.