Rune - Further Object abstraction work * Get rid of RuneObject (a dummy object) and directly replace with the ObjectInfo structure. This removes an abstraction layer and makes the code a whole lot more readble. * Change object references to be pointers to the ObjectInfo structure instead of pointers to its data (which used to be at (&ObjectInfo + 1). * Allocate the object data separately so it is no longer always after the object in the memory layout, and fixup all the accessors. * Add and test accessors to obtain a pointer to the base of the data. Since the data is now allocated separately, we can now test that all the code is actually going through the correct accessor. Validate with test/gfxbutton2.d * Change the RunData->mobj sidechannel pointer to point directly at the ObjectInfo rather than at object data. * Add ObjectInfo->in_Flags to flag dynamic allocations to reduce certain side effects that were being tracked separately.
Rune - Reformulate "unrestricted" scope for core types 2/2 * Remove "unrestricted", replacing it with "struct" and "substruct". * Change "interface" from a statement to a scope qualifier. So we now say "interface struct ..." or "interface subclass ..." and so forth.
Rune - llvm backend work * Get LLVM RA output to a state where llc can deal with it. The resulting binary will not run yet though. Fix some SSA issues related to LLVM RA temporary registers only being able to be assigned once. This is really dumb, since LLVM has to optimize multi-assignments for stack variables anyway, it should also be able to deal with multi-use register temporaries. Sigh. Adding missing boolean zext Synchronize a few run-time structures that have changed. * Replace most BE checks at higher levels with BACKEND() calls. * 'rune' frontend can now handle llvm intermediate outputs, .m, .s, and executable. * Use O_CLOEXEC as appropriate to avoid leaking descriptors through exec*(). * Syntax cleanup
Rune - Code generator work (tests/format.d and tests/gfxslider.d compiles) * Do a ton of work on the code generator to implement all the changes made to the language. * Use EX2F_LVALUE to flag an lvalue vs rvalue in the expression tree. Do NOT modify the Type structure with SF_LVALUE for this purpose, it creates massive confusion. * Get the modifications to the 'this' argument for method calls operational in the code generator. * Get some of the object lock side effects (gendata->mobj) operational again. * Completely refactor the alignment and storage handling in the resolver. Also rename many procedures for consistency. Its probably generating too much (for now), but this revamp was needed. * For now link libgen and librune to the code and not just libruntime. I'll have to fix it up later, or perhaps just keep it all in there to support run-time interpreted code and mixed mode execution in the future. * Since we no longer have an RSInfo or fat reference structures, the reference pointer has to be tested against NULL. If it is not-NULL we can extract in_DynVec and in_Type directly from a negative offset relative to the reference pointer. If it is NULL we use the resolved type from the expression, basically a LEA of a global symbol. The conditional uses a simple branch-past / fall-through sequence by tricking the LEA such that the negative offset in the branch-past code gives us the correct result.
Rune - Cleanup resolver, general cleanup * Fix expression duplication for the 'this' argument. For example, when you do: a->b->c(fubar) where c is a method call, the expression a->b was being duplicated for the invisible 'this' argument, e.g. (internalized a->b->c(&a->b, fubar)). Fix by creating a TOK_THISARG placeholder for the 'this' argument and then adjusting the run-time to set-aside the data reference from the left-hand-side of the top-level '.' or '->'. The placeholder then takes ownership of the set-aside data reference. This is a bit of a mess at the moment but it is better than what I had before. * Rename confusing sg_Type to sg_Op * Rename and adjuset TY_ARYTYPE et_ArySize. Rename to et_ArySizeExp and fork the field, adding et_OrigArySizExp for DupType operation. * Duplicate a fresh procedure body for Inlined procedures. * Assert ResolveExp() only gets called once. This helps catch situations where we fail to DupExp() an expression.
Rune - Objectification of references work part 4 (interp test/gfx* working) * Interpreter is now operational with some of the more complex bits of test code. * Fixed search level (I think). * Fixed handling of 'super.blah' and 'super->blah'. * Conslidate storage assignments. * Set sg_ClassType in parser, with the declared scope, and clean up SCOPE_UNRESTRICTED tests. * Enhanced error reporting and some cleanup.
Rune - Objectification of references work part 3 (interp partially working) * Interpreter is now partially working, e.g. tests/hello.d * Add the concept of an 'unrestricted' class. Unrestricted classes are allowed to be directly declared or directly embedded in other classes. By default, all methods for unrestricted classes pass void *this instead of void @this. * Remove the manual typedef refinements of _t in classes/sys/class.d. Instead, make it entirely automatic. This way declarations and procedures conveniently have access to the actual class or subclass type simply by using _t. This fixes issues where superclass procedures couldn't declare the actual refined subclass because they didn't know what it was. Now they do, it is '_t'. The insertion of the '[refine] typedef <class_or_subclass> _t' is handled by the resolver. * Fixup the TOK_COMPOUND handling for compound expressions to not cast (blah *) to (lvalue void *) when the argument declaration is (lvalue void *), or (blah @) to (lvalue void @) when the argument declaration is (lvalue void @). This way our method procedures properly get the correct lv_Type loaded in the LValueStor. * Move the insertion of 'this' for both the method call and the method declaration out of parse2.c and into resolve.c. This way we have access to the proper subclass w/regards to refinements. * Adjust system calls to deal with the fact that, except for 'new()' type methods, now take a pointer or reference as a single C pointer instead of an LValueStor. * Fix several issues from prior commits that hadn't been fixed. * Change the default this argument for method procedures from 'lvalue class this' to 'class @this'. That is, pass as a reference, which means that default use cases have to use this->blah instead of this.blah. * Allow pointer-to, reference-to, lvalue pointer-to- and lvalue reference-to types for the 'this' argument to a method. We no longer allow the 'lvalue class this' (lvalue directly as the class) method. * Remove the unary '@' (address of blah returned as a reference). This was going to be too messy to implement and could only work on the lvalue class this method argument anyway. Now that it has been changed, we do not have to worry about it. * Change the name of the Fs class to Fd. Since this is used to manage descriptors, calling it Fs was actually rather confusing. Rename 'fd' identifiers representing a Fd to 'efd' so they do not get confused with integer descriptors. efd is for 'extended file descriptor', aka the Fd class. * Use refineable typedefs for a number of classes.
Rune - Objectification of references work part 2 (build broken) * Major rework and removal of RefStor's, replaced by Rune objects. A Rune object pre-pends an ObjectInfo at a negative offset from the base of any @ref object. TY_REFTO can only point to full fledged objects. RuneObject - points to the base of the data, same as the data base pointer but uses a dummy 'RuneObject *' type. ObjectInfo - The information structure pre-pending to Rune objects. * Readjust headers and do a better job enforcing library order by conditionalizing prototypes. Redo the library link order. Make librune our base library. However, directly include librune.a when creating libruntime so libruntime can be stand-alone. * Remove WARNS and cleanup the compile. * Rename wantminfo to wantmobj (etc). * Lots of breakage all over the place at the moment.
Rune - Objectification of references work part 1 To further distinguish references from pointers, the model for a reference is going to be changing to embed the meta-data at negative offsets rather than using an independent Info structure. This is now possible because I have already fixed the &exp to distinguish references from pointers. &exp returns a pointer, which is not an object in any way. So normal address-of operations will still work just fine. * Declared globals, variables, fields in structures, etc will no longer be objectifiable. The only way to create an object will be to allocate it dynamically (which is the method already in standard-use in Rune). * Begin removing @variable use cases. The '@this' use-case for methods is fine as the underlying object is already a dynamically allocated reference. * In upcoming commits, the PointerInfo structure will be entirely removed, which will also remove one level of indirection from LValueStor and ReferenceStor (the second field will point directly at the Type instead). The equivalent of the info structure will become ReferenceInfo and be stored at a negative offset from the base of the object. Thus, the object pointer itself will remain sane.
Rune - reformat classes/* and tests/* * Reformat for an indent of 4 and clean up a bit.
Rune - Finalize 'char' and other basic integer types * Finalize 'char' as being 'unsigned 8 bits', remove 'uchar' and 'schar' entirely. I thought about this long and hard and, frankly, have come to believe that 'char' should never have been signed in C, let alone allowed to be either signed or unsigned. In Rune I have finalized the definition of 'char' to always be an unsigned 8-bit quantity, and to ram that home I have removed 'schar' and 'uchar'. If you want to be more explicit, then use 'int8_t' or 'uint8_t', simple as that. * I added 'short' and 'ushort' back in. In Rune 'int' is always 32 bits, period. Having coded on almost every architecture known to man, including many 16-bit micro-architectures, I have come to the conclusion that it is utterly stupid to try to make 'int' follow the machine integer size for any particular architecture. It creates a portability nightmware, frankly. If you are coding on an 8-bit or 16-bit architecture, then use 'short' instead of 'int', simple as that. The concept of trying to make libraries portable through the use of an 'int' that can change width is just flat out stupid. Not only does it not make libraries portable, it introduces an unimaginable number of side effects in C, particularly due to automatically type extension, that has driven me nuts more than a few times. It is far better to standardize on a width and then simply provide a different library to standardize on a different width. Simple as that. And in Rune, this is easy to do because you can refine typedefs in classes and use those for various argument declarations (Even if I haven't yet done this to all of Rune's system libraries). Thus why I added 'short' and 'ushort' back in. This gives 16-bit coders something convenient to grab on to without having to resort to the explicit types like int16_t. Not that there is anything wrong with int16_t, its just that the wordiness can get on coders nerves for variables that are meant to be relatively generic.
Rune - Make all pointers C-like * Rune has pointers such as 'char *' and references such as 'Fubar @', and then also has a __clang storage qualifier which was used with pointers (and for other things) to implement C-style pointers. The pointers were previously using the same (ptr, info) tuple as references, and were ref-counted and locked just like references. This major-ass commit makes pointers behave like C, without needing the __clang qualifier. * Now all '*' pointers are just a simple physical pointer without any ref-counting or locking. It is the programmer's responsibility to not shoot himself in the foot. Programs should use references in most situations, particularly involving multi-threading, but can use pointers for things like iterating buffers and such, when it makes sense. Operators that modify pointers now only work with pointers and do not work with references. This is intentional and will allow references to (in a later commit) embed the object management fields directly in the target object, allowing us to get rid of a ton of code-generation overhead. The fields will be placed at negative offsets so the base reference always points to the pure structure portion of the object. * Fix NULL semantics, basically make the 'internal2' pointer and reference operators more flexible so things like == and != can mix pointers and references. * Add a hack/work-around in findOper() related to the resolver missing something that I haven't figured out yet. This was interfering with Pointer class operators. * Add '@exp' as a unary operator for reference-to-expression, producing a reference to an lvalue. We already had '&exp' but this now produces only pure pointers, not references and not reference-compatible. '@exp' will ultimately only work on known objects, and will ultimately (in a later commit) change how global declarations are laid out (laying them out as objects instead of pure structures). * Adjust classes/* and modify some tests/* for the new reality (needs more work). * Unfortunately this pointer change also means that runtime calls like bcopy are not range-checked any more. I will try to come up with a better means to check pointer validity but we may end up having to eat the lost determinism. * Assert in runeid_sym() if the identifier cannot be represented as a symbol. Also adjust so an id of 0 returns NULL. * Rename a huge number of symbols in the codebase from Pointer to Reference, Ptr to Ref or to RawPtr, and many other rename changes, as appropriate. * The interpreter and RAS generator can both run tests/gfxinput2.d with these changes.
Rune - Add copyright notice to classes/ * Add copyright notice to classes. * Bump the sophistication of the input frame (allows testing of global constants being refined in subclasses, and affecting array declarations in the superclass.
Rune - Refactor size_t into usize_t and ssize_t * For now, officially in Rune, we omit size_t and instead have an explicit usize_t and ssize_t. I may put size_t back in the future (it would just be a typedef to usize_t).