Gravity files


In order to increase modularity, Gravity is divided into 4 main components and each one (except shared) is completely independent from the others. In this way there is a clear separation between the compiler itself that end up producing the bytecode and the virtual machine that is responsible to execute that bytecode.

Utils

  • gravity_utils: Collects useful functions extensively used by other files. Time, IO, strings, UTF-8 and many other functions can be found in this file.
  • gravity_json: Very efficient JSON parser from https://github.com/udp/json-parser.
  • gravity_debug: Contains the gravity_disassemble function used for debugging purpose.

Compiler

  • debug_macros: Debug macros used internally during development.
  • gravity_ast: Abstract syntax tree implementation.
  • gravity_codegen: Code generation module.
  • gravity_compiler: Main compiler module that can hides other internal modules.
  • gravity_ircode: Intermediate code and register allocation management.
  • gravity_lexer: Lexer implementation.
  • gravity_optimizer: Optimizer and bytecode finalyzer.
  • gravity_parser: Parser implementation and syntax checker.
  • gravity_semacheck1: Semantic checker step 1 (used for non-local identifiers).
  • gravity_semacheck2: Semantic checker step 2 (used for local identifiers).
  • gravity_symboltable: Symbol table management and creation.
  • gravity_token: Tokenizer implementation.
  • gravity_visitor: Visitor patter for C.

Shared

  • gravity_array: Dynamic array macros implementation from https://github.com/attractivechaos/klib/blob/master/kvec.h.
  • gravity_delegate: This is where utilities are collected in a single file.
  • gravity_hash: Hash table implementation.
  • gravity_macros: Useful macros mainly used at runtime.
  • gravity_memory: Memory management module with built-in leaks checker for MacOS.
  • gravity_opcodes: Enum opcodes officially supported by Gravity.
  • gravity_value: One of the most important module that declare the struct of each object and value used inside Gravity.

Runtime

  • gravity_core: Core classes implementation and definition.
  • gravity_vm: Interpreter and garbage collector implementation.
  • gravity_vmmacros: Collects various macros used by the Virtual Machine.