Skip to content

My implementation of clox as described by Robert Nystrom.

Notifications You must be signed in to change notification settings

septicalls/clox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clox

My implementation of clox as described by Robert Nystrom in crafting interpreters.

Challenges

  • Devised an efficient method for encoding line information.
  • Added support for 24 bit constants (OP_CONSTANT_LONG).
  • Wrote an original implementation of reallocate() without using malloc, realloc, or free.
  • Hand-compiled 1 + 2 * 3 - 4 / -5 into bytecode.
  • Substituted OP_NEGATE for OP_SUBTRACT.
  • Made VM stack dynamically grown.
  • Made OP_NEGATE work in-place.
  • Parsed C-style ?: (ternary operator).
  • Made ObjString own its character array with flexible array members technique.
  • Made ObjString differentiate between heap owned strings and source string literals.
  • Added support for keys of primitive types: numbers, Booleans, and nil.
  • Added support for constants (variables that cannot be re-assigned).
  • Extended clox to allow more than 256 local variables to be in scope at a time.
  • Added support for switch statement.
  • Added support for continue statement.
  • Strored the ip in a CPU register.
  • Added arity checking for native functions.
  • Supported native functions to report runtime errors.
  • Made a compact Obj header.
  • Efficiently cleared isMarked field during garbage collection cycles.
  • Object fields can be accessed by any string constructed string in Lox.
  • Object fields can be deleted permanently.
  • init() methods are accessed faster.
  • Implemented BETA-style method resolution.

About

My implementation of clox as described by Robert Nystrom.

Topics

Resources

Stars

Watchers

Forks