How the RemObjects Elements targets work

RemObjects Oxygene and RemObjects C# have 3 targets, the .NET, Cocoa (OSX/iOS) and Java (Android) targets. Each of the targets are unique, there's no interpretting from 1 to another, even though the original target was .NET. Internally the compiler reduces each of the C# and Oxygene elements to low level elements, that is, for loops become while loops, try/finally is converted to try/except on platforms that don't have a finally (like Java), using to a try/finally, etc. Then the targets convert the reduced data into the platform specific code. When the compiler is done, what's left is Exit, Assignments, If, Goto, Label, Switch, Case, While, Break, Continue, Case and Try. Each target also has a "Type Loader", which deals with adding references to .dll, .fx or .jar files.The type loader deals with listing types from external sources and getting their members. The last part of each target is the Target itself, which has the unique code for each platform, including things like specifying what types translate to the system types, dealing with operator overloading and platform specific system logic.

.NET

On .NET things are converted into IL. The compiler converts each type, member, statement and expression into a low level IL constructs.

Java

For the Java target we generate a set of .class files in memory then combine it in a JAR file, which is essentially a zip file.

Cocoa

The cocoa target is more interesting, since there's no .class or clr file format that we can use, instead it's a raw executable built with LLVM. LLVM uses a very low level assembly that it optimizes and converts to native code for the target platform, of which we support 5: armv7, armv7s, armv8, x86_64 and i386. The type loader here uses .fx formats as an intermediate. fx files are also written next to libraries emitted when compiling.

The end result is that each of the targets has nice and optimized code made specially for those platforms.

comments powered by Disqus