Skip to content

Instantly share code, notes, and snippets.

View ErikCorryGoogle's full-sized avatar

Erik Corry ErikCorryGoogle

View GitHub Profile
/\1/ // Matches Unicode code point 1 aka Ctrl-A
/()\1/ // Empty capture followed by a backreference to that capture
/()\01/ // Empty capture followed by code point 1
/\11/ // Match a tab character, which is code point 9!
/\18/ // Match code point 1, followed by "8"
/\176/ // Match a tilde, "~"
/\400/ // Match a space followed by a zero
JS_TypeOfValue(JSContext *cx, jsval v)
{
/* ... */
if (JSVAL_IS_OBJECT(v)) {
type = JSTYPE_OBJECT; /* XXXbe JSTYPE_NULL for JS2 */
@ErikCorryGoogle
ErikCorryGoogle / excerpt from jsapi.h
Created January 15, 2017 11:29
Spidermonkey tags
/*
* Type tags stored in the low bits of a jsval.
*/
#define JSVAL_OBJECT 0x0 /* untagged reference to object */
#define JSVAL_INT 0x1 /* tagged 31-bit integer value */
#define JSVAL_DOUBLE 0x2 /* tagged reference to double */
#define JSVAL_STRING 0x4 /* tagged reference to string */
#define JSVAL_BOOLEAN 0x6 /* tagged boolean value */
I like that names have to be unique. Some regexp flavours allow dupes and unify the storage between them,
but that feels complicated and difficult to spec. For something like this:
/(<foo>..)((<foo>..))*/
normally you would reset the capture whenever you iterate the *-loop, but it would be strange to delete the
foo capture on entering the loop, or would it?
By putting the named captures on the match object as properties, you are preventing any future standard from
ever adding a new property to the Match object, ever, since it might conflict with the name of a named capture.
Perhaps it makes more sense to add a .map property to the match of type Map and have string keys on that map.
This also avoids the question of what happens if someone makes a named capture called __proto__ or prototype.
movq %rdx, (%rsp)
movq %rcx, 8(%rsp)
movq %rdx, 16(%rsp)
movq %rbx, %rdi
movq %rcx, %rsi
callq *%r14
%statepoint_token = call token (…) @llvm.experimental.gc.statepoint(326, 0, %code, 3, 0, %process, %this, %16)
%method_result = call @llvm.experimental.gc.result(token %statepoint_token)
%this.relocated = call coldcc @llvm.experimental.gc.relocate(token %statepoint_token, 10, 10) ; (%this, %this)
%16.relocated = call coldcc @llvm.experimental.gc.relocate(token %statepoint_token, 11, 11) ; (%16, %16)
; We now have to use %this.relocated instead of %this,
; and %16.relocated instead of %16
%class = load_class(%this)
%id = load_class_id(%class)
%offset = add 291, %id
%code = array_load(@dartino_vtable, %offset)
%method_result = call %code(%process, %16)
; We can still use “%this” here, even if there has been a GC in the call
@ErikCorryGoogle
ErikCorryGoogle / gist:417755c0e3b2545d445bb15154a9a627
Created June 8, 2016 12:19
.vimrc file for Ggrep key binding
" Does a git grep of whatever you are currently searching for. Requires
" fugitive.vim
" Bugs:
" Always does a case dependent search, even if vim is ignorecase mode.
" Doesn't understand searches with spaces in them (usually you can just
" replace spaces with dots in the Vim search).
" Doesn't understand most metacharacters that also mean something to the
" shell.
" Understands \<word\> and converts to a grep -w, but doesn't understand
" asymmetric word delimiters like \<word or word\>