Skip to content

Instantly share code, notes, and snippets.

View cpurdy's full-sized avatar

Cameron Purdy cpurdy

View GitHub Profile
/**
* Read a sequence of bytes from the stream corresponding to a single Unicode character that is
* encoded in the UTF-8 format. If the character is in the surrogate range, the second codepoint
* in the pair will also be read, and joined with the first.
*
* @param in the BinaryInput stream
*
* @return the character read from the stream in UTF-8 format
*
* @throws IllegalUTF if there is a flaw in the UTF-8 encoding or in the resulting codepoint
module TestSimple
{
@Inject Console console;
void run()
{
function Int() f = makeMeAClosure();
console.println($"after losing the stack frame, the returned closure evaluates to {f()}");
}
@cpurdy
cpurdy / Collection.x
Created November 20, 2020 18:56
"each" functionality
/**
* Determine if any elements of the `Collection` match the provided criteria.
*
* @param match a function that evaluates elements of this collection for inclusion
*
* @return True if any element matched the specified criteria
* @return (conditional) the first element that matched the criteria
*/
conditional Element any(function Boolean(Element) match = _ -> True)
{
/**
* Generate assembly code for a method. This is the entry point for the compilation of a method.
*
* @param code the code object to which the assembly is added
* @param errs the error listener to log to
*
* @return true if nothing occurred during the compilation that should stop further progress
*/
public boolean compileMethod(Code code, ErrorListener errs)
{
import reflect.Argument;
import reflect.Annotation;
/**
* The LinkedList annotation is used to turn a property into a linked list, **without using any
* additional memory** beyond the property or properties that represent the next and previous
* pointers.
*
* There are three dimensions that define a total of six distinct scenarios supported by this mixin:
*
@cpurdy
cpurdy / Char.x
Created May 17, 2020 18:28
Unicode GeneralCategory look-up from prepared CharCats.dat binary file
/**
* The Unicode General Category of the character.
*
* This information is field 2 in the `UnicodeData.txt` data file from the Unicode Consortium.
* From [https://www.unicode.org/reports/tr44/#General_Category_Values]:
*
* > This is a useful breakdown into various character types which can be used as a default
* > categorization in implementations. For the property values, see
* > [General Category Values](https://www.unicode.org/reports/tr44/#General_Category_Values).
*