| written by Explorer on Dec 02, 2003 04:25 |
 | |  | | I'm not sure how the linoleum compiler works, or if this idea violates your goals for linoleum, but would it be possible to allow linking to other languages code? As in during the linking/compiling steps? | |  | |  |
|
   | |  | | There's no linker in the linoleum compiler. This makes things complicated, but answering your question easy . The outputted application is really different from 'normal' applications in that the code and the data section aren't available in the executable, but have to be loaded into memory still. So this is a problem.
I can also say for sure that linking to other objects violates Alex's goals with Linoleum. By doing so, the language isn't extremely universal anymore.
Still i can understand why it would be desirable to be able to link to other code. F.e. access to openGL Therefore, after porting Linoleum to linux i might design a language similar to linoleum, but then a system assembler. Possibly even using the same symbols map as linoleum, (when Alex agrees) but with access to external functions. Still i have no clue if i can do this and how i should do this. I have been thinking about a RTM with only one call, which will try to dynamically load a DLL and execute a function of that DLL.
Something like
| | [Linker Command] = FIND;
[Linker Library] = pointer to string with name of library;
[Linker Function] = pointer to string with name of function;
isocall;
? failed -> sorry function not available;
"function can be executed"
[Linker Command] = EXECUTE;
[Linker Library] = pointer to string with name of library;
[Linker Function] = pointer to string with name of function;
[Linker Parameters] = pointer to string with all parameters.
isocall;
? failed -> not available or error parsing parameter string.
"function is executed" |
|  | |  | | There could even be two different execute commands: EXECUTE SYNCHRONIZED: function finished after return EXECUTE ASYNCHRONISE: function executes in a separate thread
Well, this is my idea. Let me know what you think. | |  | |  |
|
  | written by Explorer on Dec 02, 2003 16:21 |
 | |  | | I think that if alex agreed, that would be an amazing idea. Linking to other code would be infinitely useful.. Where can I find more information on how Alex's compiler works? I'm interested in how he does it ^^; I'm very computer literate so understanding wouldn't be a problem. | |  | |  |
|
   | |  | | Hmmm, i fear that basically the only information on how the compiler works is available in the linosrc package. You have to read through the source files. I think that you need to understand the following before you start reading the source files:
The input for the linoleum compiler is:
- linoleum source file, program
- system specific binary RTM (Run Time Module)
- platform specific operands patterns
Basically what the compiler does is:it generates a code block based on the sourcecode and the pattern-map. (- All libraries needed by the source file are included, so every library has to be compiled every time you run the compiler on a program using that library. -)The compiler also generates a workspace block with the values of the initialized variables.The compiler searches the RTM for the initialization paragraph. In this section the sizes of the code and workspace block are written along with some other initialized parameters.These two blocks are merged with the RTM and the result is saved as PROGRAM.EXE.The RTM is responsible for initializing the run-time environment. It does this the following way: The RTM reads the Initialization Paragraph to know the sizes of the code and complete (initialized + uninitialized) workspace block. Based on these values it allocates memory for these blocks. Then the file with the RTM is opened and the blocks are read into the allocated memory blocks. When all further initializations are made, and the registers are cleared and prepared for the execution of the linoleum code, the control is handled to the linoleum code block.
To reflect my previous post, i think it's better to write a separate compiler for a system specific version of linoleum. This would then be based on Bison and Flex. But in this way it will be possible to link to other code just like you would do from other assemblers. So linking (to c code) would then be done something like:
| | [sourcestring]-->;
[destinationstring]-->;
=> strcpy; |
|
|
  | written by Alex on Dec 03, 2003 10:57 |
 | |  | | Well, I suppose a system-specific version of Linoleum would stand to the original Linoleum about like C stands to Java... they share a similar syntax, in terms of source code, but they're two completely different things. So if someone wants to do that (which, even if I wanted, I don't think I could forbid at all, really) the only precaution would be: don't call it a special version of Linoleum. The RTM and the way it behaves (supposed to be exactly the same for all the supported systems) is an integral part of Linoleum, not less than the source code's syntax.
I still can't see all that usefulness in doing something else apart from what the RTM does now. Perhaps to record PCM audio instead of having playback only... or to use hardware acceleration for graphics, but I can't still think that would be a reason worth losing the "extremely universal" part. Perhaps it's just me...
About the compiler, Peterpaul said pretty all there was to say. The "map" of program.exe is basically:
- RTM (with initialization paragraph within) - static data ( "main workspace" ) - code (first libraries, then main program) - stockfile components, one after the other
each block has to be aligned at least to the CPU unit, so stockfile parts are for example linked leaving a few padding bytes between them, so (presently) that their starting point from the beginning of the stock file is always an offset, seen in bytes, that's a multiple of 4.
The initialization paragraph is marked by a signature in the RTM, that is "LNLMinit", and ends with signature "LNLMIend": contains informations such as the program name, the code entry point (pointer to first instruction of the main program's "programme" period, to skip libraries' code on startup), how long is the code block (to be allocated, loaded and executed in its own dedicated thread by the RTM, not by the OS along with the RTM), how long is the workspace block (the initialized part), how much memory the program needs in terms of total workspace size, and some directors' values (display size, initial pointer mode...).
I'd please: don't. It doesn't make me happy. But then, if you:
- don't start from my compiler and RTM, - don't call it Linoleum,
and still make out your own language with a similar syntax, there's nothing I can do to keep anyone from doing that.
edit: hmmm... 13 seconds to post this message 0.8 seconds to edit it... *tries* | |  | |  |
|
|