Browse Source

Deleted trailing whitespace in src/, api/, and docs/

Filippo Costa 8 years ago
parent
commit
4fe5134d16
95 changed files with 2348 additions and 2348 deletions
  1. 2 2
      api/Makefile
  2. 33 33
      api/exec_c.c
  3. 14 14
      api/exec_gravity.c
  4. 20 20
      docs/api.html
  5. 29 29
      docs/classes.html
  6. 10 10
      docs/closures.html
  7. 7 7
      docs/contributing.html
  8. 6 6
      docs/control-flow.html
  9. 11 11
      docs/enum.html
  10. 8 8
      docs/fibers.html
  11. 26 26
      docs/functions.html
  12. 1 1
      docs/getting-started.html
  13. 7 7
      docs/index.html
  14. 12 12
      docs/internals/1_changelog.html
  15. 12 12
      docs/internals/1_files.html
  16. 11 11
      docs/internals/2_array.html
  17. 11 11
      docs/internals/2_class.html
  18. 11 11
      docs/internals/2_hash.html
  19. 11 11
      docs/internals/2_json.html
  20. 11 11
      docs/internals/2_memory.html
  21. 11 11
      docs/internals/2_overview.html
  22. 11 11
      docs/internals/2_utils.html
  23. 11 11
      docs/internals/2_visitor.html
  24. 11 11
      docs/internals/2_vm.html
  25. 11 11
      docs/internals/3_ast.html
  26. 11 11
      docs/internals/3_bytecode.html
  27. 11 11
      docs/internals/3_codegen.html
  28. 11 11
      docs/internals/3_grammar.html
  29. 11 11
      docs/internals/3_ircode.html
  30. 11 11
      docs/internals/3_lexer.html
  31. 11 11
      docs/internals/3_opcodes.html
  32. 11 11
      docs/internals/3_optimizer.html
  33. 11 11
      docs/internals/3_overview.html
  34. 11 11
      docs/internals/3_parser.html
  35. 11 11
      docs/internals/3_prattparser.html
  36. 11 11
      docs/internals/3_semantic.html
  37. 11 11
      docs/internals/3_symboltable.html
  38. 11 11
      docs/internals/4_base.html
  39. 11 11
      docs/internals/4_gc.html
  40. 11 11
      docs/internals/4_memory.html
  41. 11 11
      docs/internals/4_objmodel.html
  42. 11 11
      docs/internals/4_overview.html
  43. 11 11
      docs/internals/4_performance.html
  44. 11 11
      docs/internals/4_vm.html
  45. 11 11
      docs/internals/5_jit.html
  46. 11 11
      docs/internals/5_overview.html
  47. 12 12
      docs/internals/index.html
  48. 16 16
      docs/lists.html
  49. 13 13
      docs/loops.html
  50. 13 13
      docs/maps.html
  51. 10 10
      docs/operators.html
  52. 1 1
      docs/stylesheets/styles.css
  53. 16 16
      docs/syntax.html
  54. 17 17
      docs/system.html
  55. 18 18
      docs/types.html
  56. 7 7
      docs/unit-test.html
  57. 35 35
      src/cli/gravity.c
  58. 30 30
      src/cli/unittest.c
  59. 1 1
      src/compiler/debug_macros.h
  60. 54 54
      src/compiler/gravity_ast.c
  61. 2 2
      src/compiler/gravity_ast.h
  62. 155 155
      src/compiler/gravity_codegen.c
  63. 23 23
      src/compiler/gravity_compiler.c
  64. 36 36
      src/compiler/gravity_ircode.c
  65. 58 58
      src/compiler/gravity_lexer.c
  66. 4 4
      src/compiler/gravity_lexer.h
  67. 61 61
      src/compiler/gravity_optimizer.c
  68. 160 160
      src/compiler/gravity_parser.c
  69. 4 4
      src/compiler/gravity_parser.h
  70. 24 24
      src/compiler/gravity_semacheck1.c
  71. 8 8
      src/compiler/gravity_semacheck1.h
  72. 158 158
      src/compiler/gravity_semacheck2.c
  73. 9 9
      src/compiler/gravity_semacheck2.h
  74. 14 14
      src/compiler/gravity_symboltable.c
  75. 23 23
      src/compiler/gravity_token.c
  76. 4 4
      src/compiler/gravity_token.h
  77. 7 7
      src/compiler/gravity_visitor.c
  78. 5 5
      src/compiler/gravity_visitor.h
  79. 79 79
      src/optionals/gravity_math.c
  80. 154 154
      src/runtime/gravity_core.c
  81. 1 1
      src/runtime/gravity_core.h
  82. 176 176
      src/runtime/gravity_vm.c
  83. 1 1
      src/runtime/gravity_vm.h
  84. 1 1
      src/shared/gravity_array.h
  85. 2 2
      src/shared/gravity_delegate.h
  86. 47 47
      src/shared/gravity_hash.c
  87. 1 1
      src/shared/gravity_hash.h
  88. 28 28
      src/shared/gravity_memory.c
  89. 13 13
      src/shared/gravity_opcodes.h
  90. 155 155
      src/shared/gravity_value.c
  91. 18 18
      src/shared/gravity_value.h
  92. 33 33
      src/utils/gravity_debug.c
  93. 39 39
      src/utils/gravity_json.c
  94. 9 9
      src/utils/gravity_json.h
  95. 54 54
      src/utils/gravity_utils.c

+ 2 - 2
api/Makefile

@@ -24,7 +24,7 @@ else
 		LDFLAGS = -lm
 		LDFLAGS = -lm
 	else ifeq ($(UNAME_S),NetBSD)
 	else ifeq ($(UNAME_S),NetBSD)
 		# NetBSD
 		# NetBSD
-		LDFLAGS = -lm 
+		LDFLAGS = -lm
 	else ifeq ($(UNAME_S),OpenBSD)
 	else ifeq ($(UNAME_S),OpenBSD)
 		# OpenBSD
 		# OpenBSD
 		LDFLAGS = -lm
 		LDFLAGS = -lm
@@ -38,7 +38,7 @@ all: exec_gravity exec_c
 
 
 exec_gravity:	$(OBJ) $(EXEC_GRAVITY_SRC)
 exec_gravity:	$(OBJ) $(EXEC_GRAVITY_SRC)
 	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
-	
+
 exec_c:	$(OBJ) $(EXEC_C_SRC)
 exec_c:	$(OBJ) $(EXEC_C_SRC)
 	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 	$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
 
 

+ 33 - 33
api/exec_c.c

@@ -36,7 +36,7 @@ static void report_error (error_type_t error_type, const char *message,
 		case GRAVITY_WARNING: type = "WARNING"; break;
 		case GRAVITY_WARNING: type = "WARNING"; break;
 		case GRAVITY_ERROR_IO: type = "I/O"; break;
 		case GRAVITY_ERROR_IO: type = "I/O"; break;
 	}
 	}
-	
+
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("RUNTIME ERROR: ");
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("RUNTIME ERROR: ");
 	else printf("%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	else printf("%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	printf("%s\n", message);
 	printf("%s\n", message);
@@ -54,17 +54,17 @@ static bool math_log (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 	// missing parameters check here
 	// missing parameters check here
 	// 1. number of args
 	// 1. number of args
 	// 2. args type
 	// 2. args type
-	
+
 	// assuming arg of type float (in a real example there should be a conversion if not float)
 	// assuming arg of type float (in a real example there should be a conversion if not float)
 	gravity_float_t n = VALUE_AS_FLOAT(args[1]);
 	gravity_float_t n = VALUE_AS_FLOAT(args[1]);
-	
+
 	// gravity can be compiled with FLOAT as 32 or 64 bit
 	// gravity can be compiled with FLOAT as 32 or 64 bit
 	#if GRAVITY_ENABLE_DOUBLE
 	#if GRAVITY_ENABLE_DOUBLE
 	gravity_float_t result = (gravity_float_t)log(n);
 	gravity_float_t result = (gravity_float_t)log(n);
 	#else
 	#else
 	gravity_float_t result = (gravity_float_t)logf(n);
 	gravity_float_t result = (gravity_float_t)logf(n);
 	#endif
 	#endif
-	
+
 	gravity_vm_setslot(vm, VALUE_FROM_FLOAT(result), rindex);
 	gravity_vm_setslot(vm, VALUE_FROM_FLOAT(result), rindex);
 	return true;
 	return true;
 }
 }
@@ -73,15 +73,15 @@ static bool math_pow (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 	// missing parameters check here
 	// missing parameters check here
 	// 1. number of args
 	// 1. number of args
 	// 2. args type
 	// 2. args type
-	
+
 	// assuming arg 1 of type float (in a real example there should be a conversion if not float)
 	// assuming arg 1 of type float (in a real example there should be a conversion if not float)
 	gravity_float_t n1 = VALUE_AS_FLOAT(args[1]);
 	gravity_float_t n1 = VALUE_AS_FLOAT(args[1]);
-	
+
 	// assuming arg 2 of type float (in a real example there should be a conversion if not float)
 	// assuming arg 2 of type float (in a real example there should be a conversion if not float)
 	gravity_float_t n2 = VALUE_AS_FLOAT(args[2]);
 	gravity_float_t n2 = VALUE_AS_FLOAT(args[2]);
-	
+
 	double result = pow((double)n1, (double)n2);
 	double result = pow((double)n1, (double)n2);
-	
+
 	gravity_vm_setslot(vm, VALUE_FROM_FLOAT((gravity_float_t)result), rindex);
 	gravity_vm_setslot(vm, VALUE_FROM_FLOAT((gravity_float_t)result), rindex);
 	return true;
 	return true;
 }
 }
@@ -91,51 +91,51 @@ static bool math_pow (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static void create_math_class (gravity_vm *vm) {
 static void create_math_class (gravity_vm *vm) {
 	// create a new class (a pair of classes since we are creating a class and its meta-class)
 	// create a new class (a pair of classes since we are creating a class and its meta-class)
 	gravity_class_t *c = gravity_class_new_pair(NULL, CLASS_NAME, NULL, 0, 0);
 	gravity_class_t *c = gravity_class_new_pair(NULL, CLASS_NAME, NULL, 0, 0);
-	
+
 	// we want to register properties and methods callback to its meta-class
 	// we want to register properties and methods callback to its meta-class
 	// so user can access Math.property and Math.method without the need to instantiate it
 	// so user can access Math.property and Math.method without the need to instantiate it
-	
+
 	// get its meta-class
 	// get its meta-class
 	gravity_class_t *meta = gravity_class_get_meta(c);
 	gravity_class_t *meta = gravity_class_get_meta(c);
-	
+
 	// start binding methods and properties (special methods) to the meta class
 	// start binding methods and properties (special methods) to the meta class
-	
+
 	// *** LOG METHOD ***
 	// *** LOG METHOD ***
 	// 1. create a gravity_function_t from the c function
 	// 1. create a gravity_function_t from the c function
 	gravity_function_t *logf = gravity_function_new_internal(NULL, NULL, math_log, 0);
 	gravity_function_t *logf = gravity_function_new_internal(NULL, NULL, math_log, 0);
-	
+
 	// 2. create a closure from the gravity_function_t
 	// 2. create a closure from the gravity_function_t
 	gravity_closure_t *logc = gravity_closure_new(NULL, logf);
 	gravity_closure_t *logc = gravity_closure_new(NULL, logf);
-	
+
 	// 3. bind closure VALUE to meta class
 	// 3. bind closure VALUE to meta class
 	gravity_class_bind(meta, "log", VALUE_FROM_OBJECT(logc));
 	gravity_class_bind(meta, "log", VALUE_FROM_OBJECT(logc));
-	
+
 	// *** POW METHOD ***
 	// *** POW METHOD ***
 	// 1. create a gravity_function_t from the c function
 	// 1. create a gravity_function_t from the c function
 	gravity_function_t *powf = gravity_function_new_internal(NULL, NULL, math_pow, 0);
 	gravity_function_t *powf = gravity_function_new_internal(NULL, NULL, math_pow, 0);
-	
+
 	// 2. create a closure from the gravity_function_t
 	// 2. create a closure from the gravity_function_t
 	gravity_closure_t *powc = gravity_closure_new(NULL, powf);
 	gravity_closure_t *powc = gravity_closure_new(NULL, powf);
-	
+
 	// 3. bind closure VALUE to meta class
 	// 3. bind closure VALUE to meta class
 	gravity_class_bind(meta, "pow", VALUE_FROM_OBJECT(powc));
 	gravity_class_bind(meta, "pow", VALUE_FROM_OBJECT(powc));
-	
+
 	// *** PI PROPERTY (getter only) ***
 	// *** PI PROPERTY (getter only) ***
 	// 1. create a gravity_function_t from the c function
 	// 1. create a gravity_function_t from the c function
 	gravity_function_t *pif = gravity_function_new_internal(NULL, NULL, math_pi, 0);
 	gravity_function_t *pif = gravity_function_new_internal(NULL, NULL, math_pi, 0);
-	
+
 	// 2. create a closure from the gravity_function_t
 	// 2. create a closure from the gravity_function_t
 	gravity_closure_t *pi_getter = gravity_closure_new(NULL, pif);
 	gravity_closure_t *pi_getter = gravity_closure_new(NULL, pif);
-	
+
 	// 3. create a new special function to represents getter and setter (NULL in this case)
 	// 3. create a new special function to represents getter and setter (NULL in this case)
 	gravity_function_t *f = gravity_function_new_special(vm, NULL, GRAVITY_COMPUTED_INDEX, pi_getter, NULL);
 	gravity_function_t *f = gravity_function_new_special(vm, NULL, GRAVITY_COMPUTED_INDEX, pi_getter, NULL);
-	
+
 	// 4. create a closure for the special function
 	// 4. create a closure for the special function
 	gravity_closure_t *closure_property = gravity_closure_new(NULL, f);
 	gravity_closure_t *closure_property = gravity_closure_new(NULL, f);
-	
+
 	// 5. bind closure VALUE to meta class
 	// 5. bind closure VALUE to meta class
 	gravity_class_bind(meta, "pi", VALUE_FROM_OBJECT(closure_property));
 	gravity_class_bind(meta, "pi", VALUE_FROM_OBJECT(closure_property));
-	
+
 	// LAST STEP
 	// LAST STEP
 	// register newly defined C class into Gravity VM
 	// register newly defined C class into Gravity VM
 	gravity_vm_setvalue(vm, CLASS_NAME, VALUE_FROM_OBJECT(c));
 	gravity_vm_setvalue(vm, CLASS_NAME, VALUE_FROM_OBJECT(c));
@@ -144,45 +144,45 @@ static void create_math_class (gravity_vm *vm) {
 // MARK: -
 // MARK: -
 
 
 int main(int argc, const char * argv[]) {
 int main(int argc, const char * argv[]) {
-	
+
 	// setup a minimal delegate
 	// setup a minimal delegate
 	gravity_delegate_t delegate = {
 	gravity_delegate_t delegate = {
 		.error_callback = report_error
 		.error_callback = report_error
 	};
 	};
-	
+
 	// compile source into a closure
 	// compile source into a closure
 	gravity_compiler_t *compiler = gravity_compiler_create(&delegate);
 	gravity_compiler_t *compiler = gravity_compiler_create(&delegate);
 	gravity_closure_t *closure = gravity_compiler_run(compiler, source, strlen(source), 0, true);
 	gravity_closure_t *closure = gravity_compiler_run(compiler, source, strlen(source), 0, true);
 	if (!closure) return -1;
 	if (!closure) return -1;
-	
+
 	// setup a new VM and a new fiber
 	// setup a new VM and a new fiber
 	gravity_vm *vm = gravity_vm_new(&delegate);
 	gravity_vm *vm = gravity_vm_new(&delegate);
-	
+
 	// transfer memory from compiler to VM and then free compiler
 	// transfer memory from compiler to VM and then free compiler
 	gravity_compiler_transfer(compiler, vm);
 	gravity_compiler_transfer(compiler, vm);
 	gravity_compiler_free(compiler);
 	gravity_compiler_free(compiler);
-	
+
 	// create a new math class with methods and properties and register it to the VM
 	// create a new math class with methods and properties and register it to the VM
 	create_math_class(vm);
 	create_math_class(vm);
-	
+
 	// expected result: 12.387436
 	// expected result: 12.387436
 	// pi = 3.1415
 	// pi = 3.1415
 	// n1 = log(pi) => 1.1447
 	// n1 = log(pi) => 1.1447
 	// n2 = pow(pi, 2.12) => 11.3221
 	// n2 = pow(pi, 2.12) => 11.3221
-	
+
 	// Math class is now available from Gravity code so we can start excuting previously compiled closure
 	// Math class is now available from Gravity code so we can start excuting previously compiled closure
 	if (gravity_vm_runmain(vm, closure)) {
 	if (gravity_vm_runmain(vm, closure)) {
 		gravity_value_t result = gravity_vm_result(vm);
 		gravity_value_t result = gravity_vm_result(vm);
 		double t = gravity_vm_time(vm);
 		double t = gravity_vm_time(vm);
-		
+
 		char buffer[512];
 		char buffer[512];
 		gravity_value_dump(result, buffer, sizeof(buffer));
 		gravity_value_dump(result, buffer, sizeof(buffer));
 		printf("RESULT: %s (in %.4f ms)\n\n", buffer, t);
 		printf("RESULT: %s (in %.4f ms)\n\n", buffer, t);
 	}
 	}
-	
+
 	// our Math C class was not exposed to the GC (we passed NULL as vm parameter) so we would need to manually free it here
 	// our Math C class was not exposed to the GC (we passed NULL as vm parameter) so we would need to manually free it here
 	// free class and its methods here
 	// free class and its methods here
-	
+
 	// free vm and base classes
 	// free vm and base classes
 	if (vm) gravity_vm_free(vm);
 	if (vm) gravity_vm_free(vm);
 	gravity_core_free();
 	gravity_core_free();

+ 14 - 14
api/exec_gravity.c

@@ -26,7 +26,7 @@ static void report_error (error_type_t error_type, const char *message,
 		case GRAVITY_WARNING: type = "WARNING"; break;
 		case GRAVITY_WARNING: type = "WARNING"; break;
 		case GRAVITY_ERROR_IO: type = "I/O"; break;
 		case GRAVITY_ERROR_IO: type = "I/O"; break;
 	}
 	}
-	
+
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("RUNTIME ERROR: ");
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("RUNTIME ERROR: ");
 	else printf("%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	else printf("%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	printf("%s\n", message);
 	printf("%s\n", message);
@@ -34,57 +34,57 @@ static void report_error (error_type_t error_type, const char *message,
 
 
 
 
 int main(int argc, const char * argv[]) {
 int main(int argc, const char * argv[]) {
-	
+
 	// setup a minimal delegate
 	// setup a minimal delegate
 	gravity_delegate_t delegate = {
 	gravity_delegate_t delegate = {
 		.error_callback = report_error
 		.error_callback = report_error
 	};
 	};
-	
+
 	// compile source into a closure
 	// compile source into a closure
 	gravity_compiler_t *compiler = gravity_compiler_create(&delegate);
 	gravity_compiler_t *compiler = gravity_compiler_create(&delegate);
 	gravity_closure_t *closure = gravity_compiler_run(compiler, source, strlen(source), 0, true);
 	gravity_closure_t *closure = gravity_compiler_run(compiler, source, strlen(source), 0, true);
 	if (!closure) return -1;
 	if (!closure) return -1;
-	
+
 	// setup a new VM and a new fiber
 	// setup a new VM and a new fiber
-	gravity_vm *vm = gravity_vm_new(&delegate);	
-	
+	gravity_vm *vm = gravity_vm_new(&delegate);
+
 	// transfer memory from compiler to VM and then free compiler
 	// transfer memory from compiler to VM and then free compiler
 	gravity_compiler_transfer(compiler, vm);
 	gravity_compiler_transfer(compiler, vm);
 	gravity_compiler_free(compiler);
 	gravity_compiler_free(compiler);
-	
+
 	// load closure into VM context
 	// load closure into VM context
 	gravity_vm_loadclosure(vm, closure);
 	gravity_vm_loadclosure(vm, closure);
-	
+
 	// create parameters (that must be boxed) for the closure
 	// create parameters (that must be boxed) for the closure
 	gravity_value_t n1 = VALUE_FROM_INT(30);
 	gravity_value_t n1 = VALUE_FROM_INT(30);
 	gravity_value_t n2 = VALUE_FROM_INT(50);
 	gravity_value_t n2 = VALUE_FROM_INT(50);
 	gravity_value_t params[2] = {n1, n2};
 	gravity_value_t params[2] = {n1, n2};
-	
+
 	// lookup add closure
 	// lookup add closure
 	gravity_value_t add = gravity_vm_getvalue(vm, "add", strlen("add"));
 	gravity_value_t add = gravity_vm_getvalue(vm, "add", strlen("add"));
 	if (!VALUE_ISA_CLOSURE(add)) return -2;
 	if (!VALUE_ISA_CLOSURE(add)) return -2;
-	
+
 	// execute add closure and print result
 	// execute add closure and print result
 	if (gravity_vm_runclosure(vm, VALUE_AS_CLOSURE(add), add, params, 2)) {
 	if (gravity_vm_runclosure(vm, VALUE_AS_CLOSURE(add), add, params, 2)) {
 		gravity_value_t result = gravity_vm_result(vm);
 		gravity_value_t result = gravity_vm_result(vm);
 		printf("add result ");
 		printf("add result ");
 		gravity_value_dump(result, NULL, 0);
 		gravity_value_dump(result, NULL, 0);
 	}
 	}
-	
+
 	// lookup mul closure
 	// lookup mul closure
 	gravity_value_t mul = gravity_vm_getvalue(vm, "mul", strlen("mul"));
 	gravity_value_t mul = gravity_vm_getvalue(vm, "mul", strlen("mul"));
 	if (!VALUE_ISA_CLOSURE(mul)) return -3;
 	if (!VALUE_ISA_CLOSURE(mul)) return -3;
-	
+
 	// execute mul closure and print result
 	// execute mul closure and print result
 	if (gravity_vm_runclosure(vm, VALUE_AS_CLOSURE(mul), mul, params, 2)) {
 	if (gravity_vm_runclosure(vm, VALUE_AS_CLOSURE(mul), mul, params, 2)) {
 		gravity_value_t result = gravity_vm_result(vm);
 		gravity_value_t result = gravity_vm_result(vm);
 		printf("mul result ");
 		printf("mul result ");
 		gravity_value_dump(result, NULL, 0);
 		gravity_value_dump(result, NULL, 0);
 	}
 	}
-	
+
 	// free vm and core classes
 	// free vm and core classes
 	gravity_vm_free(vm);
 	gravity_vm_free(vm);
 	gravity_core_free();
 	gravity_core_free();
-	
+
     return 0;
     return 0;
 }
 }

+ 20 - 20
docs/api.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -73,11 +73,11 @@
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">API</h1><hr>
          	<h1 class="section-header">API</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				Gravity can be extended at runtime using C API. The right step to proceed is usually to create a new class, then add methods and proporties to it and finally register that class inside the VM.
 				Gravity can be extended at runtime using C API. The right step to proceed is usually to create a new class, then add methods and proporties to it and finally register that class inside the VM.
 			</p>
 			</p>
@@ -88,53 +88,53 @@
 		printf("%s\n", message);
 		printf("%s\n", message);
 		exit(0);
 		exit(0);
 	}
 	}
-	
-	// function to be execute inside Gravity VM		
+
+	// function to be execute inside Gravity VM
 	bool my_function (gravity_vm *vm, gravity_value_t *args,
 	bool my_function (gravity_vm *vm, gravity_value_t *args,
 	                  uint16_t nargs, uint32_t rindex) {
 	                  uint16_t nargs, uint32_t rindex) {
 		// do something useful here
 		// do something useful here
 	}
 	}
-	
-	// Configure VM delegate		
+
+	// Configure VM delegate
 	gravity_delegate_t delegate = {.error_callback = report_error};
 	gravity_delegate_t delegate = {.error_callback = report_error};
-	
+
 	// Create a new VM
 	// Create a new VM
 	gravity_vm *vm = gravity_vm_new(&delegate);
 	gravity_vm *vm = gravity_vm_new(&delegate);
-	
+
 	// Create a new class
 	// Create a new class
 	gravity_class_t *c = gravity_class_new_pair (vm, "MyClass", NULL, 0, 0);
 	gravity_class_t *c = gravity_class_new_pair (vm, "MyClass", NULL, 0, 0);
-	
+
 	// Allocate and bind closures to the newly created class
 	// Allocate and bind closures to the newly created class
 	gravity_closure_t *closure = gravity_closure_new(vm, my_function);
 	gravity_closure_t *closure = gravity_closure_new(vm, my_function);
 	gravity_class_bind(c, "myfunc", VALUE_FROM_OBJECT(closure));
 	gravity_class_bind(c, "myfunc", VALUE_FROM_OBJECT(closure));
-	
+
 	// Register class inside VM
 	// Register class inside VM
 	gravity_vm_setvalue(vm, "MyClass", VALUE_FROM_OBJECT(c));
 	gravity_vm_setvalue(vm, "MyClass", VALUE_FROM_OBJECT(c));
 			</code></pre>
 			</code></pre>
-			
+
 			<p>Using the above C code a "MyClass" class has been registered inside the VM and ready to be used by Gravity:</p>
 			<p>Using the above C code a "MyClass" class has been registered inside the VM and ready to be used by Gravity:</p>
-			<pre><code class="swift">		
+			<pre><code class="swift">
 	func main() {
 	func main() {
 		// allocate a new class
 		// allocate a new class
 		var foo = MyClass();
 		var foo = MyClass();
-		
+
 		// execute the myfunc C function
 		// execute the myfunc C function
 		foo.myfunc();
 		foo.myfunc();
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<!--<h4 class="section-h4">Execute Gravity code from C</h4>
 			<!--<h4 class="section-h4">Execute Gravity code from C</h4>
 			<p></p>
 			<p></p>
 			<pre><code class="cpp">
 			<pre><code class="cpp">
 			</code></pre>-->
 			</code></pre>-->
-			
+
 			<h4 class="section-h4">Bridge API</h4>
 			<h4 class="section-h4">Bridge API</h4>
 			<p>Gravity C API offers much more flexibility using the delegate bridge API.
 			<p>Gravity C API offers much more flexibility using the delegate bridge API.
 			<br>TO DO: more information here.</p>
 			<br>TO DO: more information here.</p>
 			<br>TO DO: post objc bridge.</p>
 			<br>TO DO: post objc bridge.</p>
          	</div>
          	</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -147,14 +147,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 29 - 29
docs/classes.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,24 +75,24 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Class</h1><hr>
          	<h1 class="section-header">Class</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Every value in Gravity is an object, and every object is an instance of a class. Classes define an object's behavior and state. Behavior is defined by methods which live in the class. Every object of the same class supports the same methods. State is defined in fields, whose values are stored in each instance.<br><br>Like <a href="functions.html">functions</a> a <strong>Class is a first class object</strong>, that means that it can be stored in local variables (even in <a href="list.html">Lists</a> or <a href="map.html">Maps</a>), passed as a function parameter or returned by a function. Gravity supports <strong>nested classes</strong> and <strong>single inheritance</strong>.
 			Every value in Gravity is an object, and every object is an instance of a class. Classes define an object's behavior and state. Behavior is defined by methods which live in the class. Every object of the same class supports the same methods. State is defined in fields, whose values are stored in each instance.<br><br>Like <a href="functions.html">functions</a> a <strong>Class is a first class object</strong>, that means that it can be stored in local variables (even in <a href="list.html">Lists</a> or <a href="map.html">Maps</a>), passed as a function parameter or returned by a function. Gravity supports <strong>nested classes</strong> and <strong>single inheritance</strong>.
 			</p>
 			</p>
-			
+
 			<h4 class="section-h4">Defining a class</h4>
 			<h4 class="section-h4">Defining a class</h4>
 			<p>Like most programming languages the class keyword is used to declare a new class:</p>
 			<p>Like most programming languages the class keyword is used to declare a new class:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	class Italy {
 	class Italy {
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Instantiate a class</h4>
 			<h4 class="section-h4">Instantiate a class</h4>
 			<p>A class in gravity can be instantiated by simply executing it (without the new keyword):</p>
 			<p>A class in gravity can be instantiated by simply executing it (without the new keyword):</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var instance = Italy();
 	var instance = Italy();
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Methods</h4>
 			<h4 class="section-h4">Methods</h4>
 			<p>Functions declared inside a class are called methods and are used to add behaviors to objects that belongs to a specific class:</p>
 			<p>Functions declared inside a class are called methods and are used to add behaviors to objects that belongs to a specific class:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -102,43 +102,43 @@
 		}
 		}
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Properties</h4>
 			<h4 class="section-h4">Properties</h4>
 			<p>Variables declared inside a class are called properties and are used to add states to objects that belongs to a specific class:</p>
 			<p>Variables declared inside a class are called properties and are used to add states to objects that belongs to a specific class:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	class Italy {
 	class Italy {
 		var population = 60656000;
 		var population = 60656000;
 		var area = 301340; // in km2
 		var area = 301340; // in km2
-				
+
 		func density() {
 		func density() {
 			return population/area;
 			return population/area;
 		}
 		}
 	}
 	}
-			
+
 	func main() {
 	func main() {
 		var it = Italy();
 		var it = Italy();
 		return it.density();	// returns 201.287582
 		return it.density();	// returns 201.287582
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Class methods and properties</h4>
 			<h4 class="section-h4">Class methods and properties</h4>
 			<p>A class method (or property) is a method (or property) that operates on class objects rather than instances of the class. In Gravity you can specify a class method (or property) using the static keyword:</p>
 			<p>A class method (or property) is a method (or property) that operates on class objects rather than instances of the class. In Gravity you can specify a class method (or property) using the static keyword:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	class Italy {
 	class Italy {
 		static var population = 60656000;
 		static var population = 60656000;
 		static var area = 301340; // in km2
 		static var area = 301340; // in km2
-				
+
 		static func density() {
 		static func density() {
 			return population/area;
 			return population/area;
 		}
 		}
 	}
 	}
-			
+
 	func main() {
 	func main() {
 		return Italy.density();
 		return Italy.density();
 	}
 	}
-			
+
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Getters and Setters:</h4>
 			<h4 class="section-h4">Getters and Setters:</h4>
 			<p>As a convenient way to execute some code when a property is read or written, Gravity fully support custom getters and setters:</p>
 			<p>As a convenient way to execute some code when a property is read or written, Gravity fully support custom getters and setters:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -153,60 +153,60 @@
 			set (newb) {_a = newb * 50;}	// parameter name can be specified
 			set (newb) {_a = newb * 50;}	// parameter name can be specified
 		};
 		};
 	}
 	}
-			
+
 	func main() {
 	func main() {
 		var f = foo();
 		var f = foo();
 		f.a = 14;		// 14*100 = 1400
 		f.a = 14;		// 14*100 = 1400
 		return f.a;		// 1400/2 = 700
 		return f.a;		// 1400/2 = 700
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Adding methods at runtime:</h4>
 			<h4 class="section-h4">Adding methods at runtime:</h4>
 			<p>Sometimes you need to add methods at runtime to a particular instance, this is far more efficient than subclassing and in many cases it could be a decision than can be applied only at runtime. Gravity provides a convenient <strong>bind</strong> method specifically developed to manage this feature:</p>
 			<p>Sometimes you need to add methods at runtime to a particular instance, this is far more efficient than subclassing and in many cases it could be a decision than can be applied only at runtime. Gravity provides a convenient <strong>bind</strong> method specifically developed to manage this feature:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	class foo {
 	class foo {
 		func f1() {System.print("Hello from f1");}
 		func f1() {System.print("Hello from f1");}
 	}
 	}
-	
+
 	func main() {
 	func main() {
 		var obj = foo();
 		var obj = foo();
 		obj.f1();	// Output: Hello from f1
 		obj.f1();	// Output: Hello from f1
-		
+
 		// add a new f2 method to obj instance
 		// add a new f2 method to obj instance
 		obj.bind("f2", {System.print("Hello from f2");});
 		obj.bind("f2", {System.print("Hello from f2");});
 		obj.f2();	// Output: Hello from f2
 		obj.f2();	// Output: Hello from f2
-		
+
 		// replace f1 method
 		// replace f1 method
 		obj.bind("f1", {System.print("Hello from f1 new");});
 		obj.bind("f1", {System.print("Hello from f1 new");});
 		obj.f1();	// Output: Hello from f1 new
 		obj.f1();	// Output: Hello from f1 new
-		
+
 		// with unbind you can remove an existing method
 		// with unbind you can remove an existing method
 		obj.unbind("f2");
 		obj.unbind("f2");
 		obj.f2();	// RUNTIME ERROR: Unable to find f2
 		obj.f2();	// RUNTIME ERROR: Unable to find f2
 	}
 	}
 
 
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Nested classes:</h4>
 			<h4 class="section-h4">Nested classes:</h4>
 			<p>There are many cases where nested classes can lead to more readable and maintainable code, for example as a way of logically grouping classes that are only used in one place:</p>
 			<p>There are many cases where nested classes can lead to more readable and maintainable code, for example as a way of logically grouping classes that are only used in one place:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	class Database {
 	class Database {
 		public var query;
 		public var query;
-	
+
 		class RecordSet {
 		class RecordSet {
 			public var sql;
 			public var sql;
-		
+
 			public func run() {
 			public func run() {
 				if (!sql) return 0;
 				if (!sql) return 0;
 				System.print(sql);
 				System.print(sql);
 				return sql.length();
 				return sql.length();
 			}
 			}
-		
+
 			func init() {
 			func init() {
 				System.print("RecordSet init called");
 				System.print("RecordSet init called");
 			}
 			}
 		}
 		}
-	
+
 		func init() {
 		func init() {
 			System.print("Database init called");
 			System.print("Database init called");
 			query = RecordSet();
 			query = RecordSet();
@@ -219,10 +219,10 @@
 		return db.query.run();
 		return db.query.run();
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Access specifiers</h4>
 			<h4 class="section-h4">Access specifiers</h4>
 			<p>The public and private keywords can be used to restrict access to specific part of code.</p>
 			<p>The public and private keywords can be used to restrict access to specific part of code.</p>
-			
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -236,14 +236,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 10 - 10
docs/closures.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,7 +75,7 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Closure</h1><hr>
          	<h1 class="section-header">Closure</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures can capture and store references to any constants and variables from the context in which they are defined. Closures can be nested and can be anonymous (without a name):
 			Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures can capture and store references to any constants and variables from the context in which they are defined. Closures can be nested and can be anonymous (without a name):
 			</p>
 			</p>
@@ -91,25 +91,25 @@
 		return addTen(20);	// result is 30
 		return addTen(20);	// result is 30
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Disassemble</h4>
 			<h4 class="section-h4">Disassemble</h4>
 			<p>A closure can be disassembled in order to reveal its bytecode:</p>
 			<p>A closure can be disassembled in order to reveal its bytecode:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	func sum (a,b) {
 	func sum (a,b) {
 		return a + b;
 		return a + b;
 	}
 	}
-	
+
 	func main() {
 	func main() {
 		System.print(sum.disassemble());
 		System.print(sum.disassemble());
 	}
 	}
-	
+
 	// Output:
 	// Output:
 	// 000000 ADD 3 1 2
 	// 000000 ADD 3 1 2
 	// 000001 RET 3
 	// 000001 RET 3
 			</code></pre>
 			</code></pre>
-			
+
 			<p>TO DO: more examples and explanations</p>
 			<p>TO DO: more examples and explanations</p>
-			
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -123,14 +123,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 7 - 7
docs/contributing.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -73,11 +73,11 @@
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Contributing</h1><hr>
          	<h1 class="section-header">Contributing</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				If you find any grammatical issue, please report it using Github Issues. Or, if some sentence or paragraph is difficult to understand, feel free to make a pull request. This book is in active development and I'll regularly update and improve it. I am not a native English speaker so feel free to correct me if something is not properly written.<br><br>If you have any question related to the material or the development of the book, feel free to open a GitHub issue or to contact me.</p>
 				If you find any grammatical issue, please report it using Github Issues. Or, if some sentence or paragraph is difficult to understand, feel free to make a pull request. This book is in active development and I'll regularly update and improve it. I am not a native English speaker so feel free to correct me if something is not properly written.<br><br>If you have any question related to the material or the development of the book, feel free to open a GitHub issue or to contact me.</p>
 				<h4 class="section-h4">About me</h4>
 				<h4 class="section-h4">About me</h4>
@@ -89,7 +89,7 @@
 			</p>
 			</p>
          	</div>
          	</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -102,14 +102,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 6 - 6
docs/control-flow.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,11 +75,11 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Control flow</h1><hr>
          	<h1 class="section-header">Control flow</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Gravity provides a variety of control flow statements. Control flow is used to determine which chunks of code are executed and how many times. Branching statements and expressions decide whether or not to execute some code and looping ones execute something more than once.
 			Gravity provides a variety of control flow statements. Control flow is used to determine which chunks of code are executed and how many times. Branching statements and expressions decide whether or not to execute some code and looping ones execute something more than once.
 			</p>
 			</p>
-			
+
 			<h4 class="section-h4">If statement</h4>
 			<h4 class="section-h4">If statement</h4>
 			<p>It is often useful to execute different pieces of code based on certain conditions. You might want to run an extra piece of code when an error occurs, or to display a message when a value becomes too high or too low. To do this, you make parts of your code conditional. In its simplest form, the if statement has a single if condition. It executes a set of statements only if that condition is true:</p>
 			<p>It is often useful to execute different pieces of code based on certain conditions. You might want to run an extra piece of code when an error occurs, or to display a message when a value becomes too high or too low. To do this, you make parts of your code conditional. In its simplest form, the if statement has a single if condition. It executes a set of statements only if that condition is true:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -125,14 +125,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/enum.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,9 +75,9 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Enum</h1><hr>
          	<h1 class="section-header">Enum</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
-			Enums defines a common type for a group of related values, if you are familiar with C, you will know that C enumerations assign related names to a set of integer values, enum in Gravity are much more flexible and enables you to assign even non integer values: 
+			Enums defines a common type for a group of related values, if you are familiar with C, you will know that C enumerations assign related names to a set of integer values, enum in Gravity are much more flexible and enables you to assign even non integer values:
 			</p>
 			</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	enum state {
 	enum state {
@@ -87,31 +87,31 @@
 		undetermined = 666,
 		undetermined = 666,
 		error			// 667
 		error			// 667
 	};
 	};
-	
+
 	enum math {
 	enum math {
 		pi = 3.141592,
 		pi = 3.141592,
 		e = 2.718281,
 		e = 2.718281,
 		goldratio = 1.618033
 		goldratio = 1.618033
 	};
 	};
-	
+
 	enum company {
 	enum company {
 		ceo = "Gauss",
 		ceo = "Gauss",
 		cto = "Eurel",
 		cto = "Eurel",
 		cfo = "Nostradamus"
 		cfo = "Nostradamus"
 	}
 	}
-	
+
 	enum mixed {
 	enum mixed {
 		one = "Hello World",
 		one = "Hello World",
 		two = 3.1415,
 		two = 3.1415,
 		three = 666,
 		three = 666,
 		four = true
 		four = true
 	}
 	}
-	
+
 	func main() {
 	func main() {
 		var a = state.active;	// a = 1
 		var a = state.active;	// a = 1
 		var b = math.pi;	// b = 3.1415
 		var b = math.pi;	// b = 3.1415
 		var c = company.ceo;	// c = "Gauss"
 		var c = company.ceo;	// c = "Gauss"
-		var d = mixed.four;	// d = true 
+		var d = mixed.four;	// d = true
 	}
 	}
 			</code></pre>
 			</code></pre>
 			<p>Enum is a static operator, which means that at compile time the real value of the enum item is automatically replaced by Gravity.</p>
 			<p>Enum is a static operator, which means that at compile time the real value of the enum item is automatically replaced by Gravity.</p>
@@ -128,14 +128,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 8 - 8
docs/fibers.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -73,11 +73,11 @@
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Fiber</h1><hr>
          	<h1 class="section-header">Fiber</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 			A Fibers (or coroutine as called in other languages) are special functions that can be interrupted at any time by the user. When a conventional function is invoked, execution begins at the start, and once a function exits, it is finished. By contrast, Fibers can exit by calling other Fibers, which may later return to the point where they were invoked in the original coroutine:
 			A Fibers (or coroutine as called in other languages) are special functions that can be interrupted at any time by the user. When a conventional function is invoked, execution begins at the start, and once a function exits, it is finished. By contrast, Fibers can exit by calling other Fibers, which may later return to the point where they were invoked in the original coroutine:
 			</p>
 			</p>
@@ -88,7 +88,7 @@
 			Fiber.yield()
 			Fiber.yield()
 			System.print("fiber 2");
 			System.print("fiber 2");
 		});
 		});
-	
+
 		System.print("main 1");
 		System.print("main 1");
 		fiber()
 		fiber()
 		System.print("main 2");
 		System.print("main 2");
@@ -105,7 +105,7 @@
 			<p>TO DO: more explanations and examples</p>
 			<p>TO DO: more explanations and examples</p>
          	</div>
          	</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -118,14 +118,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 26 - 26
docs/functions.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,7 +75,7 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Function</h1><hr>
          	<h1 class="section-header">Function</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Functions are first class objects like <a href="types.html">Int</a> or <a href="types.html">String</a> and can be stored in local variables (even in <a href="list.html">Lists</a> or <a href="map.html">Maps</a>), passed as function parameters or returned by a function. Functions can be implemented in Gravity or in a <a href="api.html">native language</a> with calling conventions compatible with ANSI C.<br><br>Functions are called by value. This means that foo(1) calls the function which is the value of the variable foo. Calling a value that is not a function will raise a runtime error.
 			Functions are first class objects like <a href="types.html">Int</a> or <a href="types.html">String</a> and can be stored in local variables (even in <a href="list.html">Lists</a> or <a href="map.html">Maps</a>), passed as function parameters or returned by a function. Functions can be implemented in Gravity or in a <a href="api.html">native language</a> with calling conventions compatible with ANSI C.<br><br>Functions are called by value. This means that foo(1) calls the function which is the value of the variable foo. Calling a value that is not a function will raise a runtime error.
 			</p>
 			</p>
@@ -86,62 +86,62 @@
 		return a + b;
 		return a + b;
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<pre><code class="swift">
 			<pre><code class="swift">
 	func f1() {
 	func f1() {
 		return 10;
 		return 10;
 	}
 	}
-			
+
 	func f2() {
 	func f2() {
 		return f1;
 		return f1;
 	}
 	}
-			
+
 	func main() {
 	func main() {
 		// a is now function f2
 		// a is now function f2
 		var a = f2;
 		var a = f2;
-				
+
 		// b is now the return value of f2 which is function f1
 		// b is now the return value of f2 which is function f1
 		var b = a();
 		var b = a();
-				
+
 		// return value is f1() which is 10
 		// return value is f1() which is 10
 		return b();
 		return b();
-				
+
 		// above code is equivalent to
 		// above code is equivalent to
 		return f2()();
 		return f2()();
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Function parameters</h4>
 			<h4 class="section-h4">Function parameters</h4>
-			<p>Functions aren’t very useful if you can’t pass values to them so you can provide a parameter list in the function declaration. Gravity performs no check on the number of parameters so you can call a function providing more or less parameters.</p> 
+			<p>Functions aren’t very useful if you can’t pass values to them so you can provide a parameter list in the function declaration. Gravity performs no check on the number of parameters so you can call a function providing more or less parameters.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	func sum(a, b) {
 	func sum(a, b) {
 		return a + b;
 		return a + b;
 	}
 	}
-			
+
 	// execute the sum function
 	// execute the sum function
 	// and returns 30 as result
 	// and returns 30 as result
 	sum(10,20);
 	sum(10,20);
 			</code></pre>
 			</code></pre>
-			
+
 			<p>If a function is called with missing arguments (less than declared), the missing values are set to <strong>undefined</strong>.</p>
 			<p>If a function is called with missing arguments (less than declared), the missing values are set to <strong>undefined</strong>.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	// sum modified to take in account missing arguments
 	// sum modified to take in account missing arguments
 	func sum(a, b) {
 	func sum(a, b) {
 		// equivalent to if (a == undefined) a = 30;
 		// equivalent to if (a == undefined) a = 30;
 		if (!a) a = 30;
 		if (!a) a = 30;
-		
+
 		// equivalent to if (b == undefined) b = 50;
 		// equivalent to if (b == undefined) b = 50;
 		if (!b) b = 50;
 		if (!b) b = 50;
-		
+
 		return a + b;
 		return a + b;
 	}
 	}
-			
+
 	// execute the sum function without any argument
 	// execute the sum function without any argument
 	// a has a 30 default value and b has a 50 default value
 	// a has a 30 default value and b has a 50 default value
 	// return value is 80
 	// return value is 80
 	sum();
 	sum();
 			</code></pre>
 			</code></pre>
-			
+
 			<p>If a function is called with more arguments (more than declared), the additional arguments can be accessed using the <strong>_args</strong> array.</p>
 			<p>If a function is called with more arguments (more than declared), the additional arguments can be accessed using the <strong>_args</strong> array.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	// sum modified to accept a variable number of arguments
 	// sum modified to accept a variable number of arguments
@@ -152,29 +152,29 @@
 		}
 		}
 		return tot;
 		return tot;
 	}
 	}
-			
+
 	// execute the sum function with a variable number
 	// execute the sum function with a variable number
 	// of arguments returns 550 as result
 	// of arguments returns 550 as result
 	sum(10,20,30,40,50,60,70,80,90,100);
 	sum(10,20,30,40,50,60,70,80,90,100);
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Recursion</h4>
 			<h4 class="section-h4">Recursion</h4>
-			<p>Function recursion is fully supported in Gravity (current function can be accessed using the _func reserved keyword):</p> 
+			<p>Function recursion is fully supported in Gravity (current function can be accessed using the _func reserved keyword):</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	func fibonacci (n) {
 	func fibonacci (n) {
 		if (n<2) return n;
 		if (n<2) return n;
 		// could be written as return _func(n-2) + _func(n-1)
 		// could be written as return _func(n-2) + _func(n-1)
 		return fibonacci(n-2) + fibonacci(n-1);
 		return fibonacci(n-2) + fibonacci(n-1);
  	}
  	}
- 
+
 	func main() {
 	func main() {
 		return fibonacci(20);
 		return fibonacci(20);
  	}
  	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Returning values</h4>
 			<h4 class="section-h4">Returning values</h4>
-			<p>A function without a return statement returns <strong>null</strong> by default. You can explicitly return a value using a return statement.</p> 
-			
+			<p>A function without a return statement returns <strong>null</strong> by default. You can explicitly return a value using a return statement.</p>
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -188,14 +188,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 1 - 1
docs/getting-started.html

@@ -108,7 +108,7 @@
 				<ul>
 				<ul>
 					<li><a href="https://github.com/Dohxis/vscode-gravity">Visual Studio Code</a></li>
 					<li><a href="https://github.com/Dohxis/vscode-gravity">Visual Studio Code</a></li>
 					<li><a href="https://github.com/Tribex/atom-language-gravity">Atom</a></li>
 					<li><a href="https://github.com/Tribex/atom-language-gravity">Atom</a></li>
-					<li><a href="https://github.com/hallzy/gravity.vim">vim</a></li> 
+					<li><a href="https://github.com/hallzy/gravity.vim">vim</a></li>
 					<li><a href="https://github.com/marcobambini/bbedit-gravity">BBEdit/TextWrangler</a></li>
 					<li><a href="https://github.com/marcobambini/bbedit-gravity">BBEdit/TextWrangler</a></li>
 				</ul>
 				</ul>
 			</p>
 			</p>

+ 7 - 7
docs/index.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -73,11 +73,11 @@
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Introduction</h1><hr>
          	<h1 class="section-header">Introduction</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				<strong>Gravity</strong> is a powerful, dynamically typed, lightweight, embeddable programming language written in C without any external dependency (except stdlib). It is a class based concurrent scripting language with a modern <a href="https://github.com/apple/swift">Swift</a> like syntax.<br><br>
 				<strong>Gravity</strong> is a powerful, dynamically typed, lightweight, embeddable programming language written in C without any external dependency (except stdlib). It is a class based concurrent scripting language with a modern <a href="https://github.com/apple/swift">Swift</a> like syntax.<br><br>
 				<strong>Gravity</strong> supports procedural programming, object-oriented programming, functional programming and data-driven programming. Thanks to built-in special methods it can also be used as a prototype-based programming language.</p>
 				<strong>Gravity</strong> supports procedural programming, object-oriented programming, functional programming and data-driven programming. Thanks to built-in special methods it can also be used as a prototype-based programming language.</p>
@@ -85,7 +85,7 @@
 				<p><strong>Gravity</strong> has been developed from scratch for the <a href="http://creolabs.com/">Creo</a> project in order to offer an easy way to write portable code for the iOS and Android platforms. It is written in portable C code that can be compiled in any platform using a C99 compiler. VM code is about 2K lines long, multipass compiler code is about 3K lines and shared code is about 2K lines. Compiler and virtual machine together add less than 200KB to the executable size in a 64bit system.</p>
 				<p><strong>Gravity</strong> has been developed from scratch for the <a href="http://creolabs.com/">Creo</a> project in order to offer an easy way to write portable code for the iOS and Android platforms. It is written in portable C code that can be compiled in any platform using a C99 compiler. VM code is about 2K lines long, multipass compiler code is about 3K lines and shared code is about 2K lines. Compiler and virtual machine together add less than 200KB to the executable size in a 64bit system.</p>
          	</div>
          	</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -98,14 +98,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 12 - 12
docs/internals/1_changelog.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html" class="active"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html" class="active"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,17 +89,17 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Change log</h1><hr>
          	<h1 class="section-header">Change log</h1><hr>
@@ -107,10 +107,10 @@
 				<ul>
 				<ul>
 					<li>First public release</li>
 					<li>First public release</li>
 				</ul>
 				</ul>
-				
+
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -123,14 +123,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 12 - 12
docs/internals/1_files.html

@@ -39,7 +39,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -49,7 +49,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html" class="active"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html" class="active"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -62,7 +62,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -79,7 +79,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -90,21 +90,21 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Gravity files</h1><hr>
          	<h1 class="section-header">Gravity files</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				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.
 				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.
 			</p>
 			</p>
@@ -149,7 +149,7 @@
 			</ul>
 			</ul>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -162,14 +162,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_array.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Array</h1><hr>
          	<h1 class="section-header">Array</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_class.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html" class="active"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html" class="active"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Class and metaclass</h1><hr>
          	<h1 class="section-header">Class and metaclass</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_hash.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Hash</h1><hr>
          	<h1 class="section-header">Hash</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_json.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">JSON</h1><hr>
          	<h1 class="section-header">JSON</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_memory.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Memory</h1><hr>
          	<h1 class="section-header">Memory</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_overview.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html" class="active"><span>Overview</span></a></li>
 					<li><a href="2_overview.html" class="active"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Overview</h1><hr>
          	<h1 class="section-header">Overview</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_utils.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Utils</h1><hr>
          	<h1 class="section-header">Utils</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_visitor.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Visitor Pattern</h1><hr>
          	<h1 class="section-header">Visitor Pattern</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/2_vm.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html" class="active"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html" class="active"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Stack vs Register VM</h1><hr>
          	<h1 class="section-header">Stack vs Register VM</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_ast.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Abstract Syntax Tree</h1><hr>
          	<h1 class="section-header">Abstract Syntax Tree</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_bytecode.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html" class="active"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html" class="active"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Bytecode</h1><hr>
          	<h1 class="section-header">Bytecode</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_codegen.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Code Generation</h1><hr>
          	<h1 class="section-header">Code Generation</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_grammar.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Grammar</h1><hr>
          	<h1 class="section-header">Grammar</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_ircode.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Intermediate Representation</h1><hr>
          	<h1 class="section-header">Intermediate Representation</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_lexer.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Lexer</h1><hr>
          	<h1 class="section-header">Lexer</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_opcodes.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">VM Opcodes</h1><hr>
          	<h1 class="section-header">VM Opcodes</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_optimizer.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html" class="active"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html" class="active"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Optimizer</h1><hr>
          	<h1 class="section-header">Optimizer</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_overview.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html" class="active"><span>Overview</span></a></li>
 					<li><a href="3_overview.html" class="active"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Compiler Overview</h1><hr>
          	<h1 class="section-header">Compiler Overview</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_parser.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Parser</h1><hr>
          	<h1 class="section-header">Parser</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_prattparser.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Pratt Parser</h1><hr>
          	<h1 class="section-header">Pratt Parser</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_semantic.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Semantic Analyses</h1><hr>
          	<h1 class="section-header">Semantic Analyses</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/3_symboltable.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Symbol Table</h1><hr>
          	<h1 class="section-header">Symbol Table</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_base.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html" class="active"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html" class="active"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Base Classes</h1><hr>
          	<h1 class="section-header">Base Classes</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_gc.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html" class="active"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html" class="active"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Garbage Collector</h1><hr>
          	<h1 class="section-header">Garbage Collector</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_memory.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Memory Ownership</h1><hr>
          	<h1 class="section-header">Memory Ownership</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_objmodel.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Object Model</h1><hr>
          	<h1 class="section-header">Object Model</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_overview.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html" class="active"><span>Overview</span></a></li>
 					<li><a href="4_overview.html" class="active"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Runtime Overview</h1><hr>
          	<h1 class="section-header">Runtime Overview</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_performance.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Efficient Interpreter</h1><hr>
          	<h1 class="section-header">Efficient Interpreter</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/4_vm.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Virtual Machine</h1><hr>
          	<h1 class="section-header">Virtual Machine</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/5_jit.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html" class="active"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html" class="active"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">LLVM JIT</h1><hr>
          	<h1 class="section-header">LLVM JIT</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 11 - 11
docs/internals/5_overview.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,24 +89,24 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html" class="active"><span>Overview</span></a></li>
 					<li><a href="5_overview.html" class="active"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">LLVM Overview</h1><hr>
          	<h1 class="section-header">LLVM Overview</h1><hr>
          	<p>Content will be available soon.</p>
          	<p>Content will be available soon.</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -119,14 +119,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 12 - 12
docs/internals/index.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -48,7 +48,7 @@
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_changelog.html"><span>Changelog</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 					<li><a href="1_files.html"><span>Gravity files</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>2. PREREQUISITES</h4>
 				<h4>2. PREREQUISITES</h4>
 				<ul>
 				<ul>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
 					<li><a href="2_overview.html"><span>Overview</span></a></li>
@@ -61,7 +61,7 @@
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_vm.html"><span>Stack vs Register VM</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 					<li><a href="2_class.html"><span>Class and metaclass</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>3. COMPILER</h4>
 				<h4>3. COMPILER</h4>
 				<ul>
 				<ul>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
 					<li><a href="3_overview.html"><span>Overview</span></a></li>
@@ -78,7 +78,7 @@
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_optimizer.html"><span>Optimizer</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 					<li><a href="3_bytecode.html"><span>Bytecode</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>4. RUNTIME</h4>
 				<h4>4. RUNTIME</h4>
 				<ul>
 				<ul>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
 					<li><a href="4_overview.html"><span>Overview</span></a></li>
@@ -89,21 +89,21 @@
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_base.html"><span>Base Classes</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 					<li><a href="4_gc.html"><span>Garbage Collector</span></a></li>
 				</ul>
 				</ul>
-				
+
 				<h4>5. LLVM</h4>
 				<h4>5. LLVM</h4>
 				<ul>
 				<ul>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_overview.html"><span>Overview</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 					<li><a href="5_jit.html"><span>LLVM JIT</span></a></li>
 				</ul>
 				</ul>
-				
+
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Introduction</h1><hr>
          	<h1 class="section-header">Introduction</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				When I started developing the Gravity programming language I knew nothing about how to develop an interpreter or how to traverse an AST. This project proved to be an invaluable experience to me and I am sure that developing a programming language from scratch is the best way to become a much better developer with a deeper understanding about what happens inside the compiler we use every single day.<br><br>
 				When I started developing the Gravity programming language I knew nothing about how to develop an interpreter or how to traverse an AST. This project proved to be an invaluable experience to me and I am sure that developing a programming language from scratch is the best way to become a much better developer with a deeper understanding about what happens inside the compiler we use every single day.<br><br>
 				I'd like to collect all my experience in this book, trying to not assume any prior knowledge except the C language. This book guides you to gain the foundational knowledge required to write a new programming language from scratch and will give you concrete answers to questions like what is really a closure or how a garbage collector works under the hood.<br><br></p>
 				I'd like to collect all my experience in this book, trying to not assume any prior knowledge except the C language. This book guides you to gain the foundational knowledge required to write a new programming language from scratch and will give you concrete answers to questions like what is really a closure or how a garbage collector works under the hood.<br><br></p>
@@ -118,7 +118,7 @@
 				</p>
 				</p>
 			</div>
 			</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -131,14 +131,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script src="../scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 16 - 16
docs/lists.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,17 +75,17 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">List</h1><hr>
          	<h1 class="section-header">List</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Lists (or arrays) are simple sequence of objects, their size is dynamic and their index starts always from 0. They provide fast random access to their elements. You can create a list by placing a sequence of comma-separated expressions inside square brackets:
 			Lists (or arrays) are simple sequence of objects, their size is dynamic and their index starts always from 0. They provide fast random access to their elements. You can create a list by placing a sequence of comma-separated expressions inside square brackets:
 			</p>
 			</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var r = [1, 2, "Hello", 3.1415, true];
 	var r = [1, 2, "Hello", 3.1415, true];
-	
+
 	// list has a count property
 	// list has a count property
 	var n = r.count;	// n is 5
 	var n = r.count;	// n is 5
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Accessing elements</h4>
 			<h4 class="section-h4">Accessing elements</h4>
 			<p>You can access an element from a list by calling the subscript operator [] on it with the index of the element you want. Like most languages, indices start at zero:
 			<p>You can access an element from a list by calling the subscript operator [] on it with the index of the element you want. Like most languages, indices start at zero:
 			</p>
 			</p>
@@ -94,32 +94,32 @@
 	names[0];	// "Mark"
 	names[0];	// "Mark"
 	names[2];	// "Paul"
 	names[2];	// "Paul"
 			</code></pre>
 			</code></pre>
-			
+
 			<p>Negative indices counts backwards from the end:</p>
 			<p>Negative indices counts backwards from the end:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var names = ["Mark", "Andrew", "Paul", "Ross", "Frank", "Max"];
 	var names = ["Mark", "Andrew", "Paul", "Ross", "Frank", "Max"];
 	names[-1];	// "Max"
 	names[-1];	// "Max"
 	names[-2];	// "Frank"
 	names[-2];	// "Frank"
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Iterating elements</h4>
 			<h4 class="section-h4">Iterating elements</h4>
-			<p>The subscript operator works well for finding values when you know the key you’re looking for, but sometimes you want to see everything that’s in the list. Since the List class implements the iterator method, you can easily use it in a for loop:</p> 
+			<p>The subscript operator works well for finding values when you know the key you’re looking for, but sometimes you want to see everything that’s in the list. Since the List class implements the iterator method, you can easily use it in a for loop:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var people = ["Mark", "Andrew", "Paul", "Ross", "Frank", "Max"];
 	var people = ["Mark", "Andrew", "Paul", "Ross", "Frank", "Max"];
 	for (var name in people) {
 	for (var name in people) {
 		System.print("Current name is " + name);
 		System.print("Current name is " + name);
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Adding elements</h4>
 			<h4 class="section-h4">Adding elements</h4>
 			<p>A List instance can be expanded by setting an index that is greater than the current size of the list:</p>
 			<p>A List instance can be expanded by setting an index that is greater than the current size of the list:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var list = [10,20,30,40,50];
 	var list = [10,20,30,40,50];
 	list[30] = 22;	// list contains now 31 elements (index 0...30)
 	list[30] = 22;	// list contains now 31 elements (index 0...30)
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">List as a stack</h4>
 			<h4 class="section-h4">List as a stack</h4>
-			<p>The List class implements the push/pop methods as a convenient way to treat a list as a stack:</p> 
+			<p>The List class implements the push/pop methods as a convenient way to treat a list as a stack:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var list = [10,20,30,40,50];
 	var list = [10,20,30,40,50];
 	list.push(100);		// add 100 to the list
 	list.push(100);		// add 100 to the list
@@ -133,15 +133,15 @@
 	var list = [1, 2, "Hello", 3.1415, true];
 	var list = [1, 2, "Hello", 3.1415, true];
 	return list.contains(3.1415); // Returns: true
 	return list.contains(3.1415); // Returns: true
 			</code></pre>
 			</code></pre>
-            
+
 			<h4 class="section-h4">List Joins</h4>
 			<h4 class="section-h4">List Joins</h4>
 			<p>The List class implements the join method as a convenient way to
 			<p>The List class implements the join method as a convenient way to
-			interpret a list as a string:</p> 
+			interpret a list as a string:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var list = [1,2,3,4,5];
 	var list = [1,2,3,4,5];
 	list.join(" + "); // Becomes: "1 + 2 + 3 + 4 + 5"
 	list.join(" + "); // Becomes: "1 + 2 + 3 + 4 + 5"
 			</code></pre>
 			</code></pre>
-            
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -154,14 +154,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 13 - 13
docs/loops.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,38 +75,38 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Loop</h1><hr>
          	<h1 class="section-header">Loop</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
-			
+
 			<h4 class="section-h4">While loop</h4>
 			<h4 class="section-h4">While loop</h4>
 			<p>A while loop performs a set of statements until a condition becomes false. These kinds of loops are best used when the number of iterations is not known before the first iteration begins.</p>
 			<p>A while loop performs a set of statements until a condition becomes false. These kinds of loops are best used when the number of iterations is not known before the first iteration begins.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	func main() {
 	func main() {
 		var i = 0;
 		var i = 0;
-			
+
 		while (i < 50000) {
 		while (i < 50000) {
 			i += 1;
 			i += 1;
 		}
 		}
-			
+
 		return i;
 		return i;
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Repeat-while loop</h4>
 			<h4 class="section-h4">Repeat-while loop</h4>
 			<p>The other variation of the while loop, known as the repeat-while loop, performs a single pass through the loop block first, before considering the loop’s condition. It then continues to repeat the loop until the condition is false.
 			<p>The other variation of the while loop, known as the repeat-while loop, performs a single pass through the loop block first, before considering the loop’s condition. It then continues to repeat the loop until the condition is false.
 			</p>
 			</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	func main() {
 	func main() {
 		var i = 0;
 		var i = 0;
-				
+
 		repeat {
 		repeat {
 			i += 1;
 			i += 1;
 		} while (i < 50000);
 		} while (i < 50000);
-				
+
 		return i;
 		return i;
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">For loop</h4>
 			<h4 class="section-h4">For loop</h4>
 			<p>You can access an element from a list by calling the subscript operator [] on it with the index of the element you want. Like most languages, indices start at zero:</p>
 			<p>You can access an element from a list by calling the subscript operator [] on it with the index of the element you want. Like most languages, indices start at zero:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -117,7 +117,7 @@
 	return count;
 	return count;
 			</code></pre>
 			</code></pre>
 			<p>The for in loop can be used over any object that supports iteration, such as <a href="lists.html">Lists</a>, Strings or <a href="maps.html">Maps</a>.</p>
 			<p>The for in loop can be used over any object that supports iteration, such as <a href="lists.html">Lists</a>, Strings or <a href="maps.html">Maps</a>.</p>
-         	
+
          	<h4 class="section-h4">Loop method</h4>
          	<h4 class="section-h4">Loop method</h4>
          	<p>Performing a loop is very common operation in any programming language, so Gravity adds a very convenient way to run a loop by adding a special loop method to some classes (Int, Range, List, String and Map) that accepts a <a href="closures.html">closure</a> as parameter:</p>
          	<p>Performing a loop is very common operation in any programming language, so Gravity adds a very convenient way to run a loop by adding a special loop method to some classes (Int, Range, List, String and Map) that accepts a <a href="closures.html">closure</a> as parameter:</p>
          	<pre><code class="swift">
          	<pre><code class="swift">
@@ -205,14 +205,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 13 - 13
docs/maps.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,7 +75,7 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Map</h1><hr>
          	<h1 class="section-header">Map</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Maps are associative containers implemented as pairs each of which maps a key to a value.
 			Maps are associative containers implemented as pairs each of which maps a key to a value.
 			You can create a map by placing a series of comma-separated entries inside square brackets. Each entry is a key and a value separated by a colon:
 			You can create a map by placing a series of comma-separated entries inside square brackets. Each entry is a key and a value separated by a colon:
@@ -83,14 +83,14 @@
 			<pre><code class="swift">
 			<pre><code class="swift">
 	// create a new map with 4 entries
 	// create a new map with 4 entries
 	var d = ["Mark":1, "Andrew":2, "Paul":3, "Ross":4];
 	var d = ["Mark":1, "Andrew":2, "Paul":3, "Ross":4];
-	
+
 	// map has a count property
 	// map has a count property
 	var n = d.count;	// n is 4
 	var n = d.count;	// n is 4
-	
+
 	// create an empty map
 	// create an empty map
 	var map = [:];
 	var map = [:];
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Looking up values</h4>
 			<h4 class="section-h4">Looking up values</h4>
 			<p>You can access an element from a list by calling the subscript operator [] on it with the key of the element you want:
 			<p>You can access an element from a list by calling the subscript operator [] on it with the key of the element you want:
 			</p>
 			</p>
@@ -99,23 +99,23 @@
 	names["Mark"];		// 1
 	names["Mark"];		// 1
 	names["Andrew"];	// 2
 	names["Andrew"];	// 2
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Iterating elements</h4>
 			<h4 class="section-h4">Iterating elements</h4>
-			<p>The subscript operator works well for finding values when you know the key you’re looking for, but sometimes you want to see everything that’s in the map. Since the Map class implements the iterator method (through the keys method), you can easily use it in a for loop:</p> 
+			<p>The subscript operator works well for finding values when you know the key you’re looking for, but sometimes you want to see everything that’s in the map. Since the Map class implements the iterator method (through the keys method), you can easily use it in a for loop:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var people = ["Mark":1, "Andrew":2, "Paul":3, "Ross":4];
 	var people = ["Mark":1, "Andrew":2, "Paul":3, "Ross":4];
 	for (var name in people.keys()) {
 	for (var name in people.keys()) {
 		System.print("Current name is " + name);
 		System.print("Current name is " + name);
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Adding elements</h4>
 			<h4 class="section-h4">Adding elements</h4>
 			<p>An item can be added to a map by simply setting a key/value:</p>
 			<p>An item can be added to a map by simply setting a key/value:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var people = ["Mark":1, "Andrew":2, "Paul":3, "Ross":4];
 	var people = ["Mark":1, "Andrew":2, "Paul":3, "Ross":4];
 	people["Kiara"] = 5;	// people now contains the "Kiara" key with value 5
 	people["Kiara"] = 5;	// people now contains the "Kiara" key with value 5
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Removing elements</h4>
 			<h4 class="section-h4">Removing elements</h4>
 			<p>The remove method has been added to the map class as a conveniente way to remove keys:</p>
 			<p>The remove method has been added to the map class as a conveniente way to remove keys:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -124,7 +124,7 @@
 	people.remove("Ross");
 	people.remove("Ross");
 	return people.count; // 2 is returned in this case
 	return people.count; // 2 is returned in this case
 			</code></pre>
 			</code></pre>
-			
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -138,14 +138,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 10 - 10
docs/operators.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,13 +75,13 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Operators</h1><hr>
          	<h1 class="section-header">Operators</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			An operator is a special symbol or phrase that you use to check, change, or combine values. For example, the addition operator (+) adds two numbers, as in <strong>var i = 1 + 2</strong>, and the logical AND operator (&&) combines two Boolean values, as in <strong>if (flag1 && flag2)</strong>.
 			An operator is a special symbol or phrase that you use to check, change, or combine values. For example, the addition operator (+) adds two numbers, as in <strong>var i = 1 + 2</strong>, and the logical AND operator (&&) combines two Boolean values, as in <strong>if (flag1 && flag2)</strong>.
 			<br><br>
 			<br><br>
 			Gravity supports most standard C operators and improves several capabilities to eliminate common coding errors. The assignment operator (=) does not return a value, to prevent it from being mistakenly used when the equal to operator (==) is intended. Gravity also provides two <a href="types.html">range</a> operators as a shortcut for expressing a range of values.
 			Gravity supports most standard C operators and improves several capabilities to eliminate common coding errors. The assignment operator (=) does not return a value, to prevent it from being mistakenly used when the equal to operator (==) is intended. Gravity also provides two <a href="types.html">range</a> operators as a shortcut for expressing a range of values.
 			</p>
 			</p>
-			
+
 			<!-- ARITHMETIC -->
 			<!-- ARITHMETIC -->
 			<h4 class="section-h4">Arithmetic Operators</h4>
 			<h4 class="section-h4">Arithmetic Operators</h4>
 			<p>
 			<p>
@@ -101,7 +101,7 @@
 	var n5 = 9 % 4		// equals 1
 	var n5 = 9 % 4		// equals 1
 			</code></pre>
 			</code></pre>
 			<p>Special attention has been placed in the division operator. A Division between two Int usually result in a Float in order to not truncate any decimal.</p>
 			<p>Special attention has been placed in the division operator. A Division between two Int usually result in a Float in order to not truncate any decimal.</p>
-			
+
 			<!-- ASSIGNMENT -->
 			<!-- ASSIGNMENT -->
 			<h4 class="section-h4">Assignment Operator</h4>
 			<h4 class="section-h4">Assignment Operator</h4>
 			<p>The assignment operator = initialize or update a value:</p>
 			<p>The assignment operator = initialize or update a value:</p>
@@ -157,7 +157,7 @@
 	1 || 0		// true because one of the two values is true
 	1 || 0		// true because one of the two values is true
 			</code></pre>
 			</code></pre>
 			<p>In order to improve code readability the reserved keywords <strong>not, and, or</strong> has been introduces as an alisas to logical operators.</p>
 			<p>In order to improve code readability the reserved keywords <strong>not, and, or</strong> has been introduces as an alisas to logical operators.</p>
-			
+
 			<!-- BITWISE -->
 			<!-- BITWISE -->
 			<h4 class="section-h4">Bitwise Operators</h4>
 			<h4 class="section-h4">Bitwise Operators</h4>
 			<p>
 			<p>
@@ -179,7 +179,7 @@
 	var n5 = n ^ 0B00001111		// equals 00111100
 	var n5 = n ^ 0B00001111		// equals 00111100
 	var n6 = ~n;			// equals 11001100
 	var n6 = ~n;			// equals 11001100
 			</code></pre>
 			</code></pre>
-			
+
 			<!-- COMPOUND -->
 			<!-- COMPOUND -->
 			<h4 class="section-h4">Compound Assignment Operators</h4>
 			<h4 class="section-h4">Compound Assignment Operators</h4>
 			<p>As a shortcut, assignment and operators can be combined together:
 			<p>As a shortcut, assignment and operators can be combined together:
@@ -196,7 +196,7 @@
 				<li>Bitwise OR and assign (|=)</li>
 				<li>Bitwise OR and assign (|=)</li>
 			</ul>
 			</ul>
 			</p>
 			</p>
-			
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -210,14 +210,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 1 - 1
docs/stylesheets/styles.css

@@ -53,7 +53,7 @@ pre {
 
 
 .sidebar-nav h4 {
 .sidebar-nav h4 {
 	font-size: 12px;
 	font-size: 12px;
-	text-transform: uppercase; 
+	text-transform: uppercase;
 	color: #BBB;
 	color: #BBB;
 	margin-bottom: 10px;
 	margin-bottom: 10px;
 }
 }

+ 16 - 16
docs/syntax.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -76,7 +76,7 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Syntax</h1><hr>
          	<h1 class="section-header">Syntax</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			<strong>Gravity</strong> syntax is designed to be familiar to people coming from C-like languages like Javascript, Swift, C++, C# and many more. We started working on this new language a year before Apple announced Swift and we were happily surprised to discovered how similar both syntax appear. Semicolon separator <strong>;</strong> is optional.
 			<strong>Gravity</strong> syntax is designed to be familiar to people coming from C-like languages like Javascript, Swift, C++, C# and many more. We started working on this new language a year before Apple announced Swift and we were happily surprised to discovered how similar both syntax appear. Semicolon separator <strong>;</strong> is optional.
 			<br><br>
 			<br><br>
@@ -86,28 +86,28 @@
 		// instance variables
 		// instance variables
 		var width;
 		var width;
 		var height;
 		var height;
-				
+
 		// instance method
 		// instance method
 		func area() {
 		func area() {
 			return width*height;
 			return width*height;
 		}
 		}
-				
+
 		// constructor
 		// constructor
 		func init(w, h) {
 		func init(w, h) {
 			width = w;
 			width = w;
 			height = h;
 			height = h;
 		}
 		}
 	}
 	}
-			
+
 	func main() {
 	func main() {
 		// initialize a new Rectangle object
 		// initialize a new Rectangle object
 		var r = Rectangle(20, 10);
 		var r = Rectangle(20, 10);
-				
+
 		// return value is 20*10 = 200
 		// return value is 20*10 = 200
 		return r.area();
 		return r.area();
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<!-- COMMENTS -->
 			<!-- COMMENTS -->
 			<h4 class="section-h4">Comments</h4>
 			<h4 class="section-h4">Comments</h4>
 			<p>Gravity supports both line comments:</p>
 			<p>Gravity supports both line comments:</p>
@@ -154,12 +154,12 @@
 		System.print("5+4=" + add(5,4));
 		System.print("5+4=" + add(5,4));
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Import</h4>
 			<h4 class="section-h4">Import</h4>
 			<p>While #include is used to include file at compilation time, the import statement enables you to load modules at runtime...</p>
 			<p>While #include is used to include file at compilation time, the import statement enables you to load modules at runtime...</p>
 			<!--<p>Gravity supports importing code from other gravity files using the
 			<!--<p>Gravity supports importing code from other gravity files using the
 			import statement:</p>-->
 			import statement:</p>-->
-			
+
 			<!-- RESERVED KEYWORDS -->
 			<!-- RESERVED KEYWORDS -->
 			<h4 class="section-h4">Reserved Keywords</h4>
 			<h4 class="section-h4">Reserved Keywords</h4>
 			<p>Like many other programming languages Gravity has some reserved keywords that assumes a very specific meaning in the context of the source code:</p>
 			<p>Like many other programming languages Gravity has some reserved keywords that assumes a very specific meaning in the context of the source code:</p>
@@ -169,7 +169,7 @@
 	_args struct repeat switch return public static extern
 	_args struct repeat switch return public static extern
 	import module default private continue internal undefined
 	import module default private continue internal undefined
 			</code></pre>
 			</code></pre>
-			
+
 			<!-- IDENTIFIERS -->
 			<!-- IDENTIFIERS -->
 			<h4 class="section-h4">Identifiers</h4>
 			<h4 class="section-h4">Identifiers</h4>
 			<p>Identifiers represent a naming rule used to identify objects inside your source code.
 			<p>Identifiers represent a naming rule used to identify objects inside your source code.
@@ -181,7 +181,7 @@
 	foo123
 	foo123
 	BYE_BYE
 	BYE_BYE
 			</code></pre>
 			</code></pre>
-			
+
 			<!-- BLOCKS -->
 			<!-- BLOCKS -->
 			<h4 class="section-h4">Blocks and Scope</h4>
 			<h4 class="section-h4">Blocks and Scope</h4>
 			<p>Every named identifier introduced in some portion of the source code is introduced in a scope. The scope is the largest part of the source code in which that identifier is valid. The names declared by a declaration are introduced into a specific scope based on the context of the declaration. For instance, local variable declarations introduce the name into the block scope, whereas class member variable declarations introduce the name into class scope.<br><br>There are three scopes defined: <strong>block scope</strong>, <strong>class scope</strong> and <strong>file scope</strong>. Names declared in the block scope become visible immediately after its completed declarator.  This means you cannot refer to a name within the block scope until after it has been fully declared. Names declared in the file and class scopes become visible immediately upon executing the starting statement of the script. This means you can refer to a name within the file or class scopes before it has been fully declared.<br><br>These are all valid scopes:</p>
 			<p>Every named identifier introduced in some portion of the source code is introduced in a scope. The scope is the largest part of the source code in which that identifier is valid. The names declared by a declaration are introduced into a specific scope based on the context of the declaration. For instance, local variable declarations introduce the name into the block scope, whereas class member variable declarations introduce the name into class scope.<br><br>There are three scopes defined: <strong>block scope</strong>, <strong>class scope</strong> and <strong>file scope</strong>. Names declared in the block scope become visible immediately after its completed declarator.  This means you cannot refer to a name within the block scope until after it has been fully declared. Names declared in the file and class scopes become visible immediately upon executing the starting statement of the script. This means you can refer to a name within the file or class scopes before it has been fully declared.<br><br>These are all valid scopes:</p>
@@ -194,7 +194,7 @@
 	func f2() {
 	func f2() {
 	    return 42;
 	    return 42;
 	}
 	}
-			
+
 	// block scope can be nested and
 	// block scope can be nested and
 	// can hide other local variables
 	// can hide other local variables
 	func f3() {
 	func f3() {
@@ -206,7 +206,7 @@
 		return a;
 		return a;
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -220,14 +220,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 17 - 17
docs/system.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -73,11 +73,11 @@
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">System</h1><hr>
          	<h1 class="section-header">System</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				System class is a class registered in every Gravity VM that offers some useful methods and properties.</p>
 				System class is a class registered in every Gravity VM that offers some useful methods and properties.</p>
 				<h4 class="section-h4">Print methods</h4>
 				<h4 class="section-h4">Print methods</h4>
@@ -85,33 +85,33 @@
 	func main() {
 	func main() {
 		// print to stdout and add a newline character
 		// print to stdout and add a newline character
 		System.print("Hello World");
 		System.print("Hello World");
-		
+
 		// print to stdout without any newline character appended
 		// print to stdout without any newline character appended
 		System.put("Hello World");
 		System.put("Hello World");
 	}
 	}
 				</code></pre>
 				</code></pre>
-				
+
 				<h4 class="section-h4">Garbage collector methods</h4>
 				<h4 class="section-h4">Garbage collector methods</h4>
 				<p>Gravity automatically manage memory for you using a tri-colour marking garbage collector, using the System class the user has the ability to change some of its settings and even disable it when certain performance critical tasks need to be performed:</p>
 				<p>Gravity automatically manage memory for you using a tri-colour marking garbage collector, using the System class the user has the ability to change some of its settings and even disable it when certain performance critical tasks need to be performed:</p>
 				<pre><code class="swift">
 				<pre><code class="swift">
 	func main() {
 	func main() {
 		// disable GC
 		// disable GC
 		System.gcenabled = false;
 		System.gcenabled = false;
-		
+
 		// ratio used during automatic recomputation of the new gcthreshold value
 		// ratio used during automatic recomputation of the new gcthreshold value
 		var ratio = System.gcratio;
 		var ratio = System.gcratio;
-		
+
 		// minimum GC threshold size
 		// minimum GC threshold size
 		var minthreshold = System.gcminthreshold;
 		var minthreshold = System.gcminthreshold;
-		
+
 		// memory required to trigger a GC
 		// memory required to trigger a GC
 		var threshold = System.gcthreshold;
 		var threshold = System.gcthreshold;
-		
+
 		// enable GC
 		// enable GC
 		System.gcenabled = true;
 		System.gcenabled = true;
 	}
 	}
 				</code></pre>
 				</code></pre>
-				
+
 				<h4 class="section-h4">Time related methods</h4>
 				<h4 class="section-h4">Time related methods</h4>
 				<p>There are times where it could be really useful to easily measure how much time is spent in a given task:</p>
 				<p>There are times where it could be really useful to easily measure how much time is spent in a given task:</p>
 				<pre><code class="swift">
 				<pre><code class="swift">
@@ -119,12 +119,12 @@
 		var t1 = System.nanotime();
 		var t1 = System.nanotime();
 		perform_my_task();
 		perform_my_task();
 		var t2 = System.nanotime();
 		var t2 = System.nanotime();
-		
+
 		// return elapsed time in ms
 		// return elapsed time in ms
 		return ((t2-t1) / 1000000.0);
 		return ((t2-t1) / 1000000.0);
 	}
 	}
 				</code></pre>
 				</code></pre>
-				
+
 				<h4 class="section-h4">System Exit</h4>
 				<h4 class="section-h4">System Exit</h4>
 				<p>There are times where it could be useful to have main() return an
 				<p>There are times where it could be useful to have main() return an
 				error code back to your shell:</p>
 				error code back to your shell:</p>
@@ -139,10 +139,10 @@
 	# Returns: 5
 	# Returns: 5
 	$ echo $?
 	$ echo $?
 				</code></pre>
 				</code></pre>
-				
+
          	</div>
          	</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -155,14 +155,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 18 - 18
docs/types.html

@@ -37,7 +37,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -75,14 +75,14 @@
 
 
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Values and Types</h1><hr>
          	<h1 class="section-header">Values and Types</h1><hr>
-			
+
 			<p class="section-content">
 			<p class="section-content">
 			Gravity is a dynamically typed language so variables do not have a type, although they refer to a value that does have a type. In Gravity everything is an object (with methods you can call and instance variables you can use). Basic intrinsic types are of class Object, Int, Float, String, Bool, Null, <a href="classes.html">Class</a>, <a href="functions.html">Function</a>, Fiber, Instance, <a href="lists.html">List</a>, <a href="maps.html">Map</a> and Range.
 			Gravity is a dynamically typed language so variables do not have a type, although they refer to a value that does have a type. In Gravity everything is an object (with methods you can call and instance variables you can use). Basic intrinsic types are of class Object, Int, Float, String, Bool, Null, <a href="classes.html">Class</a>, <a href="functions.html">Function</a>, Fiber, Instance, <a href="lists.html">List</a>, <a href="maps.html">Map</a> and Range.
 			</p>
 			</p>
-			
+
 			<h4 class="section-h4">Object</h4>
 			<h4 class="section-h4">Object</h4>
 			<p>Object is the root class of every object inside Gravity. Through the Object class, objects inherit a basic interface to the runtime system and the ability to behave as Gravity objects.</p>
 			<p>Object is the root class of every object inside Gravity. Through the Object class, objects inherit a basic interface to the runtime system and the ability to behave as Gravity objects.</p>
-			
+
 			<h4 class="section-h4">Int</h4>
 			<h4 class="section-h4">Int</h4>
 			<p>An Int represents a 64 bits (can optionally be compiled as 32bit) signed number:</p>
 			<p>An Int represents a 64 bits (can optionally be compiled as 32bit) signed number:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -96,7 +96,7 @@
 	var f = 30.radians // returns the result of converting 30 degrees to radians
 	var f = 30.radians // returns the result of converting 30 degrees to radians
 	var f = 3.degrees // returns the result of converting 3 radians to degrees
 	var f = 3.degrees // returns the result of converting 3 radians to degrees
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Float</h4>
 			<h4 class="section-h4">Float</h4>
 			<p>A float represents a 32 bits (or better) floating point number:</p>
 			<p>A float represents a 32 bits (or better) floating point number:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -106,13 +106,13 @@
 	var f = 30.5.radians // returns the result of converting 30.5 degrees to radians
 	var f = 30.5.radians // returns the result of converting 30.5 degrees to radians
 	var f = 3.14.degrees // returns the result of converting 3.14 radians to degrees
 	var f = 3.14.degrees // returns the result of converting 3.14 radians to degrees
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">String</h4>
 			<h4 class="section-h4">String</h4>
 			<p>Strings are an immutable sequence of characters. String literals can be surrounded in double or single quotes.</p>
 			<p>Strings are an immutable sequence of characters. String literals can be surrounded in double or single quotes.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var a = "Hello World";  // double quotes
 	var a = "Hello World";  // double quotes
 	var b = 'Hello World';  // single quotes
 	var b = 'Hello World';  // single quotes
-	
+
 	// Strings have also a length property
 	// Strings have also a length property
 	var n = b.length;       // n is now 11
 	var n = b.length;       // n is now 11
 
 
@@ -150,14 +150,14 @@
 	n = a[-5...10]          // n is now "World"
 	n = a[-5...10]          // n is now "World"
 	n = a[-1...-5]          // n is now "dlroW"
 	n = a[-1...-5]          // n is now "dlroW"
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Bool</h4>
 			<h4 class="section-h4">Bool</h4>
 			<p>The bool data type can have only two values, they are the literals true and false. A Bool value expresses the validity of a condition (tells whether the condition is true or false).</p>
 			<p>The bool data type can have only two values, they are the literals true and false. A Bool value expresses the validity of a condition (tells whether the condition is true or false).</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	var a = true;
 	var a = true;
 	var b = false;
 	var b = false;
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Null</h4>
 			<h4 class="section-h4">Null</h4>
 			<p>It indicates the absence of a value. If you call a method that doesn’t return anything and get its returned value, you get null back. The null data type is also used to initialize uninitialized variables with a default value.</p>
 			<p>It indicates the absence of a value. If you call a method that doesn’t return anything and get its returned value, you get null back. The null data type is also used to initialize uninitialized variables with a default value.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -168,35 +168,35 @@
 			return mass * acceleration;
 			return mass * acceleration;
 		}
 		}
 	}
 	}
-			
+
 	func f2() {
 	func f2() {
 		var sir = Newton();
 		var sir = Newton();
 		// acceleration instance variable has no default value
 		// acceleration instance variable has no default value
 		// so it is automatically set to null
 		// so it is automatically set to null
 		return sir.force();
 		return sir.force();
 	}
 	}
-			
+
 	func f1() {
 	func f1() {
 		var a;
 		var a;
 		// a is uninitialized so it has a default null value
 		// a is uninitialized so it has a default null value
 		return a;
 		return a;
 	}
 	}
 			</code></pre>
 			</code></pre>
-			
+
 			<h4 class="section-h4">Range</h4>
 			<h4 class="section-h4">Range</h4>
 			<p>A range is an object that represents a consecutive range of numbers. Syntax for this type has been directly inspired by Swift.</p>
 			<p>A range is an object that represents a consecutive range of numbers. Syntax for this type has been directly inspired by Swift.</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
 	// a represents a range with values 1,2,3
 	// a represents a range with values 1,2,3
 	var a = 1...3;
 	var a = 1...3;
-	
+
 	// b represents a range with values 1,2
 	// b represents a range with values 1,2
 	var b = 1..<3;
 	var b = 1..<3;
-	
+
 	// Ranges have also a conveniente count property
 	// Ranges have also a conveniente count property
 	var n1 = a.count;	// n1 is now 3
 	var n1 = a.count;	// n1 is now 3
 	var n2 = b.count;	// n2 is now 2
 	var n2 = b.count;	// n2 is now 2
 			</code></pre>
 			</code></pre>
-			
+
          	</div>
          	</div>
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
@@ -210,14 +210,14 @@
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 7 - 7
docs/unit-test.html

@@ -38,7 +38,7 @@
 	<div class="container body-container">
 	<div class="container body-container">
 		<div class="main-content">
 		<div class="main-content">
 			<div class="row">
 			<div class="row">
-       	
+
        		<!-- BEGIN SIDEBAR -->
        		<!-- BEGIN SIDEBAR -->
        		<div class="col-sm-3 border-right section-left">
        		<div class="col-sm-3 border-right section-left">
 				<div saveheight="1" class="sidebar-nav">
 				<div saveheight="1" class="sidebar-nav">
@@ -73,11 +73,11 @@
 				</div>
 				</div>
 			</div>
 			</div>
 			<!-- END SIDEBAR -->
 			<!-- END SIDEBAR -->
-			
+
 			<!-- BEGIN CONTENT -->
 			<!-- BEGIN CONTENT -->
        		<div class="col-sm-9 border-left section-right">
        		<div class="col-sm-9 border-left section-right">
          	<h1 class="section-header">Unit Test</h1><hr>
          	<h1 class="section-header">Unit Test</h1><hr>
-         				
+
 			<p class="section-content">
 			<p class="section-content">
 				Unit testing is so important (expecially for a programming language) that Gravity has built-in unit testing capabilities. What a user needs to do is setup some delegate C methods in order to be able to correctly setup a unit-test. Gravity already has a unit-test executable so in order to add your code to it you need to create a .gravity file using the special #unittest preprocessor macro:</p>
 				Unit testing is so important (expecially for a programming language) that Gravity has built-in unit testing capabilities. What a user needs to do is setup some delegate C methods in order to be able to correctly setup a unit-test. Gravity already has a unit-test executable so in order to add your code to it you need to create a .gravity file using the special #unittest preprocessor macro:</p>
 			<pre><code class="swift">
 			<pre><code class="swift">
@@ -96,7 +96,7 @@ func main() {
 			<p>A unittest can also be written in order to be able to check for syntax, semantic and runtime errors. For syntax and semantic errors the user can also specify row and column of the expected generated error.</p>
 			<p>A unittest can also be written in order to be able to check for syntax, semantic and runtime errors. For syntax and semantic errors the user can also specify row and column of the expected generated error.</p>
          	</div>
          	</div>
          	<!-- END CONTENT -->
          	<!-- END CONTENT -->
-         	
+
        	</div> <!-- /row -->
        	</div> <!-- /row -->
        </div> <!-- /main-content -->
        </div> <!-- /main-content -->
      </div> <!-- /container -->
      </div> <!-- /container -->
@@ -109,14 +109,14 @@ func main() {
 		</div>
 		</div>
 	</footer>
 	</footer>
     <!-- END FOOTER -->
     <!-- END FOOTER -->
-	
+
 	<!-- Bootstrap JS -->
 	<!-- Bootstrap JS -->
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
-	
+
 	<!-- Highlights JS -->
 	<!-- Highlights JS -->
     <script src="scripts/highlight/highlight.min.js"></script>
     <script src="scripts/highlight/highlight.min.js"></script>
     <script>hljs.initHighlightingOnLoad();</script>
     <script>hljs.initHighlightingOnLoad();</script>
-    
+
 	</body>
 	</body>
 </html>
 </html>

+ 35 - 35
src/cli/gravity.c

@@ -37,7 +37,7 @@ static void report_error (error_type_t error_type, const char *message, error_de
 		case GRAVITY_WARNING: type = "WARNING"; break;
 		case GRAVITY_WARNING: type = "WARNING"; break;
 		case GRAVITY_ERROR_IO: type = "I/O"; break;
 		case GRAVITY_ERROR_IO: type = "I/O"; break;
 	}
 	}
-	
+
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("RUNTIME ERROR: ");
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("RUNTIME ERROR: ");
 	else printf("%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	else printf("%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	printf("%s\n", message);
 	printf("%s\n", message);
@@ -45,30 +45,30 @@ static void report_error (error_type_t error_type, const char *message, error_de
 
 
 static const char *load_file (const char *file, size_t *size, uint32_t *fileid, void *xdata) {
 static const char *load_file (const char *file, size_t *size, uint32_t *fileid, void *xdata) {
 	#pragma unused(fileid, xdata)
 	#pragma unused(fileid, xdata)
-	
+
 	// this callback is called each time an import statement is parsed
 	// this callback is called each time an import statement is parsed
 	// file arg represents what user wrote after the import keyword, for example:
 	// file arg represents what user wrote after the import keyword, for example:
 	// import "file2"
 	// import "file2"
 	// import "file2.gravity"
 	// import "file2.gravity"
 	// import "../file2"
 	// import "../file2"
 	// import "/full_path_to_file2"
 	// import "/full_path_to_file2"
-	
+
 	// it is callback's responsability to resolve file path based on current working directory
 	// it is callback's responsability to resolve file path based on current working directory
 	// or based on user defined search paths
 	// or based on user defined search paths
 	// and returns:
 	// and returns:
 	// size of file in *size
 	// size of file in *size
 	// fileid (if any) in *fileid
 	// fileid (if any) in *fileid
 	// content of file as return value of the function
 	// content of file as return value of the function
-	
+
 	// fileid will then be used each time an error is reported by the compiler
 	// fileid will then be used each time an error is reported by the compiler
 	// so it is responsability of this function to map somewhere the association
 	// so it is responsability of this function to map somewhere the association
 	// between fileid and real file/path name
 	// between fileid and real file/path name
-	
+
 	// fileid is not used in this example
 	// fileid is not used in this example
 	// xdata not used here but it the xdata field set in the delegate
 	// xdata not used here but it the xdata field set in the delegate
 	// please note than in this simple example the imported file must be
 	// please note than in this simple example the imported file must be
 	// in the same folder as the main input file
 	// in the same folder as the main input file
-	
+
 	if (!file_exists(file)) return NULL;
 	if (!file_exists(file)) return NULL;
 	return file_read(file, size);
 	return file_read(file, size);
 }
 }
@@ -95,17 +95,17 @@ static void print_help (void) {
 
 
 static op_type parse_args (int argc, const char* argv[]) {
 static op_type parse_args (int argc, const char* argv[]) {
 	if (argc == 1) return OP_REPL;
 	if (argc == 1) return OP_REPL;
-	
+
 	if (argc == 2 && strcmp(argv[1], "--version") == 0) {
 	if (argc == 2 && strcmp(argv[1], "--version") == 0) {
 		print_version();
 		print_version();
 		exit(0);
 		exit(0);
 	}
 	}
-	
+
 	if (argc == 2 && strcmp(argv[1], "--help") == 0) {
 	if (argc == 2 && strcmp(argv[1], "--help") == 0) {
 		print_help();
 		print_help();
 		exit(0);
 		exit(0);
 	}
 	}
-	
+
 	op_type type = OP_RUN;
 	op_type type = OP_RUN;
 	for (int i=1; i<argc; ++i) {
 	for (int i=1; i<argc; ++i) {
 		if ((strcmp(argv[i], "-c") == 0) && (i+1 < argc)) {
 		if ((strcmp(argv[i], "-c") == 0) && (i+1 < argc)) {
@@ -131,7 +131,7 @@ static op_type parse_args (int argc, const char* argv[]) {
 			type = OP_COMPILE_RUN;
 			type = OP_COMPILE_RUN;
 		}
 		}
 	}
 	}
-	
+
 	return type;
 	return type;
 }
 }
 
 
@@ -140,13 +140,13 @@ static op_type parse_args (int argc, const char* argv[]) {
 static void gravity_repl (void) {
 static void gravity_repl (void) {
 	printf("REPL not yet implemented.\n");
 	printf("REPL not yet implemented.\n");
 	exit(0);
 	exit(0);
-	
+
 	/*
 	/*
 	// setup compiler/VM delegate
 	// setup compiler/VM delegate
 	gravity_delegate_t delegate = {
 	gravity_delegate_t delegate = {
 		.error_callback = report_error,
 		.error_callback = report_error,
 	};
 	};
-	
+
 	gravity_compiler_t	*compiler = gravity_compiler_create(&delegate);
 	gravity_compiler_t	*compiler = gravity_compiler_create(&delegate);
 	gravity_vm	*vm = gravity_vm_new(&delegate);
 	gravity_vm	*vm = gravity_vm_new(&delegate);
 	char		*line = NULL;
 	char		*line = NULL;
@@ -158,7 +158,7 @@ static void gravity_repl (void) {
 		//	gravity_compiler_eval(compiler, vm, line, length);
 		//	gravity_compiler_eval(compiler, vm, line, length);
 		free(line);
 		free(line);
 	}
 	}
-	
+
 	gravity_compiler_free(compiler);
 	gravity_compiler_free(compiler);
 	gravity_vm_free(vm);
 	gravity_vm_free(vm);
 	 */
 	 */
@@ -169,48 +169,48 @@ static void gravity_repl (void) {
 int main (int argc, const char* argv[]) {
 int main (int argc, const char* argv[]) {
 	// parse arguments and return operation type
 	// parse arguments and return operation type
 	op_type type = parse_args(argc, argv);
 	op_type type = parse_args(argc, argv);
-	
+
 	// special repl case
 	// special repl case
 	if (type == OP_REPL) gravity_repl();
 	if (type == OP_REPL) gravity_repl();
-	
+
 	// initialize memory debugger (if activated)
 	// initialize memory debugger (if activated)
 	mem_init();
 	mem_init();
-	
+
 	// closure to execute/serialize
 	// closure to execute/serialize
 	gravity_closure_t *closure = NULL;
 	gravity_closure_t *closure = NULL;
-	
+
 	// optional compiler
 	// optional compiler
 	gravity_compiler_t *compiler = NULL;
 	gravity_compiler_t *compiler = NULL;
-	
+
 	// setup compiler/VM delegate
 	// setup compiler/VM delegate
 	gravity_delegate_t delegate = {
 	gravity_delegate_t delegate = {
 		.error_callback = report_error,
 		.error_callback = report_error,
 		.loadfile_callback = load_file
 		.loadfile_callback = load_file
 	};
 	};
-	
+
 	// create VM
 	// create VM
 	gravity_vm *vm = gravity_vm_new(&delegate);
 	gravity_vm *vm = gravity_vm_new(&delegate);
-	
+
 	// check if input file is source code that needs to be compiled
 	// check if input file is source code that needs to be compiled
 	if ((type == OP_COMPILE) || (type == OP_COMPILE_RUN) || (type == OP_INLINE_RUN)) {
 	if ((type == OP_COMPILE) || (type == OP_COMPILE_RUN) || (type == OP_INLINE_RUN)) {
-		
+
 		// load source code
 		// load source code
         size_t size = 0;
         size_t size = 0;
         const char *source_code = NULL;
         const char *source_code = NULL;
-        
+
         if (type == OP_INLINE_RUN) {
         if (type == OP_INLINE_RUN) {
             source_code = input_file;
             source_code = input_file;
             size = strlen(input_file);
             size = strlen(input_file);
         } else {
         } else {
             source_code = file_read(input_file, &size);
             source_code = file_read(input_file, &size);
         }
         }
-        
+
         // sanity check
         // sanity check
         if (!source_code || !size) {
         if (!source_code || !size) {
             printf("Error loading %s %s\n", (type == OP_INLINE_RUN) ? "source" : "file", input_file);
             printf("Error loading %s %s\n", (type == OP_INLINE_RUN) ? "source" : "file", input_file);
             goto cleanup;
             goto cleanup;
         }
         }
-        
+
         // create closure to execute inline code
         // create closure to execute inline code
         if (type == OP_INLINE_RUN) {
         if (type == OP_INLINE_RUN) {
             char *buffer = mem_alloc(size+1024);
             char *buffer = mem_alloc(size+1024);
@@ -218,24 +218,24 @@ int main (int argc, const char* argv[]) {
             size = snprintf(buffer, size+1024, "func main() {%s};", input_file);
             size = snprintf(buffer, size+1024, "func main() {%s};", input_file);
             source_code = buffer;
             source_code = buffer;
         }
         }
-		
+
 		// create compiler
 		// create compiler
 		compiler = gravity_compiler_create(&delegate);
 		compiler = gravity_compiler_create(&delegate);
-		
+
 		// compile source code into a closure
 		// compile source code into a closure
 		closure = gravity_compiler_run(compiler, source_code, size, 0, false);
 		closure = gravity_compiler_run(compiler, source_code, size, 0, false);
 		if (!closure) goto cleanup;
 		if (!closure) goto cleanup;
-		
+
 		// check if closure needs to be serialized
 		// check if closure needs to be serialized
 		if (type == OP_COMPILE) {
 		if (type == OP_COMPILE) {
 			bool result = gravity_compiler_serialize_infile(compiler, closure, output_file);
 			bool result = gravity_compiler_serialize_infile(compiler, closure, output_file);
 			if (!result) printf("Error serializing file %s\n", output_file);
 			if (!result) printf("Error serializing file %s\n", output_file);
 			goto cleanup;
 			goto cleanup;
 		}
 		}
-		
+
 		// op is OP_COMPILE_RUN so transfer memory from compiler to VM
 		// op is OP_COMPILE_RUN so transfer memory from compiler to VM
 		gravity_compiler_transfer(compiler, vm);
 		gravity_compiler_transfer(compiler, vm);
-		
+
 	} else if (type == OP_RUN) {
 	} else if (type == OP_RUN) {
 		// unserialize file
 		// unserialize file
 		closure = gravity_vm_loadfile(vm, input_file);
 		closure = gravity_vm_loadfile(vm, input_file);
@@ -244,26 +244,26 @@ int main (int argc, const char* argv[]) {
 			goto cleanup;
 			goto cleanup;
 		}
 		}
     }
     }
-	
+
 	// sanity check
 	// sanity check
 	assert(closure);
 	assert(closure);
-	
+
 	if (gravity_vm_runmain(vm, closure)) {
 	if (gravity_vm_runmain(vm, closure)) {
 		gravity_value_t result = gravity_vm_result(vm);
 		gravity_value_t result = gravity_vm_result(vm);
 		double t = gravity_vm_time(vm);
 		double t = gravity_vm_time(vm);
-		
+
 		char buffer[512];
 		char buffer[512];
 		gravity_value_dump(vm, result, buffer, sizeof(buffer));
 		gravity_value_dump(vm, result, buffer, sizeof(buffer));
 		if (!quiet_flag) {
 		if (!quiet_flag) {
 			printf("RESULT: %s (in %.4f ms)\n\n", buffer, t);
 			printf("RESULT: %s (in %.4f ms)\n\n", buffer, t);
 		}
 		}
 	}
 	}
-	
+
 cleanup:
 cleanup:
 	if (compiler) gravity_compiler_free(compiler);
 	if (compiler) gravity_compiler_free(compiler);
 	if (vm) gravity_vm_free(vm);
 	if (vm) gravity_vm_free(vm);
 	gravity_core_free();
 	gravity_core_free();
-	
+
 	#if GRAVITY_MEMORY_DEBUG
 	#if GRAVITY_MEMORY_DEBUG
 	size_t current_memory = mem_leaks();
 	size_t current_memory = mem_leaks();
 	if (current_memory != 0) {
 	if (current_memory != 0) {
@@ -273,6 +273,6 @@ cleanup:
 		printf("\tNo VM leaks found!\n");
 		printf("\tNo VM leaks found!\n");
 	}
 	}
 	#endif
 	#endif
-	
+
 	return 0;
 	return 0;
 }
 }

+ 30 - 30
src/cli/unittest.c

@@ -14,11 +14,11 @@
 typedef struct {
 typedef struct {
 	bool			processed;
 	bool			processed;
     bool            is_fuzzy;
     bool            is_fuzzy;
-	
+
 	uint32_t		ncount;
 	uint32_t		ncount;
 	uint32_t		nsuccess;
 	uint32_t		nsuccess;
 	uint32_t		nfailure;
 	uint32_t		nfailure;
-	
+
 	error_type_t	expected_error;
 	error_type_t	expected_error;
 	gravity_value_t expected_value;
 	gravity_value_t expected_value;
 	int32_t			expected_row;
 	int32_t			expected_row;
@@ -43,7 +43,7 @@ static void	unittest_callback (error_type_t error_type, const char *description,
 	data->expected_value = value;
 	data->expected_value = value;
 	data->expected_row = row;
 	data->expected_row = row;
 	data->expected_col = col;
 	data->expected_col = col;
-	
+
 	if (notes) printf("\tNOTE: %s\n", notes);
 	if (notes) printf("\tNOTE: %s\n", notes);
 	printf("\t%s\n", description);
 	printf("\t%s\n", description);
 }
 }
@@ -52,30 +52,30 @@ static void	unittest_callback (error_type_t error_type, const char *description,
 
 
 static void callback_error (error_type_t error_type, const char *message, error_desc_t error_desc, void *xdata) {
 static void callback_error (error_type_t error_type, const char *message, error_desc_t error_desc, void *xdata) {
 	test_data *data = (test_data *)xdata;
 	test_data *data = (test_data *)xdata;
-	
+
 	if (data->processed == true) return; // ignore 2nd error
 	if (data->processed == true) return; // ignore 2nd error
 	data->processed = true;
 	data->processed = true;
-	
+
 	const char *type = "NONE";
 	const char *type = "NONE";
 	if (error_type == GRAVITY_ERROR_SYNTAX) type = "SYNTAX";
 	if (error_type == GRAVITY_ERROR_SYNTAX) type = "SYNTAX";
 	else if (error_type == GRAVITY_ERROR_SEMANTIC) type = "SEMANTIC";
 	else if (error_type == GRAVITY_ERROR_SEMANTIC) type = "SEMANTIC";
 	else if (error_type == GRAVITY_ERROR_RUNTIME) type = "RUNTIME";
 	else if (error_type == GRAVITY_ERROR_RUNTIME) type = "RUNTIME";
 	else if (error_type == GRAVITY_WARNING) type = "WARNING";
 	else if (error_type == GRAVITY_WARNING) type = "WARNING";
-	
+
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("\tRUNTIME ERROR: ");
 	if (error_type == GRAVITY_ERROR_RUNTIME) printf("\tRUNTIME ERROR: ");
 	else printf("\t%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	else printf("\t%s ERROR on %d (%d,%d): ", type, error_desc.fileid, error_desc.lineno, error_desc.colno);
 	printf("%s\n", message);
 	printf("%s\n", message);
-	
+
 	bool same_error = (data->expected_error == error_type);
 	bool same_error = (data->expected_error == error_type);
 	bool same_row = (data->expected_row != -1) ? (data->expected_row == error_desc.lineno) : true;
 	bool same_row = (data->expected_row != -1) ? (data->expected_row == error_desc.lineno) : true;
 	bool same_col = (data->expected_col != -1) ? (data->expected_col == error_desc.colno) : true;
 	bool same_col = (data->expected_col != -1) ? (data->expected_col == error_desc.colno) : true;
-	
+
     if (data->is_fuzzy) {
     if (data->is_fuzzy) {
         ++data->nsuccess;
         ++data->nsuccess;
         printf("\tSUCCESS\n");
         printf("\tSUCCESS\n");
         return;
         return;
     }
     }
-    
+
 	if (same_error && same_row && same_col) {
 	if (same_error && same_row && same_col) {
 		++data->nsuccess;
 		++data->nsuccess;
 		printf("\tSUCCESS\n");
 		printf("\tSUCCESS\n");
@@ -88,57 +88,57 @@ static void callback_error (error_type_t error_type, const char *message, error_
 static const char *callback_read (const char *path, size_t *size, uint32_t *fileid, void *xdata) {
 static const char *callback_read (const char *path, size_t *size, uint32_t *fileid, void *xdata) {
 	#pragma unused(fileid,xdata)
 	#pragma unused(fileid,xdata)
 	if (file_exists(path)) return file_read(path, size);
 	if (file_exists(path)) return file_read(path, size);
-	
+
 	// this unittest is able to resolve path only next to main test folder (not in nested folders)
 	// this unittest is able to resolve path only next to main test folder (not in nested folders)
 	const char *newpath = file_buildpath(path, test_folder_path);
 	const char *newpath = file_buildpath(path, test_folder_path);
 	if (!newpath) return NULL;
 	if (!newpath) return NULL;
-	
+
 	const char *buffer = file_read(newpath, size);
 	const char *buffer = file_read(newpath, size);
 	mem_free(newpath);
 	mem_free(newpath);
-	
+
 	return buffer;
 	return buffer;
 }
 }
 
 
 static void test_folder (const char *folder_path, test_data *data) {
 static void test_folder (const char *folder_path, test_data *data) {
 	DIRREF dir = directory_init(folder_path);
 	DIRREF dir = directory_init(folder_path);
 	if (!dir) return;
 	if (!dir) return;
-	
+
 	const char *target_file;
 	const char *target_file;
 	while ((target_file = directory_read(dir))) {
 	while ((target_file = directory_read(dir))) {
-		
+
 		#ifdef WIN32
 		#ifdef WIN32
 		const char winbuffer[MAX_PATH];
 		const char winbuffer[MAX_PATH];
 		WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR)target_file, -1, winbuffer, sizeof(winbuffer), NULL, NULL );
 		WideCharToMultiByte (CP_UTF8, 0, (LPCWSTR)target_file, -1, winbuffer, sizeof(winbuffer), NULL, NULL );
 		target_file = (const char *)winbuffer;
 		target_file = (const char *)winbuffer;
 		#endif
 		#endif
-		
+
 		// if file is a folder then start recursion
 		// if file is a folder then start recursion
 		const char *full_path = file_buildpath(target_file, folder_path);
 		const char *full_path = file_buildpath(target_file, folder_path);
 		if (is_directory(full_path)) {
 		if (is_directory(full_path)) {
 			// skip disabled folder
 			// skip disabled folder
 			if (strcmp(target_file, "disabled") == 0) continue;
 			if (strcmp(target_file, "disabled") == 0) continue;
-			
+
 			test_folder(full_path, data);
 			test_folder(full_path, data);
 			continue;
 			continue;
 		}
 		}
-		
+
 		// test only files with a .gravity extension
 		// test only files with a .gravity extension
 		if (strstr(full_path, ".gravity") == NULL) continue;
 		if (strstr(full_path, ".gravity") == NULL) continue;
         data->is_fuzzy = (strstr(full_path, "/fuzzy/") != NULL);
         data->is_fuzzy = (strstr(full_path, "/fuzzy/") != NULL);
-		
+
 		// load source code
 		// load source code
 		size_t size = 0;
 		size_t size = 0;
 		const char *source_code = file_read(full_path, &size);
 		const char *source_code = file_read(full_path, &size);
 		assert(source_code);
 		assert(source_code);
-		
+
 		// start unit test
 		// start unit test
 		unittest_init(target_file, data);
 		unittest_init(target_file, data);
-		
+
 		// compile and run source code
 		// compile and run source code
 		printf("\n%d\tTest file: %s\n", data->ncount, target_file);
 		printf("\n%d\tTest file: %s\n", data->ncount, target_file);
 		printf("\tTest path: %s\n", full_path);
 		printf("\tTest path: %s\n", full_path);
 		mem_free(full_path);
 		mem_free(full_path);
-		
+
 		// initialize compiler and delegates
 		// initialize compiler and delegates
 		gravity_delegate_t delegate = {
 		gravity_delegate_t delegate = {
 			.xdata = (void *)data,
 			.xdata = (void *)data,
@@ -146,13 +146,13 @@ static void test_folder (const char *folder_path, test_data *data) {
 			.unittest_callback = unittest_callback,
 			.unittest_callback = unittest_callback,
 			.loadfile_callback = callback_read
 			.loadfile_callback = callback_read
 		};
 		};
-		
+
 		gravity_compiler_t *compiler = gravity_compiler_create(&delegate);
 		gravity_compiler_t *compiler = gravity_compiler_create(&delegate);
 		gravity_closure_t *closure = gravity_compiler_run(compiler, source_code, size, 0, false);
 		gravity_closure_t *closure = gravity_compiler_run(compiler, source_code, size, 0, false);
 		gravity_vm *vm = gravity_vm_new(&delegate);
 		gravity_vm *vm = gravity_vm_new(&delegate);
 		gravity_compiler_transfer(compiler, vm);
 		gravity_compiler_transfer(compiler, vm);
 		gravity_compiler_free(compiler);
 		gravity_compiler_free(compiler);
-		
+
 		if (closure) {
 		if (closure) {
 			if (gravity_vm_runmain(vm, closure)) {
 			if (gravity_vm_runmain(vm, closure)) {
 				data->processed = true;
 				data->processed = true;
@@ -168,13 +168,13 @@ static void test_folder (const char *folder_path, test_data *data) {
 			}
 			}
 		}
 		}
 		gravity_vm_free(vm);
 		gravity_vm_free(vm);
-		
+
 		// case for empty files or simple declarations test
 		// case for empty files or simple declarations test
 		if (!data->processed) {
 		if (!data->processed) {
 			++data->nsuccess;
 			++data->nsuccess;
 			printf("\tSUCCESS\n");
 			printf("\tSUCCESS\n");
 		}
 		}
-		
+
 		// cleanup unitest
 		// cleanup unitest
 		unittest_cleanup(target_file, data);
 		unittest_cleanup(target_file, data);
 	}
 	}
@@ -186,25 +186,25 @@ int main (int argc, const char* argv[]) {
 		.nsuccess = 0,
 		.nsuccess = 0,
 		.nfailure = 0
 		.nfailure = 0
 	};
 	};
-	
+
 	if (argc != 2) {
 	if (argc != 2) {
 		printf("Usage: unittest /path/to/unitest/\n");
 		printf("Usage: unittest /path/to/unitest/\n");
 		return 1;
 		return 1;
 	}
 	}
-	
+
 	// print console header
 	// print console header
 	printf("==============================================\n");
 	printf("==============================================\n");
 	printf("Gravity UnitTest\n");
 	printf("Gravity UnitTest\n");
 	printf("Gravity version %s\n", GRAVITY_VERSION);
 	printf("Gravity version %s\n", GRAVITY_VERSION);
 	printf("Build date: %s\n", GRAVITY_BUILD_DATE);
 	printf("Build date: %s\n", GRAVITY_BUILD_DATE);
 	printf("==============================================\n");
 	printf("==============================================\n");
-	
+
 	mem_init();
 	mem_init();
 	nanotime_t tstart = nanotime();
 	nanotime_t tstart = nanotime();
 	test_folder_path = argv[1];
 	test_folder_path = argv[1];
 	test_folder(argv[1], &data);
 	test_folder(argv[1], &data);
 	nanotime_t tend = nanotime();
 	nanotime_t tend = nanotime();
-	
+
 	double result = ((double)((data.nsuccess * 100)) / (double)data.ncount);
 	double result = ((double)((data.nsuccess * 100)) / (double)data.ncount);
 	printf("\n\n");
 	printf("\n\n");
 	printf("==============================================\n");
 	printf("==============================================\n");
@@ -215,7 +215,7 @@ int main (int argc, const char* argv[]) {
 	printf("Time: %.4f ms\n", millitime(tstart, tend));
 	printf("Time: %.4f ms\n", millitime(tstart, tend));
 	printf("==============================================\n");
 	printf("==============================================\n");
 	printf("\n");
 	printf("\n");
-	
+
 	// If we have 1 or more failures, return an error.
 	// If we have 1 or more failures, return an error.
 	if (data.nfailure != 0) {
 	if (data.nfailure != 0) {
 		return 1;
 		return 1;

+ 1 - 1
src/compiler/debug_macros.h

@@ -14,7 +14,7 @@
 #include <fcntl.h>
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
-#include <stdarg.h> 
+#include <stdarg.h>
 #include <assert.h>
 #include <assert.h>
 #include <unistd.h>
 #include <unistd.h>
 #include <limits.h>
 #include <limits.h>

+ 54 - 54
src/compiler/gravity_ast.c

@@ -39,18 +39,18 @@ gnode_r *gnode_array_create (void) {
 
 
 void gnode_array_sethead(gnode_r *list, gnode_t *node) {
 void gnode_array_sethead(gnode_r *list, gnode_t *node) {
     if (!list || !node) return;
     if (!list || !node) return;
-    
+
 	// get old size
 	// get old size
 	size_t list_size = gnode_array_size(list);
 	size_t list_size = gnode_array_size(list);
-	
+
 	// push node at the end to trigger memory allocation (if needed)
 	// push node at the end to trigger memory allocation (if needed)
 	gnode_array_push(list, node);
 	gnode_array_push(list, node);
-	
+
 	// shift elements in array
 	// shift elements in array
 	for (size_t i=list_size; i>0; --i) {
 	for (size_t i=list_size; i>0; --i) {
 		list->p[i] = list->p[i-1];
 		list->p[i] = list->p[i-1];
 	}
 	}
-	
+
 	// set new array head
 	// set new array head
 	list->p[0] = node;
 	list->p[0] = node;
 }
 }
@@ -59,7 +59,7 @@ gnode_r *gnode_array_remove_byindex(gnode_r *old_list, size_t index) {
 	// get old size
 	// get old size
 	size_t list_size = gnode_array_size(old_list);
 	size_t list_size = gnode_array_size(old_list);
 	if (index >= list_size) return NULL;
 	if (index >= list_size) return NULL;
-	
+
 	gnode_r *new_list = gnode_array_create();
 	gnode_r *new_list = gnode_array_create();
 	for (size_t i=0; i<list_size; ++i) {
 	for (size_t i=0; i<list_size; ++i) {
 		if (i == index) continue;
 		if (i == index) continue;
@@ -76,14 +76,14 @@ gupvalue_t *gnode_function_add_upvalue(gnode_function_decl_t *f, gnode_var_t *sy
 		f->uplist = mem_alloc(sizeof(gupvalue_r));
 		f->uplist = mem_alloc(sizeof(gupvalue_r));
 		gnode_array_init(f->uplist);
 		gnode_array_init(f->uplist);
 	}
 	}
-	
+
 	// lookup symbol in uplist (if any)
 	// lookup symbol in uplist (if any)
 	gtype_array_each(f->uplist, {
 	gtype_array_each(f->uplist, {
 		// symbol already found in uplist so return its index
 		// symbol already found in uplist so return its index
 		gnode_var_t *node = (gnode_var_t *)val->node;
 		gnode_var_t *node = (gnode_var_t *)val->node;
 		if (strcmp(node->identifier, symbol->identifier) == 0) return val;
 		if (strcmp(node->identifier, symbol->identifier) == 0) return val;
 	}, gupvalue_t *);
 	}, gupvalue_t *);
-	
+
 	// symbol not found in uplist so add it
 	// symbol not found in uplist so add it
 	gupvalue_t *upvalue = mem_alloc(sizeof(gupvalue_t));
 	gupvalue_t *upvalue = mem_alloc(sizeof(gupvalue_t));
 	upvalue->node = (gnode_t *)symbol;
 	upvalue->node = (gnode_t *)symbol;
@@ -91,7 +91,7 @@ gupvalue_t *gnode_function_add_upvalue(gnode_function_decl_t *f, gnode_var_t *sy
 	upvalue->selfindex = (uint32_t)gnode_array_size(f->uplist);
 	upvalue->selfindex = (uint32_t)gnode_array_size(f->uplist);
 	upvalue->is_direct = (n == 1);
 	upvalue->is_direct = (n == 1);
 	marray_push(gupvalue_t*, *f->uplist, upvalue);
 	marray_push(gupvalue_t*, *f->uplist, upvalue);
-	
+
 	// return symbol position in uplist
 	// return symbol position in uplist
 	return upvalue;
 	return upvalue;
 }
 }
@@ -100,7 +100,7 @@ gupvalue_t *gnode_function_add_upvalue(gnode_function_decl_t *f, gnode_var_t *sy
 
 
 gnode_t *gnode_jump_stat_create (gtoken_s token, gnode_t *expr, gnode_t *decl) {
 gnode_t *gnode_jump_stat_create (gtoken_s token, gnode_t *expr, gnode_t *decl) {
 	gnode_jump_stmt_t *node = (gnode_jump_stmt_t *)mem_alloc(sizeof(gnode_jump_stmt_t));
 	gnode_jump_stmt_t *node = (gnode_jump_stmt_t *)mem_alloc(sizeof(gnode_jump_stmt_t));
-	
+
 	SETBASE(node, NODE_JUMP_STAT, token, NULL);
 	SETBASE(node, NODE_JUMP_STAT, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->expr = expr;
 	node->expr = expr;
@@ -109,7 +109,7 @@ gnode_t *gnode_jump_stat_create (gtoken_s token, gnode_t *expr, gnode_t *decl) {
 
 
 gnode_t *gnode_label_stat_create (gtoken_s token, gnode_t *expr, gnode_t *stmt, gnode_t *decl) {
 gnode_t *gnode_label_stat_create (gtoken_s token, gnode_t *expr, gnode_t *stmt, gnode_t *decl) {
 	gnode_label_stmt_t *node = (gnode_label_stmt_t *)mem_alloc(sizeof(gnode_label_stmt_t));
 	gnode_label_stmt_t *node = (gnode_label_stmt_t *)mem_alloc(sizeof(gnode_label_stmt_t));
-	
+
 	SETBASE(node, NODE_LABEL_STAT, token, NULL);
 	SETBASE(node, NODE_LABEL_STAT, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->expr = expr;
 	node->expr = expr;
@@ -119,7 +119,7 @@ gnode_t *gnode_label_stat_create (gtoken_s token, gnode_t *expr, gnode_t *stmt,
 
 
 gnode_t *gnode_flow_stat_create (gtoken_s token, gnode_t *cond, gnode_t *stmt1, gnode_t *stmt2, gnode_t *decl) {
 gnode_t *gnode_flow_stat_create (gtoken_s token, gnode_t *cond, gnode_t *stmt1, gnode_t *stmt2, gnode_t *decl) {
 	gnode_flow_stmt_t *node = (gnode_flow_stmt_t *)mem_alloc(sizeof(gnode_flow_stmt_t));
 	gnode_flow_stmt_t *node = (gnode_flow_stmt_t *)mem_alloc(sizeof(gnode_flow_stmt_t));
-	
+
 	SETBASE(node, NODE_FLOW_STAT, token, NULL);
 	SETBASE(node, NODE_FLOW_STAT, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->cond = cond;
 	node->cond = cond;
@@ -130,7 +130,7 @@ gnode_t *gnode_flow_stat_create (gtoken_s token, gnode_t *cond, gnode_t *stmt1,
 
 
 gnode_t *gnode_loop_stat_create (gtoken_s token, gnode_t *cond, gnode_t *stmt, gnode_t *expr, gnode_t *decl) {
 gnode_t *gnode_loop_stat_create (gtoken_s token, gnode_t *cond, gnode_t *stmt, gnode_t *expr, gnode_t *decl) {
 	gnode_loop_stmt_t *node = (gnode_loop_stmt_t *)mem_alloc(sizeof(gnode_loop_stmt_t));
 	gnode_loop_stmt_t *node = (gnode_loop_stmt_t *)mem_alloc(sizeof(gnode_loop_stmt_t));
-	
+
 	SETBASE(node, NODE_LOOP_STAT, token, NULL);
 	SETBASE(node, NODE_LOOP_STAT, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->cond = cond;
 	node->cond = cond;
@@ -142,7 +142,7 @@ gnode_t *gnode_loop_stat_create (gtoken_s token, gnode_t *cond, gnode_t *stmt, g
 
 
 gnode_t *gnode_block_stat_create (gnode_n type, gtoken_s token, gnode_r *stmts, gnode_t *decl) {
 gnode_t *gnode_block_stat_create (gnode_n type, gtoken_s token, gnode_r *stmts, gnode_t *decl) {
 	gnode_compound_stmt_t *node = (gnode_compound_stmt_t *)mem_alloc(sizeof(gnode_compound_stmt_t));
 	gnode_compound_stmt_t *node = (gnode_compound_stmt_t *)mem_alloc(sizeof(gnode_compound_stmt_t));
-	
+
 	SETBASE(node, type, token, NULL);
 	SETBASE(node, type, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->stmts = stmts;
 	node->stmts = stmts;
@@ -152,7 +152,7 @@ gnode_t *gnode_block_stat_create (gnode_n type, gtoken_s token, gnode_r *stmts,
 
 
 gnode_t *gnode_empty_stat_create (gtoken_s token, gnode_t *decl) {
 gnode_t *gnode_empty_stat_create (gtoken_s token, gnode_t *decl) {
 	gnode_empty_stmt_t *node = (gnode_empty_stmt_t *)mem_alloc(sizeof(gnode_empty_stmt_t));
 	gnode_empty_stmt_t *node = (gnode_empty_stmt_t *)mem_alloc(sizeof(gnode_empty_stmt_t));
-	
+
 	SETBASE(node, NODE_EMPTY_STAT, token, NULL);
 	SETBASE(node, NODE_EMPTY_STAT, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	return (gnode_t *)node;
 	return (gnode_t *)node;
@@ -163,7 +163,7 @@ gnode_t *gnode_empty_stat_create (gtoken_s token, gnode_t *decl) {
 gnode_t *gnode_class_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_t *superclass, gnode_r *protocols, gnode_r *declarations, bool is_struct, void *meta, gnode_t *decl) {
 gnode_t *gnode_class_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_t *superclass, gnode_r *protocols, gnode_r *declarations, bool is_struct, void *meta, gnode_t *decl) {
 	gnode_class_decl_t *node = (gnode_class_decl_t *)mem_alloc(sizeof(gnode_class_decl_t));
 	gnode_class_decl_t *node = (gnode_class_decl_t *)mem_alloc(sizeof(gnode_class_decl_t));
 	node->is_struct = is_struct;
 	node->is_struct = is_struct;
-	
+
 	SETBASE(node, NODE_CLASS_DECL, token, meta);
 	SETBASE(node, NODE_CLASS_DECL, token, meta);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->bridge = false;
 	node->bridge = false;
@@ -175,39 +175,39 @@ gnode_t *gnode_class_decl_create (gtoken_s token, const char *identifier, gtoken
 	node->decls = declarations;
 	node->decls = declarations;
 	node->nivar = 0;
 	node->nivar = 0;
 	node->nsvar = 0;
 	node->nsvar = 0;
-	
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
 gnode_t *gnode_module_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_r *declarations, void *meta, gnode_t *decl) {
 gnode_t *gnode_module_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_r *declarations, void *meta, gnode_t *decl) {
 	gnode_module_decl_t *node = (gnode_module_decl_t *)mem_alloc(sizeof(gnode_module_decl_t));
 	gnode_module_decl_t *node = (gnode_module_decl_t *)mem_alloc(sizeof(gnode_module_decl_t));
-	
+
 	SETBASE(node, NODE_MODULE_DECL, token, meta);
 	SETBASE(node, NODE_MODULE_DECL, token, meta);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->identifier = identifier;
 	node->identifier = identifier;
 	node->access = access_specifier;
 	node->access = access_specifier;
 	node->storage = storage_specifier;
 	node->storage = storage_specifier;
 	node->decls = declarations;
 	node->decls = declarations;
-	
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
 gnode_t *gnode_enum_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, symboltable_t *symtable, void *meta, gnode_t *decl) {
 gnode_t *gnode_enum_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, symboltable_t *symtable, void *meta, gnode_t *decl) {
 	gnode_enum_decl_t *node = (gnode_enum_decl_t *)mem_alloc(sizeof(gnode_enum_decl_t));
 	gnode_enum_decl_t *node = (gnode_enum_decl_t *)mem_alloc(sizeof(gnode_enum_decl_t));
-	
+
 	SETBASE(node, NODE_ENUM_DECL, token, meta);
 	SETBASE(node, NODE_ENUM_DECL, token, meta);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->identifier = identifier;
 	node->identifier = identifier;
 	node->access = access_specifier;
 	node->access = access_specifier;
 	node->storage = storage_specifier;
 	node->storage = storage_specifier;
 	node->symtable= symtable;
 	node->symtable= symtable;
-	
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
 gnode_t *gnode_function_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_r *params, gnode_compound_stmt_t *block, void *meta, gnode_t *decl) {
 gnode_t *gnode_function_decl_create (gtoken_s token, const char *identifier, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_r *params, gnode_compound_stmt_t *block, void *meta, gnode_t *decl) {
 	gnode_function_decl_t *node = (gnode_function_decl_t *)mem_alloc(sizeof(gnode_function_decl_t));
 	gnode_function_decl_t *node = (gnode_function_decl_t *)mem_alloc(sizeof(gnode_function_decl_t));
-	
+
 	SETBASE(node, NODE_FUNCTION_DECL, token, meta);
 	SETBASE(node, NODE_FUNCTION_DECL, token, meta);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->identifier = identifier;
 	node->identifier = identifier;
@@ -217,26 +217,26 @@ gnode_t *gnode_function_decl_create (gtoken_s token, const char *identifier, gto
 	node->block = block;
 	node->block = block;
 	node->nlocals = 0;
 	node->nlocals = 0;
 	node->uplist = NULL;
 	node->uplist = NULL;
-    
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
 gnode_t *gnode_variable_decl_create (gtoken_s token, gtoken_t type, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_r *declarations, void *meta, gnode_t *decl) {
 gnode_t *gnode_variable_decl_create (gtoken_s token, gtoken_t type, gtoken_t access_specifier, gtoken_t storage_specifier, gnode_r *declarations, void *meta, gnode_t *decl) {
 	gnode_variable_decl_t *node = (gnode_variable_decl_t *)mem_alloc(sizeof(gnode_variable_decl_t));
 	gnode_variable_decl_t *node = (gnode_variable_decl_t *)mem_alloc(sizeof(gnode_variable_decl_t));
-	
+
 	SETBASE(node, NODE_VARIABLE_DECL, token, meta);
 	SETBASE(node, NODE_VARIABLE_DECL, token, meta);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->type = type;
 	node->type = type;
 	node->access = access_specifier;
 	node->access = access_specifier;
 	node->storage = storage_specifier;
 	node->storage = storage_specifier;
 	node->decls = declarations;
 	node->decls = declarations;
-    
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
 gnode_t *gnode_variable_create (gtoken_s token, const char *identifier, const char *annotation_type, gtoken_t access_specifier, gnode_t *expr, gnode_t *decl) {
 gnode_t *gnode_variable_create (gtoken_s token, const char *identifier, const char *annotation_type, gtoken_t access_specifier, gnode_t *expr, gnode_t *decl) {
 	gnode_var_t *node = (gnode_var_t *)mem_alloc(sizeof(gnode_var_t));
 	gnode_var_t *node = (gnode_var_t *)mem_alloc(sizeof(gnode_var_t));
-	
+
 	SETBASE(node, NODE_VARIABLE, token, NULL);
 	SETBASE(node, NODE_VARIABLE, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->identifier = identifier;
 	node->identifier = identifier;
@@ -297,7 +297,7 @@ bool gnode_is_literal_number (gnode_t *node) {
 
 
 gnode_t *gnode_binary_expr_create (gtoken_t op, gnode_t *left, gnode_t *right, gnode_t *decl) {
 gnode_t *gnode_binary_expr_create (gtoken_t op, gnode_t *left, gnode_t *right, gnode_t *decl) {
 	if (!left || !right) return NULL;
 	if (!left || !right) return NULL;
-	
+
 	gnode_binary_expr_t	*node = (gnode_binary_expr_t *)mem_alloc(sizeof(gnode_binary_expr_t));
 	gnode_binary_expr_t	*node = (gnode_binary_expr_t *)mem_alloc(sizeof(gnode_binary_expr_t));
 	SETBASE(node, NODE_BINARY_EXPR, left->token, NULL);
 	SETBASE(node, NODE_BINARY_EXPR, left->token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
@@ -309,7 +309,7 @@ gnode_t *gnode_binary_expr_create (gtoken_t op, gnode_t *left, gnode_t *right, g
 
 
 gnode_t *gnode_unary_expr_create (gtoken_t op, gnode_t *expr, gnode_t *decl) {
 gnode_t *gnode_unary_expr_create (gtoken_t op, gnode_t *expr, gnode_t *decl) {
 	if (!expr) return NULL;
 	if (!expr) return NULL;
-	
+
 	gnode_unary_expr_t *node = (gnode_unary_expr_t *)mem_alloc(sizeof(gnode_unary_expr_t));
 	gnode_unary_expr_t *node = (gnode_unary_expr_t *)mem_alloc(sizeof(gnode_unary_expr_t));
 	SETBASE(node, NODE_UNARY_EXPR, expr->token, NULL);
 	SETBASE(node, NODE_UNARY_EXPR, expr->token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
@@ -320,7 +320,7 @@ gnode_t *gnode_unary_expr_create (gtoken_t op, gnode_t *expr, gnode_t *decl) {
 
 
 gnode_t *gnode_file_expr_create (gtoken_s token, cstring_r *list, gnode_t *decl) {
 gnode_t *gnode_file_expr_create (gtoken_s token, cstring_r *list, gnode_t *decl) {
 	if (!list) return NULL;
 	if (!list) return NULL;
-	
+
 	gnode_file_expr_t *node = (gnode_file_expr_t *)mem_alloc(sizeof(gnode_file_expr_t));
 	gnode_file_expr_t *node = (gnode_file_expr_t *)mem_alloc(sizeof(gnode_file_expr_t));
 	SETBASE(node, NODE_FILE_EXPR, token, NULL);
 	SETBASE(node, NODE_FILE_EXPR, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
@@ -330,7 +330,7 @@ gnode_t *gnode_file_expr_create (gtoken_s token, cstring_r *list, gnode_t *decl)
 
 
 gnode_t *gnode_identifier_expr_create (gtoken_s token, const char *identifier, const char *identifier2, gnode_t *decl) {
 gnode_t *gnode_identifier_expr_create (gtoken_s token, const char *identifier, const char *identifier2, gnode_t *decl) {
 	if (!identifier) return NULL;
 	if (!identifier) return NULL;
-	
+
 	gnode_identifier_expr_t *node = (gnode_identifier_expr_t *)mem_alloc(sizeof(gnode_identifier_expr_t));
 	gnode_identifier_expr_t *node = (gnode_identifier_expr_t *)mem_alloc(sizeof(gnode_identifier_expr_t));
 	SETBASE(node, NODE_IDENTIFIER_EXPR, token, NULL);
 	SETBASE(node, NODE_IDENTIFIER_EXPR, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
@@ -352,12 +352,12 @@ void gnode_literal_dump (gnode_literal_expr_t *node, char *buffer, int buffersiz
 
 
 static gnode_t *gnode_literal_value_expr_create (gtoken_s token, gliteral_t type, const char *s, double d, int64_t n64, gnode_t *decl) {
 static gnode_t *gnode_literal_value_expr_create (gtoken_s token, gliteral_t type, const char *s, double d, int64_t n64, gnode_t *decl) {
 	gnode_literal_expr_t *node = (gnode_literal_expr_t *)mem_alloc(sizeof(gnode_literal_expr_t));
 	gnode_literal_expr_t *node = (gnode_literal_expr_t *)mem_alloc(sizeof(gnode_literal_expr_t));
-	
+
 	SETBASE(node, NODE_LITERAL_EXPR, token, NULL);
 	SETBASE(node, NODE_LITERAL_EXPR, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->type = type;
 	node->type = type;
 	node->len = 0;
 	node->len = 0;
-	
+
 	switch (type) {
 	switch (type) {
 		case LITERAL_STRING: node->value.str = (char *)s; break;
 		case LITERAL_STRING: node->value.str = (char *)s; break;
 		case LITERAL_FLOAT: node->value.d = d; node->len = (d < FLT_MAX) ? 32 : 64; break;
 		case LITERAL_FLOAT: node->value.d = d; node->len = (d < FLT_MAX) ? 32 : 64; break;
@@ -366,7 +366,7 @@ static gnode_t *gnode_literal_value_expr_create (gtoken_s token, gliteral_t type
 		case LITERAL_STRING_INTERPOLATED: break;
 		case LITERAL_STRING_INTERPOLATED: break;
 		default: assert(0); // should never reach this point
 		default: assert(0); // should never reach this point
 	}
 	}
-	
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
@@ -375,10 +375,10 @@ gnode_t *gnode_string_interpolation_create (gtoken_s token, gnode_r *r, gnode_t
 	node->value.r = r;
 	node->value.r = r;
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
-	
+
 gnode_t *gnode_literal_string_expr_create (gtoken_s token, char *s, uint32_t len, bool allocated, gnode_t *decl) {
 gnode_t *gnode_literal_string_expr_create (gtoken_s token, char *s, uint32_t len, bool allocated, gnode_t *decl) {
 	gnode_literal_expr_t *node = (gnode_literal_expr_t *)gnode_literal_value_expr_create(token, LITERAL_STRING, NULL, 0, 0, decl);
 	gnode_literal_expr_t *node = (gnode_literal_expr_t *)gnode_literal_value_expr_create(token, LITERAL_STRING, NULL, 0, 0, decl);
-	
+
 		node->len = len;
 		node->len = len;
 	if (allocated) {
 	if (allocated) {
 		node->value.str = s;
 		node->value.str = s;
@@ -386,7 +386,7 @@ gnode_t *gnode_literal_string_expr_create (gtoken_s token, char *s, uint32_t len
 		node->value.str = (char *)mem_alloc(len+1);
 		node->value.str = (char *)mem_alloc(len+1);
 		memcpy((void *)node->value.str, (const void *)s, len);
 		memcpy((void *)node->value.str, (const void *)s, len);
 	}
 	}
-	
+
 	return (gnode_t *)node;
 	return (gnode_t *)node;
 }
 }
 
 
@@ -404,7 +404,7 @@ gnode_t *gnode_literal_bool_expr_create (gtoken_s token, int32_t n, gnode_t *dec
 
 
 gnode_t *gnode_keyword_expr_create (gtoken_s token, gnode_t *decl) {
 gnode_t *gnode_keyword_expr_create (gtoken_s token, gnode_t *decl) {
 	gnode_keyword_expr_t *node = (gnode_keyword_expr_t *)mem_alloc(sizeof(gnode_keyword_expr_t));
 	gnode_keyword_expr_t *node = (gnode_keyword_expr_t *)mem_alloc(sizeof(gnode_keyword_expr_t));
-	
+
 	SETBASE(node, NODE_KEYWORD_EXPR, token, NULL);
 	SETBASE(node, NODE_KEYWORD_EXPR, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	return (gnode_t *)node;
 	return (gnode_t *)node;
@@ -412,7 +412,7 @@ gnode_t *gnode_keyword_expr_create (gtoken_s token, gnode_t *decl) {
 
 
 gnode_t *gnode_postfix_subexpr_create (gtoken_s token, gnode_n type, gnode_t *expr, gnode_r *list, gnode_t *decl) {
 gnode_t *gnode_postfix_subexpr_create (gtoken_s token, gnode_n type, gnode_t *expr, gnode_r *list, gnode_t *decl) {
 	gnode_postfix_subexpr_t *node = (gnode_postfix_subexpr_t *)mem_alloc(sizeof(gnode_postfix_subexpr_t));
 	gnode_postfix_subexpr_t *node = (gnode_postfix_subexpr_t *)mem_alloc(sizeof(gnode_postfix_subexpr_t));
-	
+
     SETBASE(node, type, token, NULL);
     SETBASE(node, type, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	if (type == NODE_CALL_EXPR)
 	if (type == NODE_CALL_EXPR)
@@ -424,7 +424,7 @@ gnode_t *gnode_postfix_subexpr_create (gtoken_s token, gnode_n type, gnode_t *ex
 
 
 gnode_t *gnode_postfix_expr_create (gtoken_s token, gnode_t *id, gnode_r *list, gnode_t *decl) {
 gnode_t *gnode_postfix_expr_create (gtoken_s token, gnode_t *id, gnode_r *list, gnode_t *decl) {
 	gnode_postfix_expr_t *node = (gnode_postfix_expr_t *)mem_alloc(sizeof(gnode_postfix_expr_t));
 	gnode_postfix_expr_t *node = (gnode_postfix_expr_t *)mem_alloc(sizeof(gnode_postfix_expr_t));
-	
+
 	SETBASE(node, NODE_POSTFIX_EXPR, token, NULL);
 	SETBASE(node, NODE_POSTFIX_EXPR, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->id = id;
 	node->id = id;
@@ -434,7 +434,7 @@ gnode_t *gnode_postfix_expr_create (gtoken_s token, gnode_t *id, gnode_r *list,
 
 
 gnode_t *gnode_list_expr_create (gtoken_s token, gnode_r *list1, gnode_r *list2, bool ismap, gnode_t *decl) {
 gnode_t *gnode_list_expr_create (gtoken_s token, gnode_r *list1, gnode_r *list2, bool ismap, gnode_t *decl) {
 	gnode_list_expr_t *node = (gnode_list_expr_t *)mem_alloc(sizeof(gnode_list_expr_t));
 	gnode_list_expr_t *node = (gnode_list_expr_t *)mem_alloc(sizeof(gnode_list_expr_t));
-	
+
 	SETBASE(node, NODE_LIST_EXPR, token, NULL);
 	SETBASE(node, NODE_LIST_EXPR, token, NULL);
     SETDECL(node, decl);
     SETDECL(node, decl);
 	node->ismap = ismap;
 	node->ismap = ismap;
@@ -447,13 +447,13 @@ gnode_t *gnode_list_expr_create (gtoken_s token, gnode_r *list1, gnode_r *list2,
 
 
 gnode_t *gnode_duplicate (gnode_t *node, bool deep) {
 gnode_t *gnode_duplicate (gnode_t *node, bool deep) {
 	if (!node) return NULL;
 	if (!node) return NULL;
-	
+
 	if (deep == true) {
 	if (deep == true) {
 		// deep is true so I need to examine node and perform a real duplication (only of the outer nodes)
 		// deep is true so I need to examine node and perform a real duplication (only of the outer nodes)
 		// deep is true ONLY when node can also be part of an assignment and its assignment flag can be
 		// deep is true ONLY when node can also be part of an assignment and its assignment flag can be
 		// true is node is on the left and false when node is on the right
 		// true is node is on the left and false when node is on the right
 		// true flag is used only by adjust_assignment_expression in parser.c
 		// true flag is used only by adjust_assignment_expression in parser.c
-		
+
 		// node can be: identifier, file or postfix
 		// node can be: identifier, file or postfix
 		if (NODE_ISA(node, NODE_IDENTIFIER_EXPR)) {
 		if (NODE_ISA(node, NODE_IDENTIFIER_EXPR)) {
 			gnode_identifier_expr_t *expr = (gnode_identifier_expr_t *)node;
 			gnode_identifier_expr_t *expr = (gnode_identifier_expr_t *)node;
@@ -501,7 +501,7 @@ static void free_list_stmt (gvisitor_t *self, gnode_compound_stmt_t *node) {
 	CHECK_REFCOUNT(node);
 	CHECK_REFCOUNT(node);
 	gnode_array_each(node->stmts, {visit(val);});
 	gnode_array_each(node->stmts, {visit(val);});
 	if (node->stmts) gnode_array_free(node->stmts);
 	if (node->stmts) gnode_array_free(node->stmts);
-	
+
 	if (node->symtable) symboltable_free(node->symtable);
 	if (node->symtable) symboltable_free(node->symtable);
 	mem_free((gnode_t*)node);
 	mem_free((gnode_t*)node);
 }
 }
@@ -510,7 +510,7 @@ static void free_compound_stmt (gvisitor_t *self, gnode_compound_stmt_t *node) {
 	CHECK_REFCOUNT(node);
 	CHECK_REFCOUNT(node);
 	gnode_array_each(node->stmts, {visit(val);});
 	gnode_array_each(node->stmts, {visit(val);});
 	if (node->stmts) gnode_array_free(node->stmts);
 	if (node->stmts) gnode_array_free(node->stmts);
-	
+
 	if (node->symtable) symboltable_free(node->symtable);
 	if (node->symtable) symboltable_free(node->symtable);
 	mem_free((gnode_t*)node);
 	mem_free((gnode_t*)node);
 }
 }
@@ -566,7 +566,7 @@ static void free_function_decl (gvisitor_t *self, gnode_function_decl_t *node) {
 		gnode_array_each(node->params, {free_variable(self, (gnode_var_t *)val);});
 		gnode_array_each(node->params, {free_variable(self, (gnode_var_t *)val);});
 		gnode_array_free(node->params);
 		gnode_array_free(node->params);
 	}
 	}
-	
+
 	if (node->block) visit((gnode_t *)node->block);
 	if (node->block) visit((gnode_t *)node->block);
 	if (node->uplist) {
 	if (node->uplist) {
 		gtype_array_each(node->uplist, {mem_free(val);}, gupvalue_t*);
 		gtype_array_each(node->uplist, {mem_free(val);}, gupvalue_t*);
@@ -635,7 +635,7 @@ static void free_unary_expr (gvisitor_t *self, gnode_unary_expr_t *node) {
 
 
 static void free_postfix_subexpr (gvisitor_t *self, gnode_postfix_subexpr_t *subnode) {
 static void free_postfix_subexpr (gvisitor_t *self, gnode_postfix_subexpr_t *subnode) {
 	CHECK_REFCOUNT(subnode);
 	CHECK_REFCOUNT(subnode);
-	
+
 	gnode_n tag = subnode->base.tag;
 	gnode_n tag = subnode->base.tag;
 	if (tag == NODE_CALL_EXPR) {
 	if (tag == NODE_CALL_EXPR) {
 		if (subnode->args) {
 		if (subnode->args) {
@@ -645,15 +645,15 @@ static void free_postfix_subexpr (gvisitor_t *self, gnode_postfix_subexpr_t *sub
 	} else {
 	} else {
 		visit(subnode->expr);
 		visit(subnode->expr);
 	}
 	}
-	
+
 	mem_free((gnode_t*)subnode);
 	mem_free((gnode_t*)subnode);
 }
 }
 
 
 static void free_postfix_expr (gvisitor_t *self, gnode_postfix_expr_t *node) {
 static void free_postfix_expr (gvisitor_t *self, gnode_postfix_expr_t *node) {
 	CHECK_REFCOUNT(node);
 	CHECK_REFCOUNT(node);
-	
+
 	visit(node->id);
 	visit(node->id);
-	
+
 	// node->list can be NULL due to enum static conversion
 	// node->list can be NULL due to enum static conversion
 	size_t count = gnode_array_size(node->list);
 	size_t count = gnode_array_size(node->list);
 	for (size_t i=0; i<count; ++i) {
 	for (size_t i=0; i<count; ++i) {
@@ -670,7 +670,7 @@ static void free_file_expr (gvisitor_t *self, gnode_file_expr_t *node) {
 	cstring_array_each(node->identifiers, {
 	cstring_array_each(node->identifiers, {
 		mem_free((void *)val);
 		mem_free((void *)val);
 	});
 	});
-	
+
 	if (node->identifiers) gnode_array_free(node->identifiers);
 	if (node->identifiers) gnode_array_free(node->identifiers);
 	mem_free((void *)node);
 	mem_free((void *)node);
 }
 }
@@ -720,11 +720,11 @@ void gnode_free (gnode_t *ast) {
 		.nerr = 0,
 		.nerr = 0,
 		.data = NULL,
 		.data = NULL,
 		.delegate = NULL,
 		.delegate = NULL,
-		
+
         // COMMON
         // COMMON
         .visit_pre = NULL,
         .visit_pre = NULL,
         .visit_post = NULL,
         .visit_post = NULL,
-        
+
 		// STATEMENTS: 7
 		// STATEMENTS: 7
 		.visit_list_stmt = free_list_stmt,
 		.visit_list_stmt = free_list_stmt,
 		.visit_compound_stmt = free_compound_stmt,
 		.visit_compound_stmt = free_compound_stmt,
@@ -733,14 +733,14 @@ void gnode_free (gnode_t *ast) {
 		.visit_loop_stmt = free_loop_stmt,
 		.visit_loop_stmt = free_loop_stmt,
 		.visit_jump_stmt = free_jump_stmt,
 		.visit_jump_stmt = free_jump_stmt,
 		.visit_empty_stmt = free_empty_stmt,
 		.visit_empty_stmt = free_empty_stmt,
-		
+
 		// DECLARATIONS: 5
 		// DECLARATIONS: 5
 		.visit_function_decl = free_function_decl,
 		.visit_function_decl = free_function_decl,
 		.visit_variable_decl = free_variable_decl,
 		.visit_variable_decl = free_variable_decl,
 		.visit_enum_decl = free_enum_decl,
 		.visit_enum_decl = free_enum_decl,
 		.visit_class_decl = free_class_decl,
 		.visit_class_decl = free_class_decl,
 		.visit_module_decl = free_module_decl,
 		.visit_module_decl = free_module_decl,
-		
+
 		// EXPRESSIONS: 7+1
 		// EXPRESSIONS: 7+1
 		.visit_binary_expr = free_binary_expr,
 		.visit_binary_expr = free_binary_expr,
 		.visit_unary_expr = free_unary_expr,
 		.visit_unary_expr = free_unary_expr,
@@ -751,6 +751,6 @@ void gnode_free (gnode_t *ast) {
 		.visit_list_expr = free_list_expr,
 		.visit_list_expr = free_list_expr,
 		.visit_postfix_expr = free_postfix_expr
 		.visit_postfix_expr = free_postfix_expr
 	};
 	};
-	
+
     gvisit(&visitor, ast);
     gvisit(&visitor, ast);
 }
 }

+ 2 - 2
src/compiler/gravity_ast.h

@@ -25,11 +25,11 @@ typedef enum {
 
 
 	// declarations: 6
 	// declarations: 6
 	NODE_ENUM_DECL, NODE_FUNCTION_DECL, NODE_VARIABLE_DECL, NODE_CLASS_DECL, NODE_MODULE_DECL, NODE_VARIABLE,
 	NODE_ENUM_DECL, NODE_FUNCTION_DECL, NODE_VARIABLE_DECL, NODE_CLASS_DECL, NODE_MODULE_DECL, NODE_VARIABLE,
-	
+
 	// expressions: 8
 	// expressions: 8
 	NODE_BINARY_EXPR, NODE_UNARY_EXPR, NODE_FILE_EXPR, NODE_LIST_EXPR, NODE_LITERAL_EXPR, NODE_IDENTIFIER_EXPR,
 	NODE_BINARY_EXPR, NODE_UNARY_EXPR, NODE_FILE_EXPR, NODE_LIST_EXPR, NODE_LITERAL_EXPR, NODE_IDENTIFIER_EXPR,
 	NODE_POSTFIX_EXPR, NODE_KEYWORD_EXPR,
 	NODE_POSTFIX_EXPR, NODE_KEYWORD_EXPR,
-	
+
 	// postfix subexpression type
 	// postfix subexpression type
 	NODE_CALL_EXPR, NODE_SUBSCRIPT_EXPR, NODE_ACCESS_EXPR
 	NODE_CALL_EXPR, NODE_SUBSCRIPT_EXPR, NODE_ACCESS_EXPR
 } gnode_n;
 } gnode_n;

File diff suppressed because it is too large
+ 155 - 155
src/compiler/gravity_codegen.c


+ 23 - 23
src/compiler/gravity_compiler.c

@@ -34,18 +34,18 @@ static void internal_vm_transfer (gravity_vm *vm, gravity_object_t *obj) {
 
 
 static void internal_free_class (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value, void *data) {
 static void internal_free_class (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value, void *data) {
 	#pragma unused (hashtable, data)
 	#pragma unused (hashtable, data)
-	
+
 	// sanity checks
 	// sanity checks
 	if (!VALUE_ISA_FUNCTION(value)) return;
 	if (!VALUE_ISA_FUNCTION(value)) return;
 	if (!VALUE_ISA_STRING(key)) return;
 	if (!VALUE_ISA_STRING(key)) return;
-	
+
 	// check for special function
 	// check for special function
 	gravity_function_t *f = VALUE_AS_FUNCTION(value);
 	gravity_function_t *f = VALUE_AS_FUNCTION(value);
 	if (f->tag == EXEC_TYPE_SPECIAL) {
 	if (f->tag == EXEC_TYPE_SPECIAL) {
 		if (f->special[0]) gravity_function_free(NULL, (gravity_function_t *)f->special[0]);
 		if (f->special[0]) gravity_function_free(NULL, (gravity_function_t *)f->special[0]);
 		if (f->special[1]) gravity_function_free(NULL, (gravity_function_t *)f->special[1]);
 		if (f->special[1]) gravity_function_free(NULL, (gravity_function_t *)f->special[1]);
 	}
 	}
-	
+
 	// a super special init constructor is a string that begins with $init AND it is longer than strlen($init)
 	// a super special init constructor is a string that begins with $init AND it is longer than strlen($init)
 	gravity_string_t *s = VALUE_AS_STRING(key);
 	gravity_string_t *s = VALUE_AS_STRING(key);
 	bool is_super_function = ((s->len > 5) && (string_casencmp(s->s, CLASS_INTERNAL_INIT_NAME, 5) == 0));
 	bool is_super_function = ((s->len > 5) && (string_casencmp(s->s, CLASS_INTERNAL_INIT_NAME, 5) == 0));
@@ -70,7 +70,7 @@ static void internal_vm_cleanup (gravity_vm *vm) {
 gravity_compiler_t *gravity_compiler_create (gravity_delegate_t *delegate) {
 gravity_compiler_t *gravity_compiler_create (gravity_delegate_t *delegate) {
 	gravity_compiler_t *compiler = mem_alloc(sizeof(gravity_compiler_t));
 	gravity_compiler_t *compiler = mem_alloc(sizeof(gravity_compiler_t));
 	if (!compiler) return NULL;
 	if (!compiler) return NULL;
-	
+
 	compiler->ast = NULL;
 	compiler->ast = NULL;
 	compiler->objects = void_array_create();
 	compiler->objects = void_array_create();
 	compiler->delegate = delegate;
 	compiler->delegate = delegate;
@@ -83,21 +83,21 @@ static void gravity_compiler_reset (gravity_compiler_t *compiler, bool free_core
 		cstring_array_each(compiler->storage, {mem_free((void *)val);});
 		cstring_array_each(compiler->storage, {mem_free((void *)val);});
 		gnode_array_free(compiler->storage);
 		gnode_array_free(compiler->storage);
 	}
 	}
-	
+
 	// first ast then parser, don't change the release order
 	// first ast then parser, don't change the release order
 	if (compiler->ast) gnode_free(compiler->ast);
 	if (compiler->ast) gnode_free(compiler->ast);
 	if (compiler->parser) gravity_parser_free(compiler->parser);
 	if (compiler->parser) gravity_parser_free(compiler->parser);
-	
+
 	// at the end free mini VM and objects array
 	// at the end free mini VM and objects array
 	if (compiler->vm) gravity_vm_free(compiler->vm);
 	if (compiler->vm) gravity_vm_free(compiler->vm);
 	if (compiler->objects) {
 	if (compiler->objects) {
 		marray_destroy(*compiler->objects);
 		marray_destroy(*compiler->objects);
 		mem_free((void*)compiler->objects);
 		mem_free((void*)compiler->objects);
 	}
 	}
-	
+
 	// feel free to free core if someone requires it
 	// feel free to free core if someone requires it
     if (free_core) gravity_core_free();
     if (free_core) gravity_core_free();
-	
+
 	// reset internal pointers
 	// reset internal pointers
 	compiler->vm = NULL;
 	compiler->vm = NULL;
 	compiler->ast = NULL;
 	compiler->ast = NULL;
@@ -117,7 +117,7 @@ gnode_t *gravity_compiler_ast (gravity_compiler_t *compiler) {
 
 
 void gravity_compiler_transfer(gravity_compiler_t *compiler, gravity_vm *vm) {
 void gravity_compiler_transfer(gravity_compiler_t *compiler, gravity_vm *vm) {
 	if (!compiler->objects) return;
 	if (!compiler->objects) return;
-	
+
 	// transfer each object from compiler mini VM to exec VM
 	// transfer each object from compiler mini VM to exec VM
 	gravity_gc_setenabled(vm, false);
 	gravity_gc_setenabled(vm, false);
 	size_t count = marray_size(*compiler->objects);
 	size_t count = marray_size(*compiler->objects);
@@ -125,7 +125,7 @@ void gravity_compiler_transfer(gravity_compiler_t *compiler, gravity_vm *vm) {
 		gravity_object_t *obj = marray_pop(*compiler->objects);
 		gravity_object_t *obj = marray_pop(*compiler->objects);
 		gravity_vm_transfer(vm, obj);
 		gravity_vm_transfer(vm, obj);
 		if (!OBJECT_ISA_CLOSURE(obj)) continue;
 		if (!OBJECT_ISA_CLOSURE(obj)) continue;
-		
+
 		// $moduleinit closure needs to be explicitly initialized
 		// $moduleinit closure needs to be explicitly initialized
 		gravity_closure_t *closure = (gravity_closure_t *)obj;
 		gravity_closure_t *closure = (gravity_closure_t *)obj;
 		if ((closure->f->identifier) && strcmp(closure->f->identifier, INITMODULE_NAME) == 0) {
 		if ((closure->f->identifier) && strcmp(closure->f->identifier, INITMODULE_NAME) == 0) {
@@ -134,7 +134,7 @@ void gravity_compiler_transfer(gravity_compiler_t *compiler, gravity_vm *vm) {
 			gravity_vm_initmodule(vm, closure->f);
 			gravity_vm_initmodule(vm, closure->f);
 		}
 		}
 	}
 	}
-	
+
 	gravity_gc_setenabled(vm, true);
 	gravity_gc_setenabled(vm, true);
 }
 }
 
 
@@ -142,43 +142,43 @@ void gravity_compiler_transfer(gravity_compiler_t *compiler, gravity_vm *vm) {
 
 
 gravity_closure_t *gravity_compiler_run (gravity_compiler_t *compiler, const char *source, size_t len, uint32_t fileid, bool is_static) {
 gravity_closure_t *gravity_compiler_run (gravity_compiler_t *compiler, const char *source, size_t len, uint32_t fileid, bool is_static) {
 	if ((source == NULL) || (len == 0)) return NULL;
 	if ((source == NULL) || (len == 0)) return NULL;
-	
+
 	// CHECK cleanup first
 	// CHECK cleanup first
 	if (compiler->ast) gnode_free(compiler->ast);
 	if (compiler->ast) gnode_free(compiler->ast);
 	if (!compiler->objects) compiler->objects = void_array_create();
 	if (!compiler->objects) compiler->objects = void_array_create();
-	
+
 	// CODEGEN requires a mini vm in order to be able to handle garbage collector
 	// CODEGEN requires a mini vm in order to be able to handle garbage collector
 	compiler->vm = gravity_vm_newmini();
 	compiler->vm = gravity_vm_newmini();
 	gravity_vm_setdata(compiler->vm, (void *)compiler);
 	gravity_vm_setdata(compiler->vm, (void *)compiler);
 	gravity_vm_set_callbacks(compiler->vm, internal_vm_transfer, internal_vm_cleanup);
 	gravity_vm_set_callbacks(compiler->vm, internal_vm_transfer, internal_vm_cleanup);
 	gravity_core_register(compiler->vm);
 	gravity_core_register(compiler->vm);
-	
+
 	// STEP 0: CREATE PARSER
 	// STEP 0: CREATE PARSER
 	compiler->parser = gravity_parser_create(source, len, fileid, is_static);
 	compiler->parser = gravity_parser_create(source, len, fileid, is_static);
 	if (!compiler->parser) return NULL;
 	if (!compiler->parser) return NULL;
-	
+
 	// STEP 1: SYNTAX CHECK
 	// STEP 1: SYNTAX CHECK
 	compiler->ast = gravity_parser_run(compiler->parser, compiler->delegate);
 	compiler->ast = gravity_parser_run(compiler->parser, compiler->delegate);
 	if (!compiler->ast) goto abort_compilation;
 	if (!compiler->ast) goto abort_compilation;
 	gravity_parser_free(compiler->parser);
 	gravity_parser_free(compiler->parser);
 	compiler->parser = NULL;
 	compiler->parser = NULL;
-	
+
 	// STEP 2a: SEMANTIC CHECK (NON-LOCAL DECLARATIONS)
 	// STEP 2a: SEMANTIC CHECK (NON-LOCAL DECLARATIONS)
 	bool b1 = gravity_semacheck1(compiler->ast, compiler->delegate);
 	bool b1 = gravity_semacheck1(compiler->ast, compiler->delegate);
 	if (!b1) goto abort_compilation;
 	if (!b1) goto abort_compilation;
-	
+
 	// STEP 2b: SEMANTIC CHECK (LOCAL DECLARATIONS)
 	// STEP 2b: SEMANTIC CHECK (LOCAL DECLARATIONS)
 	bool b2 = gravity_semacheck2(compiler->ast, compiler->delegate);
 	bool b2 = gravity_semacheck2(compiler->ast, compiler->delegate);
 	if (!b2) goto abort_compilation;
 	if (!b2) goto abort_compilation;
-	
+
 	// STEP 3: INTERMEDIATE CODE GENERATION (stack based VM)
 	// STEP 3: INTERMEDIATE CODE GENERATION (stack based VM)
 	gravity_function_t *f = gravity_codegen(compiler->ast, compiler->delegate, compiler->vm);
 	gravity_function_t *f = gravity_codegen(compiler->ast, compiler->delegate, compiler->vm);
 	if (!f) goto abort_compilation;
 	if (!f) goto abort_compilation;
-	
+
 	// STEP 4: CODE GENERATION (register based VM)
 	// STEP 4: CODE GENERATION (register based VM)
 	f = gravity_optimizer(f);
 	f = gravity_optimizer(f);
 	if (f) return gravity_closure_new(compiler->vm, f);
 	if (f) return gravity_closure_new(compiler->vm, f);
-	
+
 abort_compilation:
 abort_compilation:
 	gravity_compiler_reset(compiler, false);
 	gravity_compiler_reset(compiler, false);
 	return NULL;
 	return NULL;
@@ -186,12 +186,12 @@ abort_compilation:
 
 
 json_t *gravity_compiler_serialize (gravity_compiler_t *compiler, gravity_closure_t *closure) {
 json_t *gravity_compiler_serialize (gravity_compiler_t *compiler, gravity_closure_t *closure) {
 	#pragma unused(compiler)
 	#pragma unused(compiler)
-	
+
 	json_t *json = json_new();
 	json_t *json = json_new();
 	json_begin_object(json, NULL);
 	json_begin_object(json, NULL);
-	
+
 	gravity_function_serialize(closure->f, json);
 	gravity_function_serialize(closure->f, json);
-	
+
 	json_end_object(json);
 	json_end_object(json);
 	return json;
 	return json;
 }
 }

+ 36 - 36
src/compiler/gravity_ircode.c

@@ -15,16 +15,16 @@ typedef marray_t(bool *)		context_r;
 
 
 struct ircode_t {
 struct ircode_t {
 	code_r		*list;						// array of ircode instructions
 	code_r		*list;						// array of ircode instructions
-	
+
 	uint32_r	label_true;					// labels used in loops
 	uint32_r	label_true;					// labels used in loops
 	uint32_r	label_false;
 	uint32_r	label_false;
 	uint32_t	label_counter;
 	uint32_t	label_counter;
-	
+
 	uint32_t	maxtemp;					// maximum number of temp registers used in this ircode
 	uint32_t	maxtemp;					// maximum number of temp registers used in this ircode
 	uint32_t	ntemps;						// current number of temp registers in use
 	uint32_t	ntemps;						// current number of temp registers in use
 	uint16_t	nlocals;					// number of local registers (params + local variables)
 	uint16_t	nlocals;					// number of local registers (params + local variables)
 	bool		error;						// error flag set when no more registers are availables
 	bool		error;						// error flag set when no more registers are availables
-	
+
 	bool		state[MAX_REGISTERS];		// registers mask
 	bool		state[MAX_REGISTERS];		// registers mask
 	bool		skipclear[MAX_REGISTERS];	// registers protection for temps used in for loop
 	bool		skipclear[MAX_REGISTERS];	// registers protection for temps used in for loop
 	uint32_r	registers;					// registers stack
 	uint32_r	registers;					// registers stack
@@ -38,14 +38,14 @@ ircode_t *ircode_create (uint16_t nlocals) {
 	code->ntemps = 0;
 	code->ntemps = 0;
 	code->maxtemp = 0;
 	code->maxtemp = 0;
 	code->error = false;
 	code->error = false;
-	
+
 	code->list = mem_alloc(sizeof(code_r));
 	code->list = mem_alloc(sizeof(code_r));
 	marray_init(*code->list);
 	marray_init(*code->list);
 	marray_init(code->label_true);
 	marray_init(code->label_true);
 	marray_init(code->label_false);
 	marray_init(code->label_false);
 	marray_init(code->registers);
 	marray_init(code->registers);
 	marray_init(code->context);
 	marray_init(code->context);
-	
+
 	// init state array (register 0 is reserved)
 	// init state array (register 0 is reserved)
 	bzero(code->state, MAX_REGISTERS * sizeof(bool));
 	bzero(code->state, MAX_REGISTERS * sizeof(bool));
 	code->state[0] = true;
 	code->state[0] = true;
@@ -61,7 +61,7 @@ void ircode_free (ircode_t *code) {
 		inst_t *inst = marray_get(*code->list, i);
 		inst_t *inst = marray_get(*code->list, i);
 		mem_free(inst);
 		mem_free(inst);
 	}
 	}
-	
+
 	marray_destroy(*code->list);
 	marray_destroy(*code->list);
     marray_destroy(code->context);
     marray_destroy(code->context);
 	marray_destroy(code->registers);
 	marray_destroy(code->registers);
@@ -90,14 +90,14 @@ bool ircode_iserror (ircode_t *code) {
 // MARK: -
 // MARK: -
 
 
 static inst_t *inst_new (opcode_t op, uint32_t p1, uint32_t p2, uint32_t p3, optag_t tag, int64_t n, double d) {
 static inst_t *inst_new (opcode_t op, uint32_t p1, uint32_t p2, uint32_t p3, optag_t tag, int64_t n, double d) {
-	
+
 	// debug code
 	// debug code
 	#if GRAVITY_OPCODE_DEBUG
 	#if GRAVITY_OPCODE_DEBUG
 	if (tag == LABEL_TAG) {
 	if (tag == LABEL_TAG) {
 		DEBUG_OPCODE("LABEL %d", p1);
 		DEBUG_OPCODE("LABEL %d", p1);
 	} else {
 	} else {
 		const char *op_name = opcode_name(op);
 		const char *op_name = opcode_name(op);
-		
+
 		if (op == LOADI) {
 		if (op == LOADI) {
 			if (tag == DOUBLE_TAG)
 			if (tag == DOUBLE_TAG)
 				printf("%s %d %.2f\n", op_name, p1, d);
 				printf("%s %d %.2f\n", op_name, p1, d);
@@ -117,17 +117,17 @@ static inst_t *inst_new (opcode_t op, uint32_t p1, uint32_t p2, uint32_t p3, opt
 		}
 		}
 	}
 	}
 	#endif
 	#endif
-	
+
 	inst_t *inst = (inst_t *)mem_alloc(sizeof(inst_t));
 	inst_t *inst = (inst_t *)mem_alloc(sizeof(inst_t));
 	inst->op = op;
 	inst->op = op;
 	inst->tag = tag;
 	inst->tag = tag;
 	inst->p1 = p1;
 	inst->p1 = p1;
 	inst->p2 = p2;
 	inst->p2 = p2;
 	inst->p3 = p3;
 	inst->p3 = p3;
-	
+
 	if (tag == DOUBLE_TAG) inst->d = d;
 	if (tag == DOUBLE_TAG) inst->d = d;
 	else if (tag == INT_TAG) inst->n = n;
 	else if (tag == INT_TAG) inst->n = n;
-	
+
 	assert(inst);
 	assert(inst);
 	return inst;
 	return inst;
 }
 }
@@ -142,35 +142,35 @@ void ircode_patch_init (ircode_t *code, uint16_t index) {
 	// LOAD  temp 0 temp
 	// LOAD  temp 0 temp
 	// MOVE  temp+1 0
 	// MOVE  temp+1 0
 	// CALL  temp temp 1
 	// CALL  temp temp 1
-	
+
 	// load constant
 	// load constant
 	uint32_t dest = ircode_register_push_temp(code);
 	uint32_t dest = ircode_register_push_temp(code);
 	inst_t *inst1 = inst_new(LOADK, dest, index, 0, NO_TAG, 0, 0.0);
 	inst_t *inst1 = inst_new(LOADK, dest, index, 0, NO_TAG, 0, 0.0);
-	
+
 	// load from lookup
 	// load from lookup
 	inst_t *inst2 = inst_new(LOAD, dest, 0, dest, NO_TAG, 0, 0.0);
 	inst_t *inst2 = inst_new(LOAD, dest, 0, dest, NO_TAG, 0, 0.0);
-	
+
 	// prepare parameter
 	// prepare parameter
 	uint32_t dest2 = ircode_register_push_temp(code);
 	uint32_t dest2 = ircode_register_push_temp(code);
 	inst_t *inst3 = inst_new(MOVE, dest2, 0, 0, NO_TAG, 0, 0.0);
 	inst_t *inst3 = inst_new(MOVE, dest2, 0, 0, NO_TAG, 0, 0.0);
 	ircode_register_pop(code);
 	ircode_register_pop(code);
-	
+
 	// execute call
 	// execute call
 	inst_t *inst4 = inst_new(CALL, dest, dest, 1, NO_TAG, 0, 0.0);
 	inst_t *inst4 = inst_new(CALL, dest, dest, 1, NO_TAG, 0, 0.0);
-	
+
 	// pop temps used
 	// pop temps used
 	ircode_register_pop(code);
 	ircode_register_pop(code);
-	
+
 	// create new instruction list
 	// create new instruction list
 	code_r		*list = mem_alloc(sizeof(code_r));
 	code_r		*list = mem_alloc(sizeof(code_r));
 	marray_init(*list);
 	marray_init(*list);
-	
+
 	// add newly create instructions
 	// add newly create instructions
 	marray_push(inst_t*, *list, inst1);
 	marray_push(inst_t*, *list, inst1);
 	marray_push(inst_t*, *list, inst2);
 	marray_push(inst_t*, *list, inst2);
 	marray_push(inst_t*, *list, inst3);
 	marray_push(inst_t*, *list, inst3);
 	marray_push(inst_t*, *list, inst4);
 	marray_push(inst_t*, *list, inst4);
-	
+
 	// then copy original instructions
 	// then copy original instructions
 	code_r *orig_list = code->list;
 	code_r *orig_list = code->list;
 	uint32_t count = ircode_count(code);
 	uint32_t count = ircode_count(code);
@@ -178,11 +178,11 @@ void ircode_patch_init (ircode_t *code, uint16_t index) {
 		inst_t *inst = marray_get(*orig_list, i);
 		inst_t *inst = marray_get(*orig_list, i);
 		marray_push(inst_t*, *list, inst);
 		marray_push(inst_t*, *list, inst);
 	}
 	}
-	
+
 	// free dest list
 	// free dest list
 	marray_destroy(*orig_list);
 	marray_destroy(*orig_list);
 	mem_free(code->list);
 	mem_free(code->list);
-	
+
 	// replace dest list with the newly created list
 	// replace dest list with the newly created list
 	code->list = list;
 	code->list = list;
 }
 }
@@ -247,7 +247,7 @@ uint8_t opcode_numop (opcode_t op) {
 		case RESERVED5:
 		case RESERVED5:
 		case RESERVED6: return 0;
 		case RESERVED6: return 0;
 	}
 	}
-	
+
 	assert(0);
 	assert(0);
 	return 0;
 	return 0;
 }
 }
@@ -256,12 +256,12 @@ void ircode_dump  (void *_code) {
 	ircode_t	*code = (ircode_t *)_code;
 	ircode_t	*code = (ircode_t *)_code;
 	code_r		*list = code->list;
 	code_r		*list = code->list;
 	uint32_t	count = ircode_count(code);
 	uint32_t	count = ircode_count(code);
-	
+
 	if (count == 0) {
 	if (count == 0) {
 		printf("NONE\n");
 		printf("NONE\n");
 		return;
 		return;
 	}
 	}
-	
+
 	for (uint32_t i=0, line=0; i<count; ++i) {
 	for (uint32_t i=0, line=0; i<count; ++i) {
 		inst_t *inst = marray_get(*list, i);
 		inst_t *inst = marray_get(*list, i);
 		opcode_t	op = inst->op;
 		opcode_t	op = inst->op;
@@ -271,19 +271,19 @@ void ircode_dump  (void *_code) {
 		if (inst->tag == SKIP_TAG) continue;
 		if (inst->tag == SKIP_TAG) continue;
 		if (inst->tag == PRAGMA_MOVE_OPTIMIZATION) continue;
 		if (inst->tag == PRAGMA_MOVE_OPTIMIZATION) continue;
 		if (inst->tag == LABEL_TAG) {printf("LABEL %d:\n", p1); continue;}
 		if (inst->tag == LABEL_TAG) {printf("LABEL %d:\n", p1); continue;}
-		
+
 		uint8_t n = opcode_numop(op);
 		uint8_t n = opcode_numop(op);
 		if ((op == SETLIST) && (p2 == 0)) n = 2;
 		if ((op == SETLIST) && (p2 == 0)) n = 2;
-		
+
 		switch (n) {
 		switch (n) {
 			case 0: {
 			case 0: {
 				printf("%05d\t%s\n", line, opcode_name(op));
 				printf("%05d\t%s\n", line, opcode_name(op));
 			}
 			}
-			
+
 			case 1: {
 			case 1: {
 				printf("%05d\t%s %d\n", line, opcode_name(op), p1);
 				printf("%05d\t%s %d\n", line, opcode_name(op), p1);
 			} break;
 			} break;
-				
+
 			case 2: {
 			case 2: {
 				if (op == LOADI) {
 				if (op == LOADI) {
 					if (inst->tag == DOUBLE_TAG) printf("%05d\t%s %d %.2f\n", line, opcode_name(op), p1, inst->d);
 					if (inst->tag == DOUBLE_TAG) printf("%05d\t%s %d %.2f\n", line, opcode_name(op), p1, inst->d);
@@ -299,11 +299,11 @@ void ircode_dump  (void *_code) {
 					printf("%05d\t%s %d %d\n", line, opcode_name(op), p1, p2);
 					printf("%05d\t%s %d %d\n", line, opcode_name(op), p1, p2);
 				}
 				}
 			} break;
 			} break;
-				
+
 			case 3: {
 			case 3: {
 				printf("%05d\t%s %d %d %d\n", line, opcode_name(op), p1, p2, p3);
 				printf("%05d\t%s %d %d %d\n", line, opcode_name(op), p1, p2, p3);
 			} break;
 			} break;
-				
+
 			default: assert(0);
 			default: assert(0);
 		}
 		}
 		++line;
 		++line;
@@ -426,15 +426,15 @@ void ircode_pop_context (ircode_t *code) {
 uint32_t ircode_register_pop_context_protect (ircode_t *code, bool protect) {
 uint32_t ircode_register_pop_context_protect (ircode_t *code, bool protect) {
 	if (marray_size(code->registers) == 0) return REGISTER_ERROR;
 	if (marray_size(code->registers) == 0) return REGISTER_ERROR;
 	uint32_t value = (uint32_t)marray_pop(code->registers);
 	uint32_t value = (uint32_t)marray_pop(code->registers);
-	
+
 	if (protect) code->state[value] = true;
 	if (protect) code->state[value] = true;
 	else if (value >= code->nlocals) code->state[value] = false;
 	else if (value >= code->nlocals) code->state[value] = false;
-	
+
 	if (protect && value >= code->nlocals) {
 	if (protect && value >= code->nlocals) {
 		bool *context = marray_last(code->context);
 		bool *context = marray_last(code->context);
 		context[value] = true;
 		context[value] = true;
 	}
 	}
-	
+
 	DEBUG_REGISTER("POP REGISTER %d", value);
 	DEBUG_REGISTER("POP REGISTER %d", value);
 	return value;
 	return value;
 }
 }
@@ -470,7 +470,7 @@ static uint32_t ircode_register_new (ircode_t *code) {
 uint32_t ircode_register_push (ircode_t *code, uint32_t nreg) {
 uint32_t ircode_register_push (ircode_t *code, uint32_t nreg) {
 	marray_push(uint32_t, code->registers, nreg);
 	marray_push(uint32_t, code->registers, nreg);
 	if (ircode_register_istemp(code, nreg)) ++code->ntemps;
 	if (ircode_register_istemp(code, nreg)) ++code->ntemps;
-	
+
 	DEBUG_REGISTER("PUSH REGISTER %d", nreg);
 	DEBUG_REGISTER("PUSH REGISTER %d", nreg);
 	return nreg;
 	return nreg;
 }
 }
@@ -479,7 +479,7 @@ uint32_t ircode_register_push_temp (ircode_t *code) {
 	uint32_t value = ircode_register_new(code);
 	uint32_t value = ircode_register_new(code);
 	marray_push(uint32_t, code->registers, value);
 	marray_push(uint32_t, code->registers, value);
 	if (value > code->maxtemp) {code->maxtemp = value; ++code->ntemps;}
 	if (value > code->maxtemp) {code->maxtemp = value; ++code->ntemps;}
-	
+
 	DEBUG_REGISTER("PUSH REGISTER %d", value);
 	DEBUG_REGISTER("PUSH REGISTER %d", value);
 	return value;
 	return value;
 }
 }
@@ -532,7 +532,7 @@ void ircode_register_unset_skip_clear (ircode_t *code, uint32_t nreg) {
 	code->skipclear[nreg] = false;
 	code->skipclear[nreg] = false;
 }
 }
 
 
-void ircode_register_clear_temps (ircode_t *code) {	
+void ircode_register_clear_temps (ircode_t *code) {
 	// clear all temporary registers (if not protected)
 	// clear all temporary registers (if not protected)
 	for (uint32_t i=code->nlocals; i<=code->maxtemp; ++i) {
 	for (uint32_t i=code->nlocals; i<=code->maxtemp; ++i) {
 		if (!code->skipclear[i]) code->state[i] = false;
 		if (!code->skipclear[i]) code->state[i] = false;

+ 58 - 58
src/compiler/gravity_lexer.c

@@ -20,7 +20,7 @@ struct gravity_lexer_t {
 	uint32_t					lineno;			// line counter
 	uint32_t					lineno;			// line counter
 	uint32_t					colno;			// column counter
 	uint32_t					colno;			// column counter
 	uint32_t					fileid;			// current file id
 	uint32_t					fileid;			// current file id
-	
+
 	gtoken_s					token;			// current token
 	gtoken_s					token;			// current token
 	bool						peeking;		// flag to check if a peek operation is in progress
 	bool						peeking;		// flag to check if a peek operation is in progress
 	bool						is_static;		// flag to check if buffer is static and must not be freed
 	bool						is_static;		// flag to check if buffer is static and must not be freed
@@ -75,30 +75,30 @@ static inline bool is_newline (gravity_lexer_t *lexer, int c) {
 	// CR: Carriage Return, U+000D (UTF-8 in hex: 0D)
 	// CR: Carriage Return, U+000D (UTF-8 in hex: 0D)
 	// LF: Line Feed, U+000A (UTF-8 in hex: 0A)
 	// LF: Line Feed, U+000A (UTF-8 in hex: 0A)
 	// CR+LF: CR (U+000D) followed by LF (U+000A) (UTF-8 in hex: 0D0A)
 	// CR+LF: CR (U+000D) followed by LF (U+000A) (UTF-8 in hex: 0D0A)
-	
+
 	// LF
 	// LF
 	if (c == 0x0A) return true;
 	if (c == 0x0A) return true;
-	
+
 	// CR+LF or CR
 	// CR+LF or CR
 	if (c == 0x0D) {
 	if (c == 0x0D) {
 		if (PEEK_NEXT == 0x0A) {NEXT; return true;}
 		if (PEEK_NEXT == 0x0A) {NEXT; return true;}
 		return true;
 		return true;
 	}
 	}
-	
+
 	// UTF-8 cases https://en.wikipedia.org/wiki/Newline#Unicode
 	// UTF-8 cases https://en.wikipedia.org/wiki/Newline#Unicode
-	
+
 	// NEL: Next Line, U+0085 (UTF-8 in hex: C285)
 	// NEL: Next Line, U+0085 (UTF-8 in hex: C285)
 	if ((c == 0xC2) && (PEEK_NEXT == 0x85)) {
 	if ((c == 0xC2) && (PEEK_NEXT == 0x85)) {
 		NEXT;
 		NEXT;
 		return true;
 		return true;
 	}
 	}
-	
+
 	// LS: Line Separator, U+2028 (UTF-8 in hex: E280A8)
 	// LS: Line Separator, U+2028 (UTF-8 in hex: E280A8)
 	if ((c == 0xE2) && (PEEK_NEXT == 0x80) && (PEEK_NEXT2 == 0xA8)) {
 	if ((c == 0xE2) && (PEEK_NEXT == 0x80) && (PEEK_NEXT2 == 0xA8)) {
 		NEXT; NEXT;
 		NEXT; NEXT;
 		return true;
 		return true;
 	}
 	}
-		
+
 	// and probably more not handled here
 	// and probably more not handled here
 	return false;
 	return false;
 }
 }
@@ -138,7 +138,7 @@ static inline bool is_builtin_operator (int c) {
 	// . ; : ? ,
 	// . ; : ? ,
 	// OPERATORS
 	// OPERATORS
 	// + - * / < > ! = | & ^ % ~
 	// + - * / < > ! = | & ^ % ~
-	
+
 	return ((c == '+') || (c == '-') || (c == '*') || (c == '/') ||
 	return ((c == '+') || (c == '-') || (c == '*') || (c == '/') ||
 			(c == '<') || (c == '>') || (c == '!') || (c == '=') ||
 			(c == '<') || (c == '>') || (c == '!') || (c == '=') ||
 			(c == '|') || (c == '&') || (c == '^') || (c == '%') ||
 			(c == '|') || (c == '&') || (c == '^') || (c == '%') ||
@@ -173,37 +173,37 @@ static gtoken_t lexer_error(gravity_lexer_t *lexer, const char *message) {
 static inline bool next_utf8(gravity_lexer_t *lexer, int *result) {
 static inline bool next_utf8(gravity_lexer_t *lexer, int *result) {
 	int c = NEXT;
 	int c = NEXT;
 	INC_TOKLEN;
 	INC_TOKLEN;
-	
+
 	uint32_t len = utf8_charbytes((const char *)&c, 0);
 	uint32_t len = utf8_charbytes((const char *)&c, 0);
 	if (len == 0) return false;
 	if (len == 0) return false;
-	
+
 	switch(len) {
 	switch(len) {
 		case 1: break;
 		case 1: break;
 		case 2: INC_OFFSET; INC_TOKBYTES; break;
 		case 2: INC_OFFSET; INC_TOKBYTES; break;
 		case 3: INC_OFFSET; INC_OFFSET; INC_TOKBYTES; INC_TOKBYTES; break;
 		case 3: INC_OFFSET; INC_OFFSET; INC_TOKBYTES; INC_TOKBYTES; break;
 		case 4: INC_OFFSET; INC_OFFSET; INC_OFFSET; INC_TOKBYTES; INC_TOKBYTES; INC_TOKBYTES; INC_POSITION; INC_TOKUTF8LEN; break;
 		case 4: INC_OFFSET; INC_OFFSET; INC_OFFSET; INC_TOKBYTES; INC_TOKBYTES; INC_TOKBYTES; INC_POSITION; INC_TOKUTF8LEN; break;
 	}
 	}
-	
+
 	if (result) *result = c;
 	if (result) *result = c;
 	return true;
 	return true;
 }
 }
 
 
 static gtoken_t lexer_scan_comment(gravity_lexer_t *lexer) {
 static gtoken_t lexer_scan_comment(gravity_lexer_t *lexer) {
 	bool isLineComment = (PEEK_NEXT == '/');
 	bool isLineComment = (PEEK_NEXT == '/');
-	
+
 	TOKEN_RESET;
 	TOKEN_RESET;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
-	
+
 	// because I already scanned /* or //
 	// because I already scanned /* or //
 	lexer->token.bytes = lexer->token.length = 2;
 	lexer->token.bytes = lexer->token.length = 2;
-	
+
 	// count variable used only to support nested comments
 	// count variable used only to support nested comments
 	int count = 1;
 	int count = 1;
 	while (!IS_EOF) {
 	while (!IS_EOF) {
 		int c = 0;
 		int c = 0;
 		next_utf8(lexer, &c);
 		next_utf8(lexer, &c);
-		
+
 		if (isLineComment){
 		if (isLineComment){
 			if (is_newline(lexer, c)) {INC_LINE; break;}
 			if (is_newline(lexer, c)) {INC_LINE; break;}
 		} else {
 		} else {
@@ -214,15 +214,15 @@ static gtoken_t lexer_scan_comment(gravity_lexer_t *lexer) {
 			if (is_newline(lexer, c)) {INC_LINE;}
 			if (is_newline(lexer, c)) {INC_LINE;}
 		}
 		}
 	}
 	}
-	
+
 	// comment is from buffer->[nseek] and it is nlen length
 	// comment is from buffer->[nseek] and it is nlen length
 	TOKEN_FINALIZE(TOK_COMMENT);
 	TOKEN_FINALIZE(TOK_COMMENT);
-	
+
 	// comments callback is called directly from the scan function and not from the main scan loop
 	// comments callback is called directly from the scan function and not from the main scan loop
 	if ((lexer->delegate) && (lexer->delegate->parser_callback)) {
 	if ((lexer->delegate) && (lexer->delegate->parser_callback)) {
 		lexer->delegate->parser_callback(&lexer->token, lexer->delegate->xdata);
 		lexer->delegate->parser_callback(&lexer->token, lexer->delegate->xdata);
 	}
 	}
-	
+
 	DEBUG_LEXEM("Found comment");
 	DEBUG_LEXEM("Found comment");
 	return TOK_COMMENT;
 	return TOK_COMMENT;
 }
 }
@@ -232,29 +232,29 @@ static gtoken_t lexer_scan_semicolon(gravity_lexer_t *lexer) {
 	INC_TOKLEN;
 	INC_TOKLEN;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
 	TOKEN_FINALIZE(TOK_OP_SEMICOLON);
 	TOKEN_FINALIZE(TOK_OP_SEMICOLON);
-	
+
 	return TOK_OP_SEMICOLON;
 	return TOK_OP_SEMICOLON;
 }
 }
 
 
-static gtoken_t lexer_scan_identifier(gravity_lexer_t *lexer) {	
+static gtoken_t lexer_scan_identifier(gravity_lexer_t *lexer) {
 	TOKEN_RESET;
 	TOKEN_RESET;
 	while (is_identifier(PEEK_CURRENT)) {
 	while (is_identifier(PEEK_CURRENT)) {
 		INC_OFFSET_POSITION;
 		INC_OFFSET_POSITION;
 		INC_TOKLEN;
 		INC_TOKLEN;
 	}
 	}
 	TOKEN_FINALIZE(TOK_IDENTIFIER);
 	TOKEN_FINALIZE(TOK_IDENTIFIER);
-	
+
     // check if identifier is a special built-in case
     // check if identifier is a special built-in case
     gtoken_t type = token_special_builtin(&lexer->token);
     gtoken_t type = token_special_builtin(&lexer->token);
     // then check if it is a reserved word (otherwise reports it as an identifier)
     // then check if it is a reserved word (otherwise reports it as an identifier)
     if (type == TOK_IDENTIFIER) type = token_keyword(lexer->token.value, lexer->token.bytes);
     if (type == TOK_IDENTIFIER) type = token_keyword(lexer->token.value, lexer->token.bytes);
 	SET_TOKTYPE(type);
 	SET_TOKTYPE(type);
-	
+
 	#if GRAVITY_LEXEM_DEBUG
 	#if GRAVITY_LEXEM_DEBUG
 	if (type == TOK_IDENTIFIER) DEBUG_LEXEM("Found identifier: %.*s", TOKEN_BYTES(lexer->token), TOKEN_VALUE(lexer->token));
 	if (type == TOK_IDENTIFIER) DEBUG_LEXEM("Found identifier: %.*s", TOKEN_BYTES(lexer->token), TOKEN_VALUE(lexer->token));
 	else DEBUG_LEXEM("Found keyword: %s", token_name(type));
 	else DEBUG_LEXEM("Found keyword: %s", token_name(type));
 	#endif
 	#endif
-	
+
 	return type;
 	return type;
 }
 }
 
 
@@ -266,14 +266,14 @@ static gtoken_t lexer_scan_number(gravity_lexer_t *lexer) {
 	bool		expFound = false;
 	bool		expFound = false;
 	int			c, expChar = 'e', floatChar = '.';
 	int			c, expChar = 'e', floatChar = '.';
 	int			plusSign = '+', minusSign = '-';
 	int			plusSign = '+', minusSign = '-';
-	
+
 	gravity_number_type	ntype = NUMBER_INTEGER;
 	gravity_number_type	ntype = NUMBER_INTEGER;
 	if (PEEK_CURRENT == '0') {
 	if (PEEK_CURRENT == '0') {
 		if (toupper(PEEK_NEXT) == 'X') {ntype = NUMBER_HEX; floatAllowed = false; expAllowed = false;}
 		if (toupper(PEEK_NEXT) == 'X') {ntype = NUMBER_HEX; floatAllowed = false; expAllowed = false;}
 		else if (toupper(PEEK_NEXT) == 'B') {ntype = NUMBER_BIN; floatAllowed = false; expAllowed = false;}
 		else if (toupper(PEEK_NEXT) == 'B') {ntype = NUMBER_BIN; floatAllowed = false; expAllowed = false;}
 		else if (toupper(PEEK_NEXT) == 'O') {ntype = NUMBER_OCT; floatAllowed = false; expAllowed = false;}
 		else if (toupper(PEEK_NEXT) == 'O') {ntype = NUMBER_OCT; floatAllowed = false; expAllowed = false;}
 	}
 	}
-	
+
 	TOKEN_RESET;
 	TOKEN_RESET;
 	if (ntype != NUMBER_INTEGER) {
 	if (ntype != NUMBER_INTEGER) {
 		// skip first 0* number marker
 		// skip first 0* number marker
@@ -282,7 +282,7 @@ static gtoken_t lexer_scan_number(gravity_lexer_t *lexer) {
 		INC_OFFSET_POSITION;
 		INC_OFFSET_POSITION;
 		INC_OFFSET_POSITION;
 		INC_OFFSET_POSITION;
 	}
 	}
-	
+
 	// supported exp formats:
 	// supported exp formats:
 	// 12345	// decimal
 	// 12345	// decimal
 	// 3.1415	// float
 	// 3.1415	// float
@@ -291,16 +291,16 @@ static gtoken_t lexer_scan_number(gravity_lexer_t *lexer) {
 	// 0xFFFF	// hex
 	// 0xFFFF	// hex
 	// 0B0101	// binary
 	// 0B0101	// binary
 	// 0O7777	// octal
 	// 0O7777	// octal
-	
+
 loop:
 loop:
 	c = PEEK_CURRENT;
 	c = PEEK_CURRENT;
-	
+
 	// explicitly list all accepted cases
 	// explicitly list all accepted cases
 	if (IS_EOF) goto report_token;
 	if (IS_EOF) goto report_token;
 	if (is_digit(c, ntype)) goto accept_char;
 	if (is_digit(c, ntype)) goto accept_char;
 	if (is_whitespace(c)) goto report_token;
 	if (is_whitespace(c)) goto report_token;
 	if (is_newline(lexer, c)) goto report_token;
 	if (is_newline(lexer, c)) goto report_token;
-	
+
 	if (expAllowed) {
 	if (expAllowed) {
 		if ((c == expChar) && (!expFound)) {expFound = true; signAllowed = true; goto accept_char;}
 		if ((c == expChar) && (!expFound)) {expFound = true; signAllowed = true; goto accept_char;}
 	}
 	}
@@ -313,10 +313,10 @@ loop:
 	}
 	}
 	if (is_builtin_operator(c)) goto report_token;
 	if (is_builtin_operator(c)) goto report_token;
 	if (is_semicolon(c)) goto report_token;
 	if (is_semicolon(c)) goto report_token;
-	
+
 	// any other case is an error
 	// any other case is an error
 	goto report_error;
 	goto report_error;
-	
+
 accept_char:
 accept_char:
 	INC_TOKLEN;
 	INC_TOKLEN;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
@@ -325,48 +325,48 @@ accept_char:
 report_token:
 report_token:
 	// number is from buffer->[nseek] and it is bytes length
 	// number is from buffer->[nseek] and it is bytes length
 	TOKEN_FINALIZE(TOK_NUMBER);
 	TOKEN_FINALIZE(TOK_NUMBER);
-	
+
 	DEBUG_LEXEM("Found number: %.*s", TOKEN_BYTES(lexer->token), TOKEN_VALUE(lexer->token));
 	DEBUG_LEXEM("Found number: %.*s", TOKEN_BYTES(lexer->token), TOKEN_VALUE(lexer->token));
 	return TOK_NUMBER;
 	return TOK_NUMBER;
-	
+
 report_error:
 report_error:
 	return lexer_error(lexer, "Malformed number expression.");
 	return lexer_error(lexer, "Malformed number expression.");
 }
 }
 
 
 static gtoken_t lexer_scan_string(gravity_lexer_t *lexer) {
 static gtoken_t lexer_scan_string(gravity_lexer_t *lexer) {
 	int c, c2;
 	int c, c2;
-	
+
 	// no memory allocation here
 	// no memory allocation here
 	c = NEXT;					// save escaped character
 	c = NEXT;					// save escaped character
 	TOKEN_RESET;				// save offset
 	TOKEN_RESET;				// save offset
-	
+
 	while ((c2 = (unsigned char)PEEK_CURRENT) != c) {
 	while ((c2 = (unsigned char)PEEK_CURRENT) != c) {
 		if (IS_EOF) return lexer_error(lexer, "Unexpected EOF inside a string literal");
 		if (IS_EOF) return lexer_error(lexer, "Unexpected EOF inside a string literal");
 		if (is_newline(lexer, c2)) INC_LINE;
 		if (is_newline(lexer, c2)) INC_LINE;
-		
+
 		// handle escaped characters
 		// handle escaped characters
 		if (c2 == '\\') {
 		if (c2 == '\\') {
 			INC_OFFSET_POSITION;
 			INC_OFFSET_POSITION;
 			INC_OFFSET_POSITION;
 			INC_OFFSET_POSITION;
 			INC_TOKLEN;
 			INC_TOKLEN;
 			INC_TOKLEN;
 			INC_TOKLEN;
-            
+
             // sanity check
             // sanity check
             if (IS_EOF) return lexer_error(lexer, "Unexpected EOF inside a string literal");
             if (IS_EOF) return lexer_error(lexer, "Unexpected EOF inside a string literal");
 			continue;
 			continue;
 		}
 		}
-		
+
 		// scan next
 		// scan next
 		if (!next_utf8(lexer, NULL)) return lexer_error(lexer, "Unknown character inside a string literal");
 		if (!next_utf8(lexer, NULL)) return lexer_error(lexer, "Unknown character inside a string literal");
         if (IS_EOF) return lexer_error(lexer, "Unexpected EOF inside a string literal");
         if (IS_EOF) return lexer_error(lexer, "Unexpected EOF inside a string literal");
 	}
 	}
-	
+
 	// skip last escape character
 	// skip last escape character
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
-	
+
 	// string is from buffer->[nseek] and it is nlen length
 	// string is from buffer->[nseek] and it is nlen length
 	TOKEN_FINALIZE(TOK_STRING);
 	TOKEN_FINALIZE(TOK_STRING);
-	
+
 	DEBUG_LEXEM("Found string: %.*s", TOKEN_BYTES(lexer->token), TOKEN_VALUE(lexer->token));
 	DEBUG_LEXEM("Found string: %.*s", TOKEN_BYTES(lexer->token), TOKEN_VALUE(lexer->token));
 	return TOK_STRING;
 	return TOK_STRING;
 }
 }
@@ -374,11 +374,11 @@ static gtoken_t lexer_scan_string(gravity_lexer_t *lexer) {
 static gtoken_t lexer_scan_operator(gravity_lexer_t *lexer) {
 static gtoken_t lexer_scan_operator(gravity_lexer_t *lexer) {
 	TOKEN_RESET;
 	TOKEN_RESET;
 	INC_TOKLEN;
 	INC_TOKLEN;
-	
+
 	int c = NEXT;
 	int c = NEXT;
 	int c2 = PEEK_CURRENT;
 	int c2 = PEEK_CURRENT;
 	int tok = 0;
 	int tok = 0;
-	
+
 	switch (c) {
 	switch (c) {
 		case '=':
 		case '=':
 			if (c2 == '=') {
 			if (c2 == '=') {
@@ -495,13 +495,13 @@ static gtoken_t lexer_scan_operator(gravity_lexer_t *lexer) {
 			break;
 			break;
 		default:
 		default:
 			return lexer_error(lexer, "Unrecognized Operator");
 			return lexer_error(lexer, "Unrecognized Operator");
-			
+
 	}
 	}
-	
+
 	TOKEN_FINALIZE(tok);
 	TOKEN_FINALIZE(tok);
-	
+
 	DEBUG_LEXEM("Found operator: %s", token_name(tok));
 	DEBUG_LEXEM("Found operator: %s", token_name(tok));
-	return tok;	
+	return tok;
 }
 }
 
 
 static gtoken_t lexer_scan_special(gravity_lexer_t *lexer) {
 static gtoken_t lexer_scan_special(gravity_lexer_t *lexer) {
@@ -509,7 +509,7 @@ static gtoken_t lexer_scan_special(gravity_lexer_t *lexer) {
 	INC_TOKLEN;
 	INC_TOKLEN;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
 	TOKEN_FINALIZE(TOK_SPECIAL);
 	TOKEN_FINALIZE(TOK_SPECIAL);
-	
+
 	return TOK_SPECIAL;
 	return TOK_SPECIAL;
 }
 }
 
 
@@ -518,7 +518,7 @@ static gtoken_t lexer_scan_preprocessor(gravity_lexer_t *lexer) {
 	INC_TOKLEN;
 	INC_TOKLEN;
 	INC_OFFSET_POSITION;
 	INC_OFFSET_POSITION;
 	TOKEN_FINALIZE(TOK_MACRO);
 	TOKEN_FINALIZE(TOK_MACRO);
-	
+
 	return TOK_MACRO;
 	return TOK_MACRO;
 }
 }
 
 
@@ -528,7 +528,7 @@ gravity_lexer_t *gravity_lexer_create (const char *source, size_t len, uint32_t
 	gravity_lexer_t *lexer = mem_alloc(sizeof(gravity_lexer_t));
 	gravity_lexer_t *lexer = mem_alloc(sizeof(gravity_lexer_t));
 	if (!lexer) return NULL;
 	if (!lexer) return NULL;
 	bzero(lexer, sizeof(gravity_lexer_t));
 	bzero(lexer, sizeof(gravity_lexer_t));
-	
+
 	lexer->is_static = is_static;
 	lexer->is_static = is_static;
 	lexer->lineno = 1;
 	lexer->lineno = 1;
 	lexer->buffer = source;
 	lexer->buffer = source;
@@ -545,27 +545,27 @@ void gravity_lexer_setdelegate (gravity_lexer_t *lexer, gravity_delegate_t *dele
 gtoken_t gravity_lexer_peek (gravity_lexer_t *lexer) {
 gtoken_t gravity_lexer_peek (gravity_lexer_t *lexer) {
 	lexer->peeking = true;
 	lexer->peeking = true;
 	gravity_lexer_t saved = *lexer;
 	gravity_lexer_t saved = *lexer;
-	
+
 	gtoken_t result = gravity_lexer_next(lexer);
 	gtoken_t result = gravity_lexer_next(lexer);
-	
+
 	*lexer = saved;
 	*lexer = saved;
 	lexer->peeking = false;
 	lexer->peeking = false;
-	
+
 	return result;
 	return result;
 }
 }
 
 
 gtoken_t gravity_lexer_next (gravity_lexer_t *lexer) {
 gtoken_t gravity_lexer_next (gravity_lexer_t *lexer) {
 	int			c;
 	int			c;
 	gtoken_t	token;
 	gtoken_t	token;
-	
+
 loop:
 loop:
 	if (IS_EOF) return TOK_EOF;
 	if (IS_EOF) return TOK_EOF;
 	c = PEEK_CURRENT;
 	c = PEEK_CURRENT;
-	
+
 	if (is_whitespace(c)) {INC_OFFSET_POSITION; goto loop;}
 	if (is_whitespace(c)) {INC_OFFSET_POSITION; goto loop;}
 	if (is_newline(lexer, c)) {INC_OFFSET_POSITION; INC_LINE; goto loop;}
 	if (is_newline(lexer, c)) {INC_OFFSET_POSITION; INC_LINE; goto loop;}
 	if (is_comment(c, PEEK_NEXT)) {lexer_scan_comment(lexer); goto loop;}
 	if (is_comment(c, PEEK_NEXT)) {lexer_scan_comment(lexer); goto loop;}
-	
+
 	if (is_semicolon(c)) {token = lexer_scan_semicolon(lexer); goto return_result;}
 	if (is_semicolon(c)) {token = lexer_scan_semicolon(lexer); goto return_result;}
 	if (is_alpha(c)) {token = lexer_scan_identifier(lexer); goto return_result;}
 	if (is_alpha(c)) {token = lexer_scan_identifier(lexer); goto return_result;}
 	if (is_digit(c, false)) {token = lexer_scan_number(lexer); goto return_result;}
 	if (is_digit(c, false)) {token = lexer_scan_number(lexer); goto return_result;}
@@ -573,9 +573,9 @@ loop:
 	if (is_builtin_operator(c)) {token = lexer_scan_operator(lexer); goto return_result;}
 	if (is_builtin_operator(c)) {token = lexer_scan_operator(lexer); goto return_result;}
 	if (is_special(c)) {token = lexer_scan_special(lexer); goto return_result;}
 	if (is_special(c)) {token = lexer_scan_special(lexer); goto return_result;}
 	if (is_preprocessor(c)) {token = lexer_scan_preprocessor(lexer); goto return_result;}
 	if (is_preprocessor(c)) {token = lexer_scan_preprocessor(lexer); goto return_result;}
-	
+
 	return lexer_error(lexer, "Unrecognized token");
 	return lexer_error(lexer, "Unrecognized token");
-	
+
 return_result:
 return_result:
 	LEXER_CALL_CALLBACK();
 	LEXER_CALL_CALLBACK();
 	return token;
 	return token;

+ 4 - 4
src/compiler/gravity_lexer.h

@@ -16,24 +16,24 @@
 /*
 /*
 	Lexer is built in such a way that no memory allocations are necessary during usage
 	Lexer is built in such a way that no memory allocations are necessary during usage
 	(except for the gravity_lexer_t opaque datatype allocated within gravity_lexer_create).
 	(except for the gravity_lexer_t opaque datatype allocated within gravity_lexer_create).
- 
+
 	Example:
 	Example:
 	gravity_lexer *lexer = gravity_lexer_create(...);
 	gravity_lexer *lexer = gravity_lexer_create(...);
 	while (gravity_lexer_next(lexer)) {
 	while (gravity_lexer_next(lexer)) {
 		// do something here
 		// do something here
 	}
 	}
 	gravity_lexer_free(lexer);
 	gravity_lexer_free(lexer);
-	
+
 	gravity_lexer_next (and gravity_lexer_peek) returns an int token (gtoken_t)
 	gravity_lexer_next (and gravity_lexer_peek) returns an int token (gtoken_t)
 	which represents what has been currently scanned. When EOF is reached TOK_EOF is
 	which represents what has been currently scanned. When EOF is reached TOK_EOF is
 	returned (with value 0) and the while loop exits.
 	returned (with value 0) and the while loop exits.
-	
+
 	In order to have token details, gravity_lexer_token must be called.
 	In order to have token details, gravity_lexer_token must be called.
 	In case of a scan error TOK_ERROR is returned and error details can be extracted
 	In case of a scan error TOK_ERROR is returned and error details can be extracted
 	from the token itself. In order to be able to not allocate any memory during
 	from the token itself. In order to be able to not allocate any memory during
 	tokenization STRINGs and NUMBERs are just sanity checked but not converted.
 	tokenization STRINGs and NUMBERs are just sanity checked but not converted.
 	It is parser responsability to perform the right conversion.
 	It is parser responsability to perform the right conversion.
- 
+
  */
  */
 
 
 // opaque datatype
 // opaque datatype

+ 61 - 61
src/compiler/gravity_optimizer.c

@@ -54,7 +54,7 @@ static void finalize_function (gravity_function_t *f) {
 	uint32_t		notpure = 0;
 	uint32_t		notpure = 0;
 	uint32_t		*bytecode = NULL;
 	uint32_t		*bytecode = NULL;
 	gravity_hash_t	*labels = gravity_hash_create(0, hash_compute, hash_isequal, NULL, NULL);
 	gravity_hash_t	*labels = gravity_hash_create(0, hash_compute, hash_isequal, NULL, NULL);
-	
+
 	// determine how big bytecode buffer must be
 	// determine how big bytecode buffer must be
 	// and collect all LABEL instructions
 	// and collect all LABEL instructions
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
@@ -68,19 +68,19 @@ static void finalize_function (gravity_function_t *f) {
 		}
 		}
 		++ninst;
 		++ninst;
 	}
 	}
-	
+
 	// +1 is just a trick so the VM switch loop terminates with an implicit RET0 instruction (RET0 has opcode 0)
 	// +1 is just a trick so the VM switch loop terminates with an implicit RET0 instruction (RET0 has opcode 0)
 	f->ninsts = ninst;
 	f->ninsts = ninst;
 	bytecode = (uint32_t *)mem_alloc((ninst+1) * sizeof(uint32_t));
 	bytecode = (uint32_t *)mem_alloc((ninst+1) * sizeof(uint32_t));
 	assert(bytecode);
 	assert(bytecode);
-	
+
 	uint32_t j=0;
 	uint32_t j=0;
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
 		inst_t *inst = ircode_get(code, i);
 		inst_t *inst = ircode_get(code, i);
 		if (IS_SKIP(inst)) continue;
 		if (IS_SKIP(inst)) continue;
 		if (IS_LABEL(inst)) continue;
 		if (IS_LABEL(inst)) continue;
 		if (IS_PRAGMA_MOVE_OPT(inst)) continue;
 		if (IS_PRAGMA_MOVE_OPT(inst)) continue;
-		
+
 		uint32_t op = 0x0;
 		uint32_t op = 0x0;
 		switch (inst->op) {
 		switch (inst->op) {
 			case HALT:
 			case HALT:
@@ -88,7 +88,7 @@ static void finalize_function (gravity_function_t *f) {
 			case NOP:
 			case NOP:
 				OPCODE_SET(op, inst->op);
 				OPCODE_SET(op, inst->op);
 				break;
 				break;
-			
+
 			case LOAD:
 			case LOAD:
 			case STORE:
 			case STORE:
 				++notpure;	// not sure here
 				++notpure;	// not sure here
@@ -122,11 +122,11 @@ static void finalize_function (gravity_function_t *f) {
 			case NOT:
 			case NOT:
 				OPCODE_SET_TWO8bit_ONE10bit(op, inst->op, inst->p1, inst->p2, inst->p3);
 				OPCODE_SET_TWO8bit_ONE10bit(op, inst->op, inst->p1, inst->p2, inst->p3);
 				break;
 				break;
-			
+
 			case LOADI:
 			case LOADI:
 				OPCODE_SET_ONE8bit_SIGN_ONE17bit(op, inst->op, inst->p1, (inst->n < 0) ? 1 : 0, inst->n);
 				OPCODE_SET_ONE8bit_SIGN_ONE17bit(op, inst->op, inst->p1, (inst->n < 0) ? 1 : 0, inst->n);
 				break;
 				break;
-				
+
 			case JUMPF: {
 			case JUMPF: {
 				gravity_value_t *v = gravity_hash_lookup(labels, VALUE_FROM_INT(inst->p2));
 				gravity_value_t *v = gravity_hash_lookup(labels, VALUE_FROM_INT(inst->p2));
 				assert(v); // key MUST exists!
 				assert(v); // key MUST exists!
@@ -136,11 +136,11 @@ static void finalize_function (gravity_function_t *f) {
 				//OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, njump);
 				//OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, njump);
 				break;
 				break;
 			}
 			}
-			
+
 			case RET:
 			case RET:
 				OPCODE_SET_ONE8bit(op, inst->op, inst->p1);
 				OPCODE_SET_ONE8bit(op, inst->op, inst->p1);
 				break;
 				break;
-				
+
 			case JUMP: {
 			case JUMP: {
 				gravity_value_t *v = gravity_hash_lookup(labels, VALUE_FROM_INT(inst->p1));
 				gravity_value_t *v = gravity_hash_lookup(labels, VALUE_FROM_INT(inst->p1));
 				assert(v); // key MUST exists!
 				assert(v); // key MUST exists!
@@ -148,7 +148,7 @@ static void finalize_function (gravity_function_t *f) {
 				OPCODE_SET_ONE26bit(op, inst->op, njump);
 				OPCODE_SET_ONE26bit(op, inst->op, njump);
 				break;
 				break;
 			}
 			}
-			
+
 			case LOADG:
 			case LOADG:
 			case STOREG:
 			case STOREG:
 				++notpure;
 				++notpure;
@@ -156,21 +156,21 @@ static void finalize_function (gravity_function_t *f) {
 			case LOADK:
 			case LOADK:
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				break;
 				break;
-				
+
 			case CALL:
 			case CALL:
 				OPCODE_SET_TWO8bit_ONE10bit(op, inst->op, inst->p1, inst->p2, inst->p3);
 				OPCODE_SET_TWO8bit_ONE10bit(op, inst->op, inst->p1, inst->p2, inst->p3);
 				break;
 				break;
-			
+
 			case SETLIST:
 			case SETLIST:
 				OPCODE_SET_TWO8bit_ONE10bit(op, inst->op, inst->p1, inst->p2, inst->p3);
 				OPCODE_SET_TWO8bit_ONE10bit(op, inst->op, inst->p1, inst->p2, inst->p3);
 				break;
 				break;
-				
+
 			case LOADU:
 			case LOADU:
 			case STOREU:
 			case STOREU:
 				++notpure;
 				++notpure;
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				break;
 				break;
-			
+
 			case RANGENEW: {
 			case RANGENEW: {
 				uint8_t flag = (inst->tag == RANGE_INCLUDE_TAG) ? 0 : 1;
 				uint8_t flag = (inst->tag == RANGE_INCLUDE_TAG) ? 0 : 1;
 				OPCODE_SET_THREE8bit_ONE2bit(op, inst->op, inst->p1, inst->p2, inst->p3, flag);
 				OPCODE_SET_THREE8bit_ONE2bit(op, inst->op, inst->p1, inst->p2, inst->p3, flag);
@@ -180,16 +180,16 @@ static void finalize_function (gravity_function_t *f) {
 			case LISTNEW:
 			case LISTNEW:
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				break;
 				break;
-				
+
 			case SWITCH:
 			case SWITCH:
 				assert(0);
 				assert(0);
 				break;
 				break;
-				
+
 			case CLOSURE:
 			case CLOSURE:
 			case CLOSE:
 			case CLOSE:
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				OPCODE_SET_ONE8bit_ONE18bit(op, inst->op, inst->p1, inst->p2);
 				break;
 				break;
-				
+
 			case RESERVED1:
 			case RESERVED1:
 			case RESERVED2:
 			case RESERVED2:
 			case RESERVED3:
 			case RESERVED3:
@@ -199,14 +199,14 @@ static void finalize_function (gravity_function_t *f) {
 				assert(0);
 				assert(0);
 				break;
 				break;
 		}
 		}
-		
+
 		// store encoded instruction
 		// store encoded instruction
 		bytecode[j++] = op;
 		bytecode[j++] = op;
 	}
 	}
-	
+
 	ircode_free(code);
 	ircode_free(code);
 	gravity_hash_free(labels);
 	gravity_hash_free(labels);
-	
+
 	f->bytecode = bytecode;
 	f->bytecode = bytecode;
 	f->purity = (notpure == 0) ? 1.0f : ((float)(notpure * 100) / (float)ninst) / 100.0f;
 	f->purity = (notpure == 0) ? 1.0f : ((float)(notpure * 100) / (float)ninst) / 100.0f;
 }
 }
@@ -215,7 +215,7 @@ static void finalize_function (gravity_function_t *f) {
 
 
 inline static bool pop1_instruction (ircode_t *code, uint32_t index, inst_t **inst1) {
 inline static bool pop1_instruction (ircode_t *code, uint32_t index, inst_t **inst1) {
 	*inst1 = NULL;
 	*inst1 = NULL;
-	
+
 	for (int32_t i=index-1; i>=0; --i) {
 	for (int32_t i=index-1; i>=0; --i) {
 		inst_t *inst = ircode_get(code, i);
 		inst_t *inst = ircode_get(code, i);
 		if ((inst != NULL) && (inst->tag != SKIP_TAG)) {
 		if ((inst != NULL) && (inst->tag != SKIP_TAG)) {
@@ -223,14 +223,14 @@ inline static bool pop1_instruction (ircode_t *code, uint32_t index, inst_t **in
 			return true;
 			return true;
 		}
 		}
 	}
 	}
-	
+
 	return false;
 	return false;
 }
 }
 
 
 inline static bool pop2_instructions (ircode_t *code, uint32_t index, inst_t **inst1, inst_t **inst2) {
 inline static bool pop2_instructions (ircode_t *code, uint32_t index, inst_t **inst1, inst_t **inst2) {
 	*inst1 = NULL;
 	*inst1 = NULL;
 	*inst2 = NULL;
 	*inst2 = NULL;
-	
+
 	for (int32_t i=index-1; i>=0; --i) {
 	for (int32_t i=index-1; i>=0; --i) {
 		inst_t *inst = ircode_get(code, i);
 		inst_t *inst = ircode_get(code, i);
 		if ((inst != NULL) && (inst->tag != SKIP_TAG)) {
 		if ((inst != NULL) && (inst->tag != SKIP_TAG)) {
@@ -241,7 +241,7 @@ inline static bool pop2_instructions (ircode_t *code, uint32_t index, inst_t **i
 			}
 			}
 		}
 		}
 	}
 	}
-	
+
 	return false;
 	return false;
 }
 }
 
 
@@ -252,7 +252,7 @@ inline static inst_t *current_instruction (ircode_t *code, uint32_t i) {
 		if (inst->tag != SKIP_TAG) return inst;
 		if (inst->tag != SKIP_TAG) return inst;
 		++i;
 		++i;
 	}
 	}
-	
+
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -266,11 +266,11 @@ static bool optimize_const_instruction (inst_t *inst, inst_t *inst1, inst_t *ins
 	optag_t	type;
 	optag_t	type;
 	double	d = 0.0, d1 = 0.0, d2 = 0.0;
 	double	d = 0.0, d1 = 0.0, d2 = 0.0;
 	int64_t	n = 0, n1 = 0, n2 = 0;
 	int64_t	n = 0, n1 = 0, n2 = 0;
-	
+
 	// compute types
 	// compute types
 	if (inst1->tag == inst2->tag) type = inst1->tag;
 	if (inst1->tag == inst2->tag) type = inst1->tag;
 	else type = DOUBLE_TAG;
 	else type = DOUBLE_TAG;
-	
+
 	// compute operands
 	// compute operands
 	if (type == DOUBLE_TAG) {
 	if (type == DOUBLE_TAG) {
 		d1 = (inst1->tag == INT_TAG) ? (double)inst1->n : inst1->d;
 		d1 = (inst1->tag == INT_TAG) ? (double)inst1->n : inst1->d;
@@ -279,45 +279,45 @@ static bool optimize_const_instruction (inst_t *inst, inst_t *inst1, inst_t *ins
 		n1 = (inst1->tag == INT_TAG) ? inst1->n : (int64_t)inst1->d;
 		n1 = (inst1->tag == INT_TAG) ? inst1->n : (int64_t)inst1->d;
 		n2 = (inst2->tag == INT_TAG) ? inst2->n : (int64_t)inst2->d;
 		n2 = (inst2->tag == INT_TAG) ? inst2->n : (int64_t)inst2->d;
 	}
 	}
-	
+
 	// perform operation
 	// perform operation
 	switch (inst->op) {
 	switch (inst->op) {
 		case ADD:
 		case ADD:
 			if (type == DOUBLE_TAG) d = d1 + d2;
 			if (type == DOUBLE_TAG) d = d1 + d2;
 			else n = n1 + n2;
 			else n = n1 + n2;
 			break;
 			break;
-			
+
 		case SUB:
 		case SUB:
 			if (type == DOUBLE_TAG) d = d1 - d2;
 			if (type == DOUBLE_TAG) d = d1 - d2;
 			else n = n1 - n2;
 			else n = n1 - n2;
 			break;
 			break;
-			
+
 		case MUL:
 		case MUL:
 			if (type == DOUBLE_TAG) d = d1 * d2;
 			if (type == DOUBLE_TAG) d = d1 * d2;
 			else n = n1 * n2;
 			else n = n1 * n2;
 			break;
 			break;
-			
+
 		case DIV:
 		case DIV:
 			// don't optimize in case of division by 0
 			// don't optimize in case of division by 0
 			if ((int64_t)d2 == 0) return false;
 			if ((int64_t)d2 == 0) return false;
 			if (type == DOUBLE_TAG) d = d1 / d2;
 			if (type == DOUBLE_TAG) d = d1 / d2;
 			else n = n1 / n2;
 			else n = n1 / n2;
 			break;
 			break;
-			
+
 		case REM:
 		case REM:
 			if ((int64_t)d2 == 0) return false;
 			if ((int64_t)d2 == 0) return false;
 			if (type == DOUBLE_TAG) d = (double)((int64_t)d1 % (int64_t)d2);
 			if (type == DOUBLE_TAG) d = (double)((int64_t)d1 % (int64_t)d2);
 			else n = n1 % n2;
 			else n = n1 % n2;
 			break;
 			break;
-			
+
 		default:
 		default:
 			assert(0);
 			assert(0);
 	}
 	}
-	
+
 	// adjust IRCODE
 	// adjust IRCODE
 	inst_setskip(inst1);
 	inst_setskip(inst1);
 	inst_setskip(inst2);
 	inst_setskip(inst2);
-	
+
 	// convert an ADD instruction to a LOADI instruction
 	// convert an ADD instruction to a LOADI instruction
 	// ADD A B C	=> R(A) = R(B) + R(C)
 	// ADD A B C	=> R(A) = R(B) + R(C)
 	// LOADI A B	=> R(A) = N
 	// LOADI A B	=> R(A) = N
@@ -326,7 +326,7 @@ static bool optimize_const_instruction (inst_t *inst, inst_t *inst1, inst_t *ins
 	inst->p2 = inst->p3 = 0;
 	inst->p2 = inst->p3 = 0;
 	if (type == DOUBLE_TAG) inst->d = d;
 	if (type == DOUBLE_TAG) inst->d = d;
 	else inst->n = n;
 	else inst->n = n;
-	
+
 	return true;
 	return true;
 }
 }
 
 
@@ -337,7 +337,7 @@ static bool optimize_neg_instruction (ircode_t *code, inst_t *inst, uint32_t i)
 	if (inst1->op != LOADI) return false;
 	if (inst1->op != LOADI) return false;
 	if (inst1->p1 != inst->p2) return false;
 	if (inst1->p1 != inst->p2) return false;
 	if (!ircode_register_istemp(code, inst1->p1)) return false;
 	if (!ircode_register_istemp(code, inst1->p1)) return false;
-	
+
 	uint64_t n = inst1->n;
 	uint64_t n = inst1->n;
 	if (n>131072) return false;
 	if (n>131072) return false;
 	inst1->p1 = inst->p2;
 	inst1->p1 = inst->p2;
@@ -350,11 +350,11 @@ static bool optimize_math_instruction (ircode_t *code, inst_t *inst, uint32_t i)
 	uint8_t count = opcode_numop(inst->op) - 1;
 	uint8_t count = opcode_numop(inst->op) - 1;
 	inst_t *inst1 = NULL, *inst2 = NULL;
 	inst_t *inst1 = NULL, *inst2 = NULL;
 	bool	flag = false;
 	bool	flag = false;
-	
+
 	if (count == 2) {
 	if (count == 2) {
 		pop2_instructions(code, i, &inst2, &inst1);
 		pop2_instructions(code, i, &inst2, &inst1);
 		if (IS_NUM(inst1) && IS_NUM(inst2)) flag = optimize_const_instruction(inst, inst1, inst2);
 		if (IS_NUM(inst1) && IS_NUM(inst2)) flag = optimize_const_instruction(inst, inst1, inst2);
-		
+
 		// process inst2
 		// process inst2
 		if (IS_MOVE(inst2)) {
 		if (IS_MOVE(inst2)) {
 			bool b1 = ircode_register_istemp(code, inst->p3);
 			bool b1 = ircode_register_istemp(code, inst->p3);
@@ -365,7 +365,7 @@ static bool optimize_math_instruction (ircode_t *code, inst_t *inst, uint32_t i)
 				flag = true;
 				flag = true;
 			}
 			}
 		}
 		}
-		
+
 		// process inst1
 		// process inst1
 		if (IS_MOVE(inst1)) {
 		if (IS_MOVE(inst1)) {
 			bool b1 = ircode_register_istemp(code, inst->p2);
 			bool b1 = ircode_register_istemp(code, inst->p2);
@@ -376,7 +376,7 @@ static bool optimize_math_instruction (ircode_t *code, inst_t *inst, uint32_t i)
 				flag = true;
 				flag = true;
 			}
 			}
 		}
 		}
-		
+
 	}
 	}
 	else {
 	else {
 		pop1_instruction(code, i, &inst1);
 		pop1_instruction(code, i, &inst1);
@@ -391,38 +391,38 @@ static bool optimize_move_instruction (ircode_t *code, inst_t *inst, uint32_t i)
 	pop1_instruction(code, i, &inst1);
 	pop1_instruction(code, i, &inst1);
 	if (inst1 == NULL) return false;
 	if (inst1 == NULL) return false;
 	if ((inst1->op != LOADI) && (inst1->op != LOADG) && (inst1->op != LOADK)) return false;
 	if ((inst1->op != LOADI) && (inst1->op != LOADG) && (inst1->op != LOADK)) return false;
-	
+
 	bool b1 = ircode_register_istemp(code, inst->p2);
 	bool b1 = ircode_register_istemp(code, inst->p2);
 	bool b2 = ((inst1) && ircode_register_istemp(code, inst1->p1));
 	bool b2 = ((inst1) && ircode_register_istemp(code, inst1->p1));
-	
+
 	if ((b1) && (b2) && (inst->p2 == inst1->p1)) {
 	if ((b1) && (b2) && (inst->p2 == inst1->p1)) {
 		inst1->p1 = inst->p1;
 		inst1->p1 = inst->p1;
 		inst_setskip(inst);
 		inst_setskip(inst);
 		return true;
 		return true;
 	}
 	}
-	
+
 	return false;
 	return false;
 }
 }
 
 
 static bool optimize_return_instruction (ircode_t *code, inst_t *inst, uint32_t i) {
 static bool optimize_return_instruction (ircode_t *code, inst_t *inst, uint32_t i) {
 	inst_t *inst1 = NULL;
 	inst_t *inst1 = NULL;
 	pop1_instruction(code, i, &inst1);
 	pop1_instruction(code, i, &inst1);
-	
+
 	if (!ircode_register_istemp(code, inst->p1)) return false;
 	if (!ircode_register_istemp(code, inst->p1)) return false;
 	if ((IS_MOVE(inst1)) && (inst->p1 == inst1->p1)) {
 	if ((IS_MOVE(inst1)) && (inst->p1 == inst1->p1)) {
 		inst->p1 = inst1->p2;
 		inst->p1 = inst1->p2;
 		inst_setskip(inst1);
 		inst_setskip(inst1);
 		return true;
 		return true;
 	}
 	}
-	
+
 	return false;
 	return false;
 }
 }
 
 
 static bool optimize_num_instruction (inst_t *inst, gravity_function_t *f) {
 static bool optimize_num_instruction (inst_t *inst, gravity_function_t *f) {
-	
+
 	// double values always added to constant pool
 	// double values always added to constant pool
 	bool add_cpool = (inst->tag == DOUBLE_TAG);
 	bool add_cpool = (inst->tag == DOUBLE_TAG);
-	
+
 	// LOADI is a 32bit instruction
 	// LOADI is a 32bit instruction
 	// 32 - 6 (OPCODE) - 8 (register) - 1 bit sign = 17
 	// 32 - 6 (OPCODE) - 8 (register) - 1 bit sign = 17
 	// range is from MAX_INLINE_INT-1 to MAX_INLINE_INT
 	// range is from MAX_INLINE_INT-1 to MAX_INLINE_INT
@@ -432,7 +432,7 @@ static bool optimize_num_instruction (inst_t *inst, gravity_function_t *f) {
 		int64_t n = inst->n;
 		int64_t n = inst->n;
 		add_cpool = ((n < -MAX_INLINE_INT + 1) || (n > MAX_INLINE_INT));
 		add_cpool = ((n < -MAX_INLINE_INT + 1) || (n > MAX_INLINE_INT));
 	}
 	}
-	
+
 	if (add_cpool) {
 	if (add_cpool) {
 		uint16_t index = 0;
 		uint16_t index = 0;
 		if (inst->tag == INT_TAG) {
 		if (inst->tag == INT_TAG) {
@@ -442,13 +442,13 @@ static bool optimize_num_instruction (inst_t *inst, gravity_function_t *f) {
 			// always add floating point values as double in constant pool (then VM will be configured to interpret it as float or double)
 			// always add floating point values as double in constant pool (then VM will be configured to interpret it as float or double)
 			index = gravity_function_cpool_add(NULL, f, VALUE_FROM_FLOAT(inst->d));
 			index = gravity_function_cpool_add(NULL, f, VALUE_FROM_FLOAT(inst->d));
 		}
 		}
-		
+
 		// replace LOADI with a LOADK instruction
 		// replace LOADI with a LOADK instruction
 		inst->op = LOADK;
 		inst->op = LOADK;
 		inst->p2 = index;
 		inst->p2 = index;
 		inst->tag = NO_TAG;
 		inst->tag = NO_TAG;
 	}
 	}
-	
+
 	return true;
 	return true;
 }
 }
 
 
@@ -456,13 +456,13 @@ static bool optimize_num_instruction (inst_t *inst, gravity_function_t *f) {
 
 
 gravity_function_t *gravity_optimizer(gravity_function_t *f) {
 gravity_function_t *gravity_optimizer(gravity_function_t *f) {
 	if (f->bytecode == NULL) return f;
 	if (f->bytecode == NULL) return f;
-	
+
 	ircode_t	*code = (ircode_t *)f->bytecode;
 	ircode_t	*code = (ircode_t *)f->bytecode;
 	uint32_t	count = ircode_count(code);
 	uint32_t	count = ircode_count(code);
 	bool		optimizer = true;
 	bool		optimizer = true;
-	
+
 	f->ntemps = ircode_ntemps(code);
 	f->ntemps = ircode_ntemps(code);
-	
+
 	loop_neg:
 	loop_neg:
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
 		inst_t *inst = current_instruction(code, i);
 		inst_t *inst = current_instruction(code, i);
@@ -471,7 +471,7 @@ gravity_function_t *gravity_optimizer(gravity_function_t *f) {
 			if (b) goto loop_neg;
 			if (b) goto loop_neg;
 		}
 		}
 	}
 	}
-	
+
 	loop_math:
 	loop_math:
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
 		inst_t *inst = current_instruction(code, i);
 		inst_t *inst = current_instruction(code, i);
@@ -480,7 +480,7 @@ gravity_function_t *gravity_optimizer(gravity_function_t *f) {
 			if (b) goto loop_math;
 			if (b) goto loop_math;
 		}
 		}
 	}
 	}
-	
+
 	loop_move:
 	loop_move:
 	optimizer = true;
 	optimizer = true;
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
@@ -491,7 +491,7 @@ gravity_function_t *gravity_optimizer(gravity_function_t *f) {
 			if (b) goto loop_move;
 			if (b) goto loop_move;
 		}
 		}
 	}
 	}
-	
+
 	loop_ret:
 	loop_ret:
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
 		inst_t *inst = current_instruction(code, i);
 		inst_t *inst = current_instruction(code, i);
@@ -500,19 +500,19 @@ gravity_function_t *gravity_optimizer(gravity_function_t *f) {
 			if (b) goto loop_ret;
 			if (b) goto loop_ret;
 		}
 		}
 	}
 	}
-	
+
 	for (uint32_t i=0; i<count; ++i) {
 	for (uint32_t i=0; i<count; ++i) {
 		inst_t *inst = current_instruction(code, i);
 		inst_t *inst = current_instruction(code, i);
 		if (IS_NUM(inst)) optimize_num_instruction (inst, f);
 		if (IS_NUM(inst)) optimize_num_instruction (inst, f);
 	}
 	}
-	
+
 	// dump optimized version
 	// dump optimized version
 	#if GRAVITY_BYTECODE_DEBUG
 	#if GRAVITY_BYTECODE_DEBUG
 	gravity_function_dump(f, ircode_dump);
 	gravity_function_dump(f, ircode_dump);
 	#endif
 	#endif
-	
+
 	// finalize function
 	// finalize function
 	finalize_function(f);
 	finalize_function(f);
-	
+
 	return f;
 	return f;
 }
 }

File diff suppressed because it is too large
+ 160 - 160
src/compiler/gravity_parser.c


+ 4 - 4
src/compiler/gravity_parser.h

@@ -16,16 +16,16 @@
 /*
 /*
 	Parser is responsible to build the AST, convert strings and number from tokens and
 	Parser is responsible to build the AST, convert strings and number from tokens and
 	implement syntax error recovery strategy.
 	implement syntax error recovery strategy.
-	
+
 	Notes about error recovery:
 	Notes about error recovery:
 	Each parse* function can return NULL in case of error but each function is RESPONSIBLE
 	Each parse* function can return NULL in case of error but each function is RESPONSIBLE
-	to make appropriate actions in order to handle/recover errors. 
-	
+	to make appropriate actions in order to handle/recover errors.
+
 	Error recovery techniques can be:
 	Error recovery techniques can be:
 	Shallow Error Recovery
 	Shallow Error Recovery
 	Deep Error Recovery
 	Deep Error Recovery
 	https://javacc.java.net/doc/errorrecovery.html
 	https://javacc.java.net/doc/errorrecovery.html
- 
+
  */
  */
 
 
 // opaque datatype
 // opaque datatype

+ 24 - 24
src/compiler/gravity_semacheck1.c

@@ -32,11 +32,11 @@ static int ident =0;
 static void report_error (gvisitor_t *self, gnode_t *node, const char *format, ...) {
 static void report_error (gvisitor_t *self, gnode_t *node, const char *format, ...) {
 	// increment internal error counter
 	// increment internal error counter
 	++self->nerr;
 	++self->nerr;
-	
+
 	// get error callback (if any)
 	// get error callback (if any)
 	void *data = (self->delegate) ? ((gravity_delegate_t *)self->delegate)->xdata : NULL;
 	void *data = (self->delegate) ? ((gravity_delegate_t *)self->delegate)->xdata : NULL;
 	gravity_error_callback error_fn = (self->delegate) ? ((gravity_delegate_t *)self->delegate)->error_callback : NULL;
 	gravity_error_callback error_fn = (self->delegate) ? ((gravity_delegate_t *)self->delegate)->error_callback : NULL;
-	
+
 	// build error message
 	// build error message
 	char		buffer[1024];
 	char		buffer[1024];
 	va_list		arg;
 	va_list		arg;
@@ -45,7 +45,7 @@ static void report_error (gvisitor_t *self, gnode_t *node, const char *format, .
 		vsnprintf(buffer, sizeof(buffer), format, arg);
 		vsnprintf(buffer, sizeof(buffer), format, arg);
 		va_end (arg);
 		va_end (arg);
 	}
 	}
-	
+
 	// setup error struct
 	// setup error struct
 	error_desc_t error_desc = {
 	error_desc_t error_desc = {
 		.lineno = node->token.lineno,
 		.lineno = node->token.lineno,
@@ -54,7 +54,7 @@ static void report_error (gvisitor_t *self, gnode_t *node, const char *format, .
 		.offset = node->token.position,
 		.offset = node->token.position,
         .meta = meta_from_node(node)
         .meta = meta_from_node(node)
 	};
 	};
-	
+
 	// finally call error callback
 	// finally call error callback
 	if (error_fn) error_fn(GRAVITY_ERROR_SEMANTIC, buffer, error_desc, data);
 	if (error_fn) error_fn(GRAVITY_ERROR_SEMANTIC, buffer, error_desc, data);
 	else printf("%s\n", buffer);
 	else printf("%s\n", buffer);
@@ -64,27 +64,27 @@ static void report_error (gvisitor_t *self, gnode_t *node, const char *format, .
 
 
 static void visit_list_stmt (gvisitor_t *self, gnode_compound_stmt_t *node) {
 static void visit_list_stmt (gvisitor_t *self, gnode_compound_stmt_t *node) {
 	DECLARE_SYMTABLE;
 	DECLARE_SYMTABLE;
-	
+
 	node->symtable = symtable;	// GLOBALS
 	node->symtable = symtable;	// GLOBALS
 	gnode_array_each(node->stmts, {visit(val);});
 	gnode_array_each(node->stmts, {visit(val);});
 }
 }
 
 
 static void visit_function_decl (gvisitor_t *self, gnode_function_decl_t *node) {
 static void visit_function_decl (gvisitor_t *self, gnode_function_decl_t *node) {
 	DECLARE_SYMTABLE;
 	DECLARE_SYMTABLE;
-	
+
 	DEBUG_SYMTABLE("function: %s", node->identifier);
 	DEBUG_SYMTABLE("function: %s", node->identifier);
-	
+
 	// function identifier
 	// function identifier
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
-	
+
 	// we are just interested in non-local declarations so don't further scan function node
 	// we are just interested in non-local declarations so don't further scan function node
 	// node->symtable is NULL here and it will be created in semacheck2
 	// node->symtable is NULL here and it will be created in semacheck2
 }
 }
 
 
 static void visit_variable_decl (gvisitor_t *self, gnode_variable_decl_t *node) {
 static void visit_variable_decl (gvisitor_t *self, gnode_variable_decl_t *node) {
 	DECLARE_SYMTABLE;
 	DECLARE_SYMTABLE;
-	
+
 	gnode_array_each(node->decls, {
 	gnode_array_each(node->decls, {
 		gnode_var_t *p = (gnode_var_t *)val;
 		gnode_var_t *p = (gnode_var_t *)val;
 		DEBUG_SYMTABLE("variable: %s", p->identifier);
 		DEBUG_SYMTABLE("variable: %s", p->identifier);
@@ -95,9 +95,9 @@ static void visit_variable_decl (gvisitor_t *self, gnode_variable_decl_t *node)
 
 
 static void visit_enum_decl (gvisitor_t *self, gnode_enum_decl_t *node) {
 static void visit_enum_decl (gvisitor_t *self, gnode_enum_decl_t *node) {
 	DECLARE_SYMTABLE;
 	DECLARE_SYMTABLE;
-	
+
 	DEBUG_SYMTABLE("enum: %s", node->identifier);
 	DEBUG_SYMTABLE("enum: %s", node->identifier);
-	
+
 	// check enum identifier uniqueness in current symbol table
 	// check enum identifier uniqueness in current symbol table
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
@@ -105,13 +105,13 @@ static void visit_enum_decl (gvisitor_t *self, gnode_enum_decl_t *node) {
 
 
 static void visit_class_decl (gvisitor_t *self, gnode_class_decl_t *node) {
 static void visit_class_decl (gvisitor_t *self, gnode_class_decl_t *node) {
 	DECLARE_SYMTABLE;
 	DECLARE_SYMTABLE;
-	
+
 	DEBUG_SYMTABLE("class: %s", node->identifier);
 	DEBUG_SYMTABLE("class: %s", node->identifier);
-	
+
 	// class identifier
 	// class identifier
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
-	
+
 	CREATE_SYMTABLE;
 	CREATE_SYMTABLE;
 	gnode_array_each(node->decls, {
 	gnode_array_each(node->decls, {
 		visit(val);
 		visit(val);
@@ -121,13 +121,13 @@ static void visit_class_decl (gvisitor_t *self, gnode_class_decl_t *node) {
 
 
 static void visit_module_decl (gvisitor_t *self, gnode_module_decl_t *node) {
 static void visit_module_decl (gvisitor_t *self, gnode_module_decl_t *node) {
 	DECLARE_SYMTABLE;
 	DECLARE_SYMTABLE;
-	
+
 	DEBUG_SYMTABLE("module: %s", node->identifier);
 	DEBUG_SYMTABLE("module: %s", node->identifier);
-	
+
 	// module identifier
 	// module identifier
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 	if (!symboltable_insert(symtable, node->identifier, (void *)node))
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
 		REPORT_ERROR(node, "Identifier %s redeclared.", node->identifier);
-	
+
 	CREATE_SYMTABLE;
 	CREATE_SYMTABLE;
 	gnode_array_each(node->decls, {
 	gnode_array_each(node->decls, {
 		visit(val);
 		visit(val);
@@ -139,16 +139,16 @@ static void visit_module_decl (gvisitor_t *self, gnode_module_decl_t *node) {
 
 
 bool gravity_semacheck1 (gnode_t *node, gravity_delegate_t *delegate) {
 bool gravity_semacheck1 (gnode_t *node, gravity_delegate_t *delegate) {
 	symboltable_t *context = symboltable_create(false);
 	symboltable_t *context = symboltable_create(false);
-	
+
 	gvisitor_t visitor = {
 	gvisitor_t visitor = {
 		.nerr = 0,							// used to store number of found errors
 		.nerr = 0,							// used to store number of found errors
 		.data = (void *)context,			// used to store a pointer to the symbol table
 		.data = (void *)context,			// used to store a pointer to the symbol table
 		.delegate = (void *)delegate,		// compiler delegate to report errors
 		.delegate = (void *)delegate,		// compiler delegate to report errors
-		
+
         // COMMON
         // COMMON
         .visit_pre = NULL,
         .visit_pre = NULL,
         .visit_post = NULL,
         .visit_post = NULL,
-        
+
 		// STATEMENTS: 7
 		// STATEMENTS: 7
 		.visit_list_stmt = visit_list_stmt,
 		.visit_list_stmt = visit_list_stmt,
 		.visit_compound_stmt = NULL,
 		.visit_compound_stmt = NULL,
@@ -157,14 +157,14 @@ bool gravity_semacheck1 (gnode_t *node, gravity_delegate_t *delegate) {
 		.visit_loop_stmt = NULL,
 		.visit_loop_stmt = NULL,
 		.visit_jump_stmt = NULL,
 		.visit_jump_stmt = NULL,
 		.visit_empty_stmt = NULL,
 		.visit_empty_stmt = NULL,
-		
+
 		// DECLARATIONS: 5
 		// DECLARATIONS: 5
 		.visit_function_decl = visit_function_decl,
 		.visit_function_decl = visit_function_decl,
 		.visit_variable_decl = visit_variable_decl,
 		.visit_variable_decl = visit_variable_decl,
 		.visit_enum_decl = visit_enum_decl,
 		.visit_enum_decl = visit_enum_decl,
 		.visit_class_decl = visit_class_decl,
 		.visit_class_decl = visit_class_decl,
 		.visit_module_decl = visit_module_decl,
 		.visit_module_decl = visit_module_decl,
-		
+
 		// EXPRESSIONS: 8
 		// EXPRESSIONS: 8
 		.visit_binary_expr = NULL,
 		.visit_binary_expr = NULL,
 		.visit_unary_expr = NULL,
 		.visit_unary_expr = NULL,
@@ -175,10 +175,10 @@ bool gravity_semacheck1 (gnode_t *node, gravity_delegate_t *delegate) {
 		.visit_list_expr = NULL,
 		.visit_list_expr = NULL,
 		.visit_postfix_expr = NULL,
 		.visit_postfix_expr = NULL,
 	};
 	};
-	
+
 	DEBUG_SYMTABLE("=== SYMBOL TABLE ===");
 	DEBUG_SYMTABLE("=== SYMBOL TABLE ===");
 	gvisit(&visitor, node);
 	gvisit(&visitor, node);
 	DEBUG_SYMTABLE("====================\n");
 	DEBUG_SYMTABLE("====================\n");
-	
+
 	return (visitor.nerr == 0);
 	return (visitor.nerr == 0);
 }
 }

+ 8 - 8
src/compiler/gravity_semacheck1.h

@@ -23,30 +23,30 @@
 		function foo() {
 		function foo() {
 			return bar();
 			return bar();
 		}
 		}
-	
+
 		function bar() {
 		function bar() {
 			...
 			...
 		}
 		}
- 
+
 		or
 		or
- 
+
 		class foo:bar {
 		class foo:bar {
 			...
 			...
 		}
 		}
- 
+
 		class bar {
 		class bar {
 			...
 			...
 		}
 		}
- 
+
 		and
 		and
- 
+
 		class foo {
 		class foo {
 			var a;
 			var a;
- 
+
 			function bar() {
 			function bar() {
 				return a + b;
 				return a + b;
 			}
 			}
- 
+
 			var b;
 			var b;
 		}
 		}
  */
  */

File diff suppressed because it is too large
+ 158 - 158
src/compiler/gravity_semacheck2.c


+ 9 - 9
src/compiler/gravity_semacheck2.h

@@ -13,14 +13,14 @@
 #include "gravity_delegate.h"
 #include "gravity_delegate.h"
 
 
 // Responsible to gather and check local identifiers
 // Responsible to gather and check local identifiers
-// Complete check for all identifiers and report not found errors 
+// Complete check for all identifiers and report not found errors
 
 
 bool gravity_semacheck2(gnode_t *node, gravity_delegate_t *delegate);
 bool gravity_semacheck2(gnode_t *node, gravity_delegate_t *delegate);
 
 
 /*
 /*
- 
+
 	The following table summarizes what can be defined inside a declaration:
 	The following table summarizes what can be defined inside a declaration:
- 
+
     -------+---------------------------------------------------------+
     -------+---------------------------------------------------------+
 	       |   func   |   var   |   enum   |   class   |   module    |
 	       |   func   |   var   |   enum   |   class   |   module    |
 	-------+---------------------------------------------------------+
 	-------+---------------------------------------------------------+
@@ -34,29 +34,29 @@ bool gravity_semacheck2(gnode_t *node, gravity_delegate_t *delegate);
     -------+---------------------------------------------------------+
     -------+---------------------------------------------------------+
 	module |   NO     |   NO    |   NO     |   NO      |   NO        |
 	module |   NO     |   NO    |   NO     |   NO      |   NO        |
     -------+---------------------------------------------------------+
     -------+---------------------------------------------------------+
- 
+
 	Everything declared inside a func is a local, so for example:
 	Everything declared inside a func is a local, so for example:
- 
+
 	func foo {
 	func foo {
 		func a...;
 		func a...;
 		enum b...;
 		enum b...;
 		class c..;
 		class c..;
 	}
 	}
- 
+
 	is converted by codegen to:
 	is converted by codegen to:
-	
+
 	func foo {
 	func foo {
 		var a = func...;
 		var a = func...;
 		var b = enum...;
 		var b = enum...;
 		var c = class..;
 		var c = class..;
 	}
 	}
- 
+
 	Even if the ONLY valid syntax is anonymous func assignment, user will not be able
 	Even if the ONLY valid syntax is anonymous func assignment, user will not be able
 	to assign an anonymous enum or class to a variable. Restriction is applied by parser
 	to assign an anonymous enum or class to a variable. Restriction is applied by parser
 	and reported as a syntax error.
 	and reported as a syntax error.
 	Define a module inside a function is not allowed (no real technical reason but I found
 	Define a module inside a function is not allowed (no real technical reason but I found
 	it a very bad programming practice), restriction is applied by samantic checker.
 	it a very bad programming practice), restriction is applied by samantic checker.
- 
+
  */
  */
 
 
 
 

+ 14 - 14
src/compiler/gravity_symboltable.c

@@ -35,7 +35,7 @@ struct symboltable_t {
 
 
 static void check_upvalue_inscope (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value, void *data) {
 static void check_upvalue_inscope (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value, void *data) {
 	#pragma unused(hashtable, key)
 	#pragma unused(hashtable, key)
-	
+
 	uint32_t index = *(uint32_t *)data;
 	uint32_t index = *(uint32_t *)data;
 	gnode_t *node = VALUE_AS_NODE(value);
 	gnode_t *node = VALUE_AS_NODE(value);
 	if (NODE_ISA(node, NODE_VARIABLE)) {
 	if (NODE_ISA(node, NODE_VARIABLE)) {
@@ -45,7 +45,7 @@ static void check_upvalue_inscope (gravity_hash_t *hashtable, gravity_value_t ke
 		}
 		}
 	}
 	}
 }
 }
-	
+
 // MARK: -
 // MARK: -
 
 
 static void symboltable_hash_free (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value, void *data) {
 static void symboltable_hash_free (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value, void *data) {
@@ -67,38 +67,38 @@ symboltable_t *symboltable_create (bool is_enum) {
 	gravity_hash_t	*hash = gravity_hash_create(0, gravity_value_hash, gravity_value_equals,
 	gravity_hash_t	*hash = gravity_hash_create(0, gravity_value_hash, gravity_value_equals,
 												(is_enum) ? symboltable_keyvalue_free : symboltable_hash_free, NULL);
 												(is_enum) ? symboltable_keyvalue_free : symboltable_hash_free, NULL);
 	if (!table) return NULL;
 	if (!table) return NULL;
-	
+
 	// init symbol table
 	// init symbol table
 	table->counter = 0;
 	table->counter = 0;
 	table->stack = mem_alloc(sizeof(ghash_r));
 	table->stack = mem_alloc(sizeof(ghash_r));
 	scope_stack_init(table->stack);
 	scope_stack_init(table->stack);
 	scope_stack_push(table->stack, hash);
 	scope_stack_push(table->stack, hash);
-	
+
 	return table;
 	return table;
 }
 }
 
 
 void symboltable_free (symboltable_t *table) {
 void symboltable_free (symboltable_t *table) {
 	size_t i, n = scope_stack_size(table->stack);
 	size_t i, n = scope_stack_size(table->stack);
-	
+
 	for (i=0; i<n; ++i) {
 	for (i=0; i<n; ++i) {
 		gravity_hash_t *h = scope_stack_get(table->stack, i);
 		gravity_hash_t *h = scope_stack_get(table->stack, i);
 		gravity_hash_free(h);
 		gravity_hash_free(h);
 	}
 	}
-	
+
 	if (table->stack) {
 	if (table->stack) {
 		scope_stack_free(table->stack);
 		scope_stack_free(table->stack);
 		mem_free(table->stack);
 		mem_free(table->stack);
 	}
 	}
-	
+
 	mem_free(table);
 	mem_free(table);
 }
 }
 
 
 bool symboltable_insert (symboltable_t *table, const char *identifier, gnode_t *node) {
 bool symboltable_insert (symboltable_t *table, const char *identifier, gnode_t *node) {
     if (!identifier) return false;
     if (!identifier) return false;
-    
+
 	size_t			n = scope_stack_size(table->stack);
 	size_t			n = scope_stack_size(table->stack);
 	gravity_hash_t	*h = scope_stack_get(table->stack, n-1);
 	gravity_hash_t	*h = scope_stack_get(table->stack, n-1);
-	
+
 	// insert node with key identifier into hash table (and check if already exists in current scope)
 	// insert node with key identifier into hash table (and check if already exists in current scope)
 	gravity_value_t key = VALUE_FROM_CSTRING(NULL, identifier);
 	gravity_value_t key = VALUE_FROM_CSTRING(NULL, identifier);
 	if (gravity_hash_lookup(h, key) != NULL) {
 	if (gravity_hash_lookup(h, key) != NULL) {
@@ -106,21 +106,21 @@ bool symboltable_insert (symboltable_t *table, const char *identifier, gnode_t *
 		return false;
 		return false;
 	}
 	}
 	gravity_hash_insert(h, key, VALUE_FROM_NODE(node));
 	gravity_hash_insert(h, key, VALUE_FROM_NODE(node));
-						
+
 	++table->counter;
 	++table->counter;
 	return true;
 	return true;
 }
 }
 
 
 gnode_t *symboltable_lookup (symboltable_t *table, const char *identifier) {
 gnode_t *symboltable_lookup (symboltable_t *table, const char *identifier) {
 	STATICVALUE_FROM_STRING(key, identifier, strlen(identifier));
 	STATICVALUE_FROM_STRING(key, identifier, strlen(identifier));
-	
+
 	size_t n = scope_stack_size(table->stack);
 	size_t n = scope_stack_size(table->stack);
 	for (int i=(int)n-1; i>=0; --i) {
 	for (int i=(int)n-1; i>=0; --i) {
 		gravity_hash_t *h = scope_stack_get(table->stack, i);
 		gravity_hash_t *h = scope_stack_get(table->stack, i);
 		gravity_value_t *v = gravity_hash_lookup(h, key);
 		gravity_value_t *v = gravity_hash_lookup(h, key);
 		if (v) return VALUE_AS_NODE(*v);
 		if (v) return VALUE_AS_NODE(*v);
 	}
 	}
-	
+
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -134,7 +134,7 @@ uint32_t symboltable_count (symboltable_t *table, uint32_t index) {
 gnode_t *symboltable_global_lookup (symboltable_t *table, const char *identifier) {
 gnode_t *symboltable_global_lookup (symboltable_t *table, const char *identifier) {
 	gravity_hash_t *h = scope_stack_get(table->stack, 0);
 	gravity_hash_t *h = scope_stack_get(table->stack, 0);
 	STATICVALUE_FROM_STRING(key, identifier, strlen(identifier));
 	STATICVALUE_FROM_STRING(key, identifier, strlen(identifier));
-	
+
 	gravity_value_t *v = gravity_hash_lookup(h, key);
 	gravity_value_t *v = gravity_hash_lookup(h, key);
 	return (v) ? VALUE_AS_NODE(*v) : NULL;
 	return (v) ? VALUE_AS_NODE(*v) : NULL;
 }
 }
@@ -160,7 +160,7 @@ uint32_t symboltable_exit_scope (symboltable_t *table, uint32_t *nlevel) {
 
 
 void symboltable_dump (symboltable_t *table) {
 void symboltable_dump (symboltable_t *table) {
 	size_t n = scope_stack_size(table->stack);
 	size_t n = scope_stack_size(table->stack);
-	
+
 	for (int i=(int)n-1; i>=0; --i) {
 	for (int i=(int)n-1; i>=0; --i) {
 		gravity_hash_t *h = (gravity_hash_t *)scope_stack_get(table->stack, i);
 		gravity_hash_t *h = (gravity_hash_t *)scope_stack_get(table->stack, i);
 		gravity_hash_dump(h);
 		gravity_hash_dump(h);

+ 23 - 23
src/compiler/gravity_token.c

@@ -24,7 +24,7 @@ const char *token_name (gtoken_t token) {
 		case TOK_IDENTIFIER: return "IDENTIFIER";
 		case TOK_IDENTIFIER: return "IDENTIFIER";
 		case TOK_SPECIAL: return "SPECIAL";
 		case TOK_SPECIAL: return "SPECIAL";
 		case TOK_MACRO: return "MACRO";
 		case TOK_MACRO: return "MACRO";
-		
+
 		// keywords
 		// keywords
 		case TOK_KEY_FILE: return "file";
 		case TOK_KEY_FILE: return "file";
 		case TOK_KEY_FUNC: return "func";
 		case TOK_KEY_FUNC: return "func";
@@ -62,7 +62,7 @@ const char *token_name (gtoken_t token) {
 		case TOK_KEY_ISA: return "is";
 		case TOK_KEY_ISA: return "is";
 		case TOK_KEY_CURRARGS: return "_args";
 		case TOK_KEY_CURRARGS: return "_args";
 		case TOK_KEY_CURRFUNC: return "_func";
 		case TOK_KEY_CURRFUNC: return "_func";
-		
+
 		// operators
 		// operators
 		case TOK_OP_ADD: return "+";
 		case TOK_OP_ADD: return "+";
 		case TOK_OP_SUB: return "-";
 		case TOK_OP_SUB: return "-";
@@ -101,7 +101,7 @@ const char *token_name (gtoken_t token) {
 		case TOK_OP_BIT_AND_ASSIGN: return "&=";
 		case TOK_OP_BIT_AND_ASSIGN: return "&=";
 		case TOK_OP_BIT_OR_ASSIGN: return "|=";
 		case TOK_OP_BIT_OR_ASSIGN: return "|=";
 		case TOK_OP_BIT_XOR_ASSIGN: return "^=";
 		case TOK_OP_BIT_XOR_ASSIGN: return "^=";
-		
+
 		case TOK_OP_OPEN_PARENTHESIS: return "(";
 		case TOK_OP_OPEN_PARENTHESIS: return "(";
 		case TOK_OP_CLOSED_PARENTHESIS: return ")";
 		case TOK_OP_CLOSED_PARENTHESIS: return ")";
 		case TOK_OP_OPEN_SQUAREBRACKET: return "[";
 		case TOK_OP_OPEN_SQUAREBRACKET: return "[";
@@ -112,10 +112,10 @@ const char *token_name (gtoken_t token) {
 		case TOK_OP_COLON: return ":";
 		case TOK_OP_COLON: return ":";
 		case TOK_OP_COMMA: return ",";
 		case TOK_OP_COMMA: return ",";
 		case TOK_OP_DOT: return ".";
 		case TOK_OP_DOT: return ".";
-		
+
 		case TOK_END: return "";
 		case TOK_END: return "";
 	}
 	}
-	
+
 	// should never reach this point
 	// should never reach this point
 	return "UNRECOGNIZED TOKEN";
 	return "UNRECOGNIZED TOKEN";
 }
 }
@@ -128,7 +128,7 @@ void token_keywords_indexes (uint32_t *idx_start, uint32_t *idx_end) {
 gtoken_t token_special_builtin(gtoken_s *token) {
 gtoken_t token_special_builtin(gtoken_s *token) {
     const char *buffer = token->value;
     const char *buffer = token->value;
     int32_t len = token->bytes;
     int32_t len = token->bytes;
-    
+
     switch (len) {
     switch (len) {
         case 8:
         case 8:
             if (string_casencmp(buffer, "__LINE__", len) == 0) {
             if (string_casencmp(buffer, "__LINE__", len) == 0) {
@@ -140,21 +140,21 @@ gtoken_t token_special_builtin(gtoken_s *token) {
                 return TOK_STRING;
                 return TOK_STRING;
             }
             }
             break;
             break;
-        
+
         case 9:
         case 9:
             if (string_casencmp(buffer, "__CLASS__", len) == 0) {
             if (string_casencmp(buffer, "__CLASS__", len) == 0) {
                 token->builtin = BUILTIN_CLASS;
                 token->builtin = BUILTIN_CLASS;
                 return TOK_STRING;
                 return TOK_STRING;
             }
             }
             break;
             break;
-            
+
         case 10:
         case 10:
             if (string_casencmp(buffer, "__COLUMN__", len) == 0) {
             if (string_casencmp(buffer, "__COLUMN__", len) == 0) {
                 token->builtin = BUILTIN_COLUMN;
                 token->builtin = BUILTIN_COLUMN;
                 return TOK_NUMBER;
                 return TOK_NUMBER;
             }
             }
             break;
             break;
-            
+
         case 12:
         case 12:
             if (string_casencmp(buffer, "__FUNCTION__", len) == 0) {
             if (string_casencmp(buffer, "__FUNCTION__", len) == 0) {
                 token->builtin = BUILTIN_FUNC;
                 token->builtin = BUILTIN_FUNC;
@@ -162,7 +162,7 @@ gtoken_t token_special_builtin(gtoken_s *token) {
             }
             }
             break;
             break;
     }
     }
-    
+
     return TOK_IDENTIFIER;
     return TOK_IDENTIFIER;
 }
 }
 
 
@@ -174,14 +174,14 @@ gtoken_t token_keyword (const char *buffer, int32_t len) {
 			if (string_casencmp(buffer, "or", len) == 0) return TOK_OP_OR;
 			if (string_casencmp(buffer, "or", len) == 0) return TOK_OP_OR;
 			if (string_casencmp(buffer, "is", len) == 0) return TOK_KEY_ISA;
 			if (string_casencmp(buffer, "is", len) == 0) return TOK_KEY_ISA;
 			break;
 			break;
-			
+
 		case 3:
 		case 3:
 			if (string_casencmp(buffer, "for", len) == 0) return TOK_KEY_FOR;
 			if (string_casencmp(buffer, "for", len) == 0) return TOK_KEY_FOR;
 			if (string_casencmp(buffer, "var", len) == 0) return TOK_KEY_VAR;
 			if (string_casencmp(buffer, "var", len) == 0) return TOK_KEY_VAR;
 			if (string_casencmp(buffer, "and", len) == 0) return TOK_OP_AND;
 			if (string_casencmp(buffer, "and", len) == 0) return TOK_OP_AND;
 			if (string_casencmp(buffer, "not", len) == 0) return TOK_OP_NOT;
 			if (string_casencmp(buffer, "not", len) == 0) return TOK_OP_NOT;
 			break;
 			break;
-			
+
 		case 4:
 		case 4:
 			if (string_casencmp(buffer, "func", len) == 0) return TOK_KEY_FUNC;
 			if (string_casencmp(buffer, "func", len) == 0) return TOK_KEY_FUNC;
 			if (string_casencmp(buffer, "else", len) == 0) return TOK_KEY_ELSE;
 			if (string_casencmp(buffer, "else", len) == 0) return TOK_KEY_ELSE;
@@ -192,7 +192,7 @@ gtoken_t token_keyword (const char *buffer, int32_t len) {
 			if (string_casencmp(buffer, "file", len) == 0) return TOK_KEY_FILE;
 			if (string_casencmp(buffer, "file", len) == 0) return TOK_KEY_FILE;
 			if (string_casencmp(buffer, "lazy", len) == 0) return TOK_KEY_LAZY;
 			if (string_casencmp(buffer, "lazy", len) == 0) return TOK_KEY_LAZY;
 			break;
 			break;
-			
+
 		case 5:
 		case 5:
 			if (string_casencmp(buffer, "super", len) == 0) return TOK_KEY_SUPER;
 			if (string_casencmp(buffer, "super", len) == 0) return TOK_KEY_SUPER;
 			if (string_casencmp(buffer, "false", len) == 0) return TOK_KEY_FALSE;
 			if (string_casencmp(buffer, "false", len) == 0) return TOK_KEY_FALSE;
@@ -204,7 +204,7 @@ gtoken_t token_keyword (const char *buffer, int32_t len) {
 			if (string_casencmp(buffer, "_func", len) == 0) return TOK_KEY_CURRFUNC;
 			if (string_casencmp(buffer, "_func", len) == 0) return TOK_KEY_CURRFUNC;
 			if (string_casencmp(buffer, "_args", len) == 0) return TOK_KEY_CURRARGS;
 			if (string_casencmp(buffer, "_args", len) == 0) return TOK_KEY_CURRARGS;
 			break;
 			break;
-			
+
 		case 6:
 		case 6:
 			if (string_casencmp(buffer, "struct", len) == 0) return TOK_KEY_STRUCT;
 			if (string_casencmp(buffer, "struct", len) == 0) return TOK_KEY_STRUCT;
 			if (string_casencmp(buffer, "repeat", len) == 0) return TOK_KEY_REPEAT;
 			if (string_casencmp(buffer, "repeat", len) == 0) return TOK_KEY_REPEAT;
@@ -216,22 +216,22 @@ gtoken_t token_keyword (const char *buffer, int32_t len) {
 			if (string_casencmp(buffer, "import", len) == 0) return TOK_KEY_IMPORT;
 			if (string_casencmp(buffer, "import", len) == 0) return TOK_KEY_IMPORT;
 			if (string_casencmp(buffer, "module", len) == 0) return TOK_KEY_MODULE;
 			if (string_casencmp(buffer, "module", len) == 0) return TOK_KEY_MODULE;
 			break;
 			break;
-			
+
 		case 7:
 		case 7:
 			if (string_casencmp(buffer, "default", len) == 0) return TOK_KEY_DEFAULT;
 			if (string_casencmp(buffer, "default", len) == 0) return TOK_KEY_DEFAULT;
 			if (string_casencmp(buffer, "private", len) == 0) return TOK_KEY_PRIVATE;
 			if (string_casencmp(buffer, "private", len) == 0) return TOK_KEY_PRIVATE;
 			break;
 			break;
-			
+
 		case 8:
 		case 8:
 			if (string_casencmp(buffer, "continue", len) == 0) return TOK_KEY_CONTINUE;
 			if (string_casencmp(buffer, "continue", len) == 0) return TOK_KEY_CONTINUE;
 			if (string_casencmp(buffer, "internal", len) == 0) return TOK_KEY_INTERNAL;
 			if (string_casencmp(buffer, "internal", len) == 0) return TOK_KEY_INTERNAL;
 			break;
 			break;
-			
+
 		case 9:
 		case 9:
 			if (string_casencmp(buffer, "undefined", len) == 0) return TOK_KEY_UNDEFINED;
 			if (string_casencmp(buffer, "undefined", len) == 0) return TOK_KEY_UNDEFINED;
 			break;
 			break;
 	}
 	}
-	
+
 	return TOK_IDENTIFIER;
 	return TOK_IDENTIFIER;
 }
 }
 
 
@@ -256,7 +256,7 @@ bool token_isvariable_declaration (gtoken_t token) {
 
 
 bool token_isstatement (gtoken_t token) {
 bool token_isstatement (gtoken_t token) {
 	if (token == TOK_EOF) return false;
 	if (token == TOK_EOF) return false;
-	
+
 	// label_statement (case, default)
 	// label_statement (case, default)
 	// expression_statement ('+' | '-' | '!' | 'not' | new | raise | file | isPrimaryExpression)
 	// expression_statement ('+' | '-' | '!' | 'not' | new | raise | file | isPrimaryExpression)
 	// flow_statement (if, select)
 	// flow_statement (if, select)
@@ -266,7 +266,7 @@ bool token_isstatement (gtoken_t token) {
 	// declaration_statement (isDeclarationStatement)
 	// declaration_statement (isDeclarationStatement)
 	// empty_statement (;)
 	// empty_statement (;)
 	// import_statement (import)
 	// import_statement (import)
-	
+
 	return (token_islabel_statement(token) || token_isexpression_statement(token) || token_isflow_statement(token) ||
 	return (token_islabel_statement(token) || token_isexpression_statement(token) || token_isflow_statement(token) ||
 			token_isloop_statement(token) || token_isjump_statement(token) || token_iscompound_statement(token) ||
 			token_isloop_statement(token) || token_isjump_statement(token) || token_iscompound_statement(token) ||
 			token_isdeclaration_statement(token) || token_isempty_statement(token) || token_isimport_statement(token) ||
 			token_isdeclaration_statement(token) || token_isempty_statement(token) || token_isimport_statement(token) ||
@@ -305,7 +305,7 @@ bool token_isprimary_expression (gtoken_t token) {
 	// function_expression
 	// function_expression
 	// list_expression
 	// list_expression
 	// map_expression
 	// map_expression
-	
+
 	return ((token == TOK_NUMBER) || (token == TOK_STRING) || (token == TOK_KEY_TRUE) ||
 	return ((token == TOK_NUMBER) || (token == TOK_STRING) || (token == TOK_KEY_TRUE) ||
 			(token == TOK_KEY_FALSE) || (token == TOK_IDENTIFIER) || (token == TOK_KEY_NULL) ||
 			(token == TOK_KEY_FALSE) || (token == TOK_IDENTIFIER) || (token == TOK_KEY_NULL) ||
 			(token == TOK_KEY_SUPER) || (token == TOK_KEY_FUNC) || (token == TOK_KEY_UNDEFINED) ||
 			(token == TOK_KEY_SUPER) || (token == TOK_KEY_FUNC) || (token == TOK_KEY_UNDEFINED) ||
@@ -319,7 +319,7 @@ bool token_isexpression_statement (gtoken_t token) {
 	// postfix_expression: primary_expression | 'module' (was file)
 	// postfix_expression: primary_expression | 'module' (was file)
 	// unary_operator: '+' | '-' | '!' | 'not'
 	// unary_operator: '+' | '-' | '!' | 'not'
 	// raise_expression: 'raise'
 	// raise_expression: 'raise'
-	
+
 	return (token_isprimary_expression(token) || (token == TOK_OP_ADD) || (token == TOK_OP_SUB) ||
 	return (token_isprimary_expression(token) || (token == TOK_OP_ADD) || (token == TOK_OP_SUB) ||
 			(token == TOK_OP_NOT) || (token == TOK_KEY_CURRARGS) || (token == TOK_KEY_CURRFUNC));
 			(token == TOK_OP_NOT) || (token == TOK_KEY_CURRARGS) || (token == TOK_KEY_CURRFUNC));
 }
 }
@@ -352,7 +352,7 @@ bool token_isdeclaration_statement (gtoken_t token) {
 	// module_declaration (MODULE)
 	// module_declaration (MODULE)
 	// event_declaration_statement (EVENT)
 	// event_declaration_statement (EVENT)
 	// empty_declaration (;)
 	// empty_declaration (;)
-	
+
 	return ((token_isaccess_specifier(token) || token_isstorage_specifier(token) || token_isvariable_declaration(token) ||
 	return ((token_isaccess_specifier(token) || token_isstorage_specifier(token) || token_isvariable_declaration(token) ||
 			(token == TOK_KEY_FUNC)	|| (token == TOK_KEY_CLASS) || (token == TOK_KEY_STRUCT) || (token == TOK_KEY_ENUM) ||
 			(token == TOK_KEY_FUNC)	|| (token == TOK_KEY_CLASS) || (token == TOK_KEY_STRUCT) || (token == TOK_KEY_ENUM) ||
 			(token == TOK_KEY_MODULE) || (token == TOK_KEY_EVENT)  || (token == TOK_OP_SEMICOLON)));
 			(token == TOK_KEY_MODULE) || (token == TOK_KEY_EVENT)  || (token == TOK_OP_SEMICOLON)));

+ 4 - 4
src/compiler/gravity_token.h

@@ -63,7 +63,7 @@
 typedef enum {
 typedef enum {
 	// General (8)
 	// General (8)
 	TOK_EOF	= 0, TOK_ERROR, TOK_COMMENT, TOK_STRING, TOK_NUMBER, TOK_IDENTIFIER, TOK_SPECIAL, TOK_MACRO,
 	TOK_EOF	= 0, TOK_ERROR, TOK_COMMENT, TOK_STRING, TOK_NUMBER, TOK_IDENTIFIER, TOK_SPECIAL, TOK_MACRO,
-	
+
 	// Keywords (36)
 	// Keywords (36)
 	// remember to keep in sync functions token_keywords_indexes and token_name
 	// remember to keep in sync functions token_keywords_indexes and token_name
 	TOK_KEY_FUNC, TOK_KEY_SUPER, TOK_KEY_DEFAULT, TOK_KEY_TRUE, TOK_KEY_FALSE, TOK_KEY_IF,
 	TOK_KEY_FUNC, TOK_KEY_SUPER, TOK_KEY_DEFAULT, TOK_KEY_TRUE, TOK_KEY_FALSE, TOK_KEY_IF,
@@ -72,7 +72,7 @@ typedef enum {
 	TOK_KEY_FILE, TOK_KEY_INTERNAL, TOK_KEY_PUBLIC, TOK_KEY_STATIC, TOK_KEY_EXTERN, TOK_KEY_LAZY, TOK_KEY_CONST,
 	TOK_KEY_FILE, TOK_KEY_INTERNAL, TOK_KEY_PUBLIC, TOK_KEY_STATIC, TOK_KEY_EXTERN, TOK_KEY_LAZY, TOK_KEY_CONST,
 	TOK_KEY_VAR, TOK_KEY_MODULE, TOK_KEY_IMPORT, TOK_KEY_CASE, TOK_KEY_EVENT, TOK_KEY_NULL, TOK_KEY_UNDEFINED,
 	TOK_KEY_VAR, TOK_KEY_MODULE, TOK_KEY_IMPORT, TOK_KEY_CASE, TOK_KEY_EVENT, TOK_KEY_NULL, TOK_KEY_UNDEFINED,
 	TOK_KEY_ISA, TOK_KEY_CURRFUNC, TOK_KEY_CURRARGS,
 	TOK_KEY_ISA, TOK_KEY_CURRFUNC, TOK_KEY_CURRARGS,
-	
+
 	// Operators (36)
 	// Operators (36)
 	TOK_OP_SHIFT_LEFT, TOK_OP_SHIFT_RIGHT, TOK_OP_MUL, TOK_OP_DIV, TOK_OP_REM, TOK_OP_BIT_AND, TOK_OP_ADD, TOK_OP_SUB,
 	TOK_OP_SHIFT_LEFT, TOK_OP_SHIFT_RIGHT, TOK_OP_MUL, TOK_OP_DIV, TOK_OP_REM, TOK_OP_BIT_AND, TOK_OP_ADD, TOK_OP_SUB,
 	TOK_OP_BIT_OR, TOK_OP_BIT_XOR, TOK_OP_BIT_NOT, TOK_OP_RANGE_EXCLUDED, TOK_OP_RANGE_INCLUDED, TOK_OP_LESS, TOK_OP_LESS_EQUAL,
 	TOK_OP_BIT_OR, TOK_OP_BIT_XOR, TOK_OP_BIT_NOT, TOK_OP_RANGE_EXCLUDED, TOK_OP_RANGE_INCLUDED, TOK_OP_LESS, TOK_OP_LESS_EQUAL,
@@ -80,11 +80,11 @@ typedef enum {
 	TOK_OP_PATTERN_MATCH, TOK_OP_AND, TOK_OP_OR, TOK_OP_TERNARY, TOK_OP_ASSIGN, TOK_OP_MUL_ASSIGN, TOK_OP_DIV_ASSIGN,
 	TOK_OP_PATTERN_MATCH, TOK_OP_AND, TOK_OP_OR, TOK_OP_TERNARY, TOK_OP_ASSIGN, TOK_OP_MUL_ASSIGN, TOK_OP_DIV_ASSIGN,
 	TOK_OP_REM_ASSIGN, TOK_OP_ADD_ASSIGN, TOK_OP_SUB_ASSIGN, TOK_OP_SHIFT_LEFT_ASSIGN, TOK_OP_SHIFT_RIGHT_ASSIGN,
 	TOK_OP_REM_ASSIGN, TOK_OP_ADD_ASSIGN, TOK_OP_SUB_ASSIGN, TOK_OP_SHIFT_LEFT_ASSIGN, TOK_OP_SHIFT_RIGHT_ASSIGN,
 	TOK_OP_BIT_AND_ASSIGN, TOK_OP_BIT_OR_ASSIGN, TOK_OP_BIT_XOR_ASSIGN, TOK_OP_NOT,
 	TOK_OP_BIT_AND_ASSIGN, TOK_OP_BIT_OR_ASSIGN, TOK_OP_BIT_XOR_ASSIGN, TOK_OP_NOT,
-	
+
 	// Punctuators (10)
 	// Punctuators (10)
 	TOK_OP_SEMICOLON, TOK_OP_OPEN_PARENTHESIS, TOK_OP_COLON, TOK_OP_COMMA, TOK_OP_DOT, TOK_OP_CLOSED_PARENTHESIS,
 	TOK_OP_SEMICOLON, TOK_OP_OPEN_PARENTHESIS, TOK_OP_COLON, TOK_OP_COMMA, TOK_OP_DOT, TOK_OP_CLOSED_PARENTHESIS,
 	TOK_OP_OPEN_SQUAREBRACKET, TOK_OP_CLOSED_SQUAREBRACKET, TOK_OP_OPEN_CURLYBRACE, TOK_OP_CLOSED_CURLYBRACE,
 	TOK_OP_OPEN_SQUAREBRACKET, TOK_OP_CLOSED_SQUAREBRACKET, TOK_OP_OPEN_CURLYBRACE, TOK_OP_CLOSED_CURLYBRACE,
-	
+
 	// Mark end of tokens (1)
 	// Mark end of tokens (1)
 	TOK_END
 	TOK_END
 } gtoken_t;
 } gtoken_t;

+ 7 - 7
src/compiler/gravity_visitor.c

@@ -23,12 +23,12 @@ void gvisit(gvisitor_t *self, gnode_t *node) {
 	// this line added after implemented getter and setter,
 	// this line added after implemented getter and setter,
 	// because they are functions inside a COMPOUND_STATEMENT and can be NULL
 	// because they are functions inside a COMPOUND_STATEMENT and can be NULL
 	if (!node) return;
 	if (!node) return;
-	
+
     // pre-visit
     // pre-visit
     if (self->visit_pre) self->visit_pre(self, node);
     if (self->visit_pre) self->visit_pre(self, node);
-    
+
 	switch (node->tag) {
 	switch (node->tag) {
-		
+
 		// statements (7)
 		// statements (7)
 		case NODE_LIST_STAT: VISIT(list_stmt);
 		case NODE_LIST_STAT: VISIT(list_stmt);
 		case NODE_COMPOUND_STAT: VISIT(compound_stmt);
 		case NODE_COMPOUND_STAT: VISIT(compound_stmt);
@@ -37,7 +37,7 @@ void gvisit(gvisitor_t *self, gnode_t *node) {
 		case NODE_JUMP_STAT: VISIT(jump_stmt);
 		case NODE_JUMP_STAT: VISIT(jump_stmt);
 		case NODE_LOOP_STAT: VISIT(loop_stmt);
 		case NODE_LOOP_STAT: VISIT(loop_stmt);
 		case NODE_EMPTY_STAT: VISIT(empty_stmt);
 		case NODE_EMPTY_STAT: VISIT(empty_stmt);
-		
+
 		// declarations (5)
 		// declarations (5)
 		case NODE_ENUM_DECL: VISIT(enum_decl);
 		case NODE_ENUM_DECL: VISIT(enum_decl);
 		case NODE_FUNCTION_DECL: VISIT(function_decl);
 		case NODE_FUNCTION_DECL: VISIT(function_decl);
@@ -45,7 +45,7 @@ void gvisit(gvisitor_t *self, gnode_t *node) {
 		case NODE_CLASS_DECL: VISIT(class_decl);
 		case NODE_CLASS_DECL: VISIT(class_decl);
 		case NODE_MODULE_DECL: VISIT(module_decl);
 		case NODE_MODULE_DECL: VISIT(module_decl);
 		// NODE_VARIABLE is handled by NODE_VARIABLE_DECL
 		// NODE_VARIABLE is handled by NODE_VARIABLE_DECL
-			
+
 		// expressions (8)
 		// expressions (8)
 		case NODE_BINARY_EXPR: VISIT(binary_expr);
 		case NODE_BINARY_EXPR: VISIT(binary_expr);
 		case NODE_UNARY_EXPR: VISIT(unary_expr);
 		case NODE_UNARY_EXPR: VISIT(unary_expr);
@@ -55,11 +55,11 @@ void gvisit(gvisitor_t *self, gnode_t *node) {
 		case NODE_IDENTIFIER_EXPR: VISIT(identifier_expr);
 		case NODE_IDENTIFIER_EXPR: VISIT(identifier_expr);
 		case NODE_KEYWORD_EXPR: VISIT(keyword_expr);
 		case NODE_KEYWORD_EXPR: VISIT(keyword_expr);
 		case NODE_POSTFIX_EXPR: VISIT(postfix_expr);
 		case NODE_POSTFIX_EXPR: VISIT(postfix_expr);
-			
+
 		// default assert
 		// default assert
 		default: default_action(node);
 		default: default_action(node);
 	}
 	}
-    
+
     // post-visit
     // post-visit
     if (self->visit_post) self->visit_post(self, node);
     if (self->visit_post) self->visit_post(self, node);
 }
 }

+ 5 - 5
src/compiler/gravity_visitor.h

@@ -17,13 +17,13 @@ typedef struct gvisitor {
 	uint32_t	nerr;			// to store err counter state
 	uint32_t	nerr;			// to store err counter state
 	void		*data;			// to store a ptr state
 	void		*data;			// to store a ptr state
 	void		*delegate;		// delegate callback
 	void		*delegate;		// delegate callback
-	
+
     // COMMON
     // COMMON
     void (* visit_pre)(struct gvisitor *self, gnode_t *node);
     void (* visit_pre)(struct gvisitor *self, gnode_t *node);
     void (* visit_post)(struct gvisitor *self, gnode_t *node);
     void (* visit_post)(struct gvisitor *self, gnode_t *node);
-    
+
 	// count must be equal to enum gnode_n defined in gravity_ast.h less 3
 	// count must be equal to enum gnode_n defined in gravity_ast.h less 3
-	
+
 	// STATEMENTS: 7
 	// STATEMENTS: 7
 	void (* visit_list_stmt)(struct gvisitor *self, gnode_compound_stmt_t *node);
 	void (* visit_list_stmt)(struct gvisitor *self, gnode_compound_stmt_t *node);
 	void (* visit_compound_stmt)(struct gvisitor *self, gnode_compound_stmt_t *node);
 	void (* visit_compound_stmt)(struct gvisitor *self, gnode_compound_stmt_t *node);
@@ -32,14 +32,14 @@ typedef struct gvisitor {
 	void (* visit_jump_stmt)(struct gvisitor *self, gnode_jump_stmt_t *node);
 	void (* visit_jump_stmt)(struct gvisitor *self, gnode_jump_stmt_t *node);
 	void (* visit_loop_stmt)(struct gvisitor *self, gnode_loop_stmt_t *node);
 	void (* visit_loop_stmt)(struct gvisitor *self, gnode_loop_stmt_t *node);
 	void (* visit_empty_stmt)(struct gvisitor *self, gnode_empty_stmt_t *node);
 	void (* visit_empty_stmt)(struct gvisitor *self, gnode_empty_stmt_t *node);
-	
+
 	// DECLARATIONS: 5+1 (NODE_VARIABLE handled by NODE_VARIABLE_DECL case)
 	// DECLARATIONS: 5+1 (NODE_VARIABLE handled by NODE_VARIABLE_DECL case)
 	void (* visit_function_decl)(struct gvisitor *self, gnode_function_decl_t *node);
 	void (* visit_function_decl)(struct gvisitor *self, gnode_function_decl_t *node);
 	void (* visit_variable_decl)(struct gvisitor *self, gnode_variable_decl_t *node);
 	void (* visit_variable_decl)(struct gvisitor *self, gnode_variable_decl_t *node);
 	void (* visit_enum_decl)(struct gvisitor *self, gnode_enum_decl_t *node);
 	void (* visit_enum_decl)(struct gvisitor *self, gnode_enum_decl_t *node);
 	void (* visit_class_decl)(struct gvisitor *self, gnode_class_decl_t *node);
 	void (* visit_class_decl)(struct gvisitor *self, gnode_class_decl_t *node);
 	void (* visit_module_decl)(struct gvisitor *self, gnode_module_decl_t *node);
 	void (* visit_module_decl)(struct gvisitor *self, gnode_module_decl_t *node);
-	
+
 	// EXPRESSIONS: 7+3 (CALL EXPRESSIONS handled by one callback)
 	// EXPRESSIONS: 7+3 (CALL EXPRESSIONS handled by one callback)
 	void (* visit_binary_expr)(struct gvisitor *self, gnode_binary_expr_t *node);
 	void (* visit_binary_expr)(struct gvisitor *self, gnode_binary_expr_t *node);
 	void (* visit_unary_expr)(struct gvisitor *self, gnode_unary_expr_t *node);
 	void (* visit_unary_expr)(struct gvisitor *self, gnode_unary_expr_t *node);

+ 79 - 79
src/optionals/gravity_math.c

@@ -62,11 +62,11 @@ static uint32_t                     refcount = 0;
 static bool math_abs (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_abs (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_int_t computed_value;
         gravity_int_t computed_value;
         #ifdef GRAVITY_ENABLE_INT64
         #ifdef GRAVITY_ENABLE_INT64
@@ -76,7 +76,7 @@ static bool math_abs (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
         #endif
         #endif
         RETURN_VALUE(VALUE_FROM_INT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_INT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value;
         gravity_float_t computed_value;
         #ifdef GRAVITY_ENABLE_DOUBLE
         #ifdef GRAVITY_ENABLE_DOUBLE
@@ -86,7 +86,7 @@ static bool math_abs (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
         #endif
         #endif
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -95,21 +95,21 @@ static bool math_abs (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_acos (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_acos (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ACOS((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)ACOS((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ACOS((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)ACOS((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -118,21 +118,21 @@ static bool math_acos (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
 static bool math_asin (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_asin (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ASIN((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)ASIN((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ASIN((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)ASIN((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -141,21 +141,21 @@ static bool math_asin (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
 static bool math_atan (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_atan (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ATAN((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)ATAN((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ATAN((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)ATAN((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -163,31 +163,31 @@ static bool math_atan (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
 // returns the arctangent of the quotient of its arguments
 // returns the arctangent of the quotient of its arguments
 static bool math_atan2 (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_atan2 (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm)
     #pragma unused(vm)
-    
+
     if (nargs != 3) RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     if (nargs != 3) RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
-    
+
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value2 = GET_VALUE(2);
     gravity_value_t value2 = GET_VALUE(2);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     gravity_float_t n2;
     gravity_float_t n2;
     if (VALUE_ISA_INT(value2)) n2 = (gravity_float_t)value2.n;
     if (VALUE_ISA_INT(value2)) n2 = (gravity_float_t)value2.n;
     else if (VALUE_ISA_FLOAT(value2)) n2 = (gravity_float_t)value2.f;
     else if (VALUE_ISA_FLOAT(value2)) n2 = (gravity_float_t)value2.f;
     else RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     else RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ATAN2((gravity_float_t)value.n, n2);
         gravity_float_t computed_value = (gravity_float_t)ATAN2((gravity_float_t)value.n, n2);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ATAN2((gravity_float_t)value.f, n2);
         gravity_float_t computed_value = (gravity_float_t)ATAN2((gravity_float_t)value.f, n2);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -252,21 +252,21 @@ static bool math_xrt (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_ceil (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_ceil (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)CEIL((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)CEIL((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)CEIL((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)CEIL((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -275,21 +275,21 @@ static bool math_ceil (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
 static bool math_cos (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_cos (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)COS((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)COS((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)COS((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)COS((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -298,21 +298,21 @@ static bool math_cos (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_exp (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_exp (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)EXP((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)EXP((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)EXP((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)EXP((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -321,21 +321,21 @@ static bool math_exp (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_floor (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_floor (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)FLOOR((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)FLOOR((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)FLOOR((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)FLOOR((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -397,21 +397,21 @@ static bool math_lcm (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_log (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_log (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)LOG((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)LOG((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)LOG((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)LOG((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -477,7 +477,7 @@ static bool math_logx (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
 static bool math_max (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_max (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     gravity_float_t n = FLOAT_MIN;
     gravity_float_t n = FLOAT_MIN;
     gravity_value_t result = VALUE_FROM_UNDEFINED;
     gravity_value_t result = VALUE_FROM_UNDEFINED;
-    
+
     for (uint16_t i = 1; i<nargs; ++i) {
     for (uint16_t i = 1; i<nargs; ++i) {
         gravity_value_t value = GET_VALUE(i);
         gravity_value_t value = GET_VALUE(i);
         if (VALUE_ISA_INT(value)) {
         if (VALUE_ISA_INT(value)) {
@@ -486,7 +486,7 @@ static bool math_max (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
             if (value.f > n) result = value;
             if (value.f > n) result = value;
         } else continue;
         } else continue;
     }
     }
-    
+
     RETURN_VALUE(result, rindex);
     RETURN_VALUE(result, rindex);
 }
 }
 
 
@@ -494,7 +494,7 @@ static bool math_max (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_min (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_min (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     gravity_float_t n = FLOAT_MAX;
     gravity_float_t n = FLOAT_MAX;
     gravity_value_t result = VALUE_FROM_UNDEFINED;
     gravity_value_t result = VALUE_FROM_UNDEFINED;
-    
+
     for (uint16_t i = 1; i<nargs; ++i) {
     for (uint16_t i = 1; i<nargs; ++i) {
         gravity_value_t value = GET_VALUE(i);
         gravity_value_t value = GET_VALUE(i);
         if (VALUE_ISA_INT(value)) {
         if (VALUE_ISA_INT(value)) {
@@ -503,38 +503,38 @@ static bool math_min (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
             if (value.f < n) result = value;
             if (value.f < n) result = value;
         } else continue;
         } else continue;
     }
     }
-    
+
     RETURN_VALUE(result, rindex);
     RETURN_VALUE(result, rindex);
 }
 }
 
 
 // returns the value of x to the power of y
 // returns the value of x to the power of y
 static bool math_pow (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_pow (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm)
     #pragma unused(vm)
-    
+
     if (nargs != 3) RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     if (nargs != 3) RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
-    
+
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value2 = GET_VALUE(2);
     gravity_value_t value2 = GET_VALUE(2);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     gravity_float_t n2;
     gravity_float_t n2;
     if (VALUE_ISA_INT(value2)) n2 = (gravity_float_t)value2.n;
     if (VALUE_ISA_INT(value2)) n2 = (gravity_float_t)value2.n;
     else if (VALUE_ISA_FLOAT(value2)) n2 = (gravity_float_t)value2.f;
     else if (VALUE_ISA_FLOAT(value2)) n2 = (gravity_float_t)value2.f;
     else RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     else RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)POW((gravity_float_t)value.n, n2);
         gravity_float_t computed_value = (gravity_float_t)POW((gravity_float_t)value.n, n2);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)POW((gravity_float_t)value.f, n2);
         gravity_float_t computed_value = (gravity_float_t)POW((gravity_float_t)value.f, n2);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -542,14 +542,14 @@ static bool math_pow (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 // returns a random number between 0 and 1
 // returns a random number between 0 and 1
 static bool math_random (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_random (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, args, nargs)
     #pragma unused(vm, args, nargs)
-    
+
     // only seed once
     // only seed once
     static bool already_seeded = false;
     static bool already_seeded = false;
     if (!already_seeded) {
     if (!already_seeded) {
         srand((unsigned)time(NULL));
         srand((unsigned)time(NULL));
         already_seeded = true;
         already_seeded = true;
     }
     }
-    
+
     int r = rand();
     int r = rand();
     RETURN_VALUE(VALUE_FROM_FLOAT((float)r / RAND_MAX), rindex);
     RETURN_VALUE(VALUE_FROM_FLOAT((float)r / RAND_MAX), rindex);
 }
 }
@@ -558,21 +558,21 @@ static bool math_random (gravity_vm *vm, gravity_value_t *args, uint16_t nargs,
 static bool math_round (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_round (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ROUND((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)ROUND((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)ROUND((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)ROUND((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -581,21 +581,21 @@ static bool math_round (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, u
 static bool math_sin (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_sin (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)SIN((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)SIN((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)SIN((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)SIN((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -604,21 +604,21 @@ static bool math_sin (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uin
 static bool math_sqrt (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_sqrt (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)SQRT((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)SQRT((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)SQRT((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)SQRT((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -627,21 +627,21 @@ static bool math_sqrt (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, ui
 static bool math_tan (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
 static bool math_tan (gravity_vm *vm, gravity_value_t *args, uint16_t nargs, uint32_t rindex) {
     #pragma unused(vm, nargs)
     #pragma unused(vm, nargs)
     gravity_value_t value = GET_VALUE(1);
     gravity_value_t value = GET_VALUE(1);
-    
+
     if (VALUE_ISA_NULL(value)) {
     if (VALUE_ISA_NULL(value)) {
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
         RETURN_VALUE(VALUE_FROM_INT(0), rindex);
     }
     }
-    
+
     if (VALUE_ISA_INT(value)) {
     if (VALUE_ISA_INT(value)) {
         gravity_float_t computed_value = (gravity_float_t)TAN((gravity_float_t)value.n);
         gravity_float_t computed_value = (gravity_float_t)TAN((gravity_float_t)value.n);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     if (VALUE_ISA_FLOAT(value)) {
     if (VALUE_ISA_FLOAT(value)) {
         gravity_float_t computed_value = (gravity_float_t)TAN((gravity_float_t)value.f);
         gravity_float_t computed_value = (gravity_float_t)TAN((gravity_float_t)value.f);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
         RETURN_VALUE(VALUE_FROM_FLOAT(computed_value), rindex);
     }
     }
-    
+
     // should be NaN
     // should be NaN
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
     RETURN_VALUE(VALUE_FROM_UNDEFINED, rindex);
 }
 }
@@ -700,7 +700,7 @@ static bool math_SQRT1_2 (gravity_vm *vm, gravity_value_t *args, uint16_t nargs,
 static void create_optional_class (void) {
 static void create_optional_class (void) {
     gravity_class_math = gravity_class_new_pair(NULL, MATH_CLASS_NAME, NULL, 0, 0);
     gravity_class_math = gravity_class_new_pair(NULL, MATH_CLASS_NAME, NULL, 0, 0);
     gravity_class_t *meta = gravity_class_get_meta(gravity_class_math);
     gravity_class_t *meta = gravity_class_get_meta(gravity_class_math);
-    
+
     gravity_class_bind(meta, "abs", NEW_CLOSURE_VALUE(math_abs));
     gravity_class_bind(meta, "abs", NEW_CLOSURE_VALUE(math_abs));
     gravity_class_bind(meta, "acos", NEW_CLOSURE_VALUE(math_acos));
     gravity_class_bind(meta, "acos", NEW_CLOSURE_VALUE(math_acos));
     gravity_class_bind(meta, "asin", NEW_CLOSURE_VALUE(math_asin));
     gravity_class_bind(meta, "asin", NEW_CLOSURE_VALUE(math_asin));
@@ -725,7 +725,7 @@ static void create_optional_class (void) {
     gravity_class_bind(meta, "sin", NEW_CLOSURE_VALUE(math_sin));
     gravity_class_bind(meta, "sin", NEW_CLOSURE_VALUE(math_sin));
     gravity_class_bind(meta, "sqrt", NEW_CLOSURE_VALUE(math_sqrt));
     gravity_class_bind(meta, "sqrt", NEW_CLOSURE_VALUE(math_sqrt));
     gravity_class_bind(meta, "tan", NEW_CLOSURE_VALUE(math_tan));
     gravity_class_bind(meta, "tan", NEW_CLOSURE_VALUE(math_tan));
-    
+
     gravity_closure_t *closure = NULL;
     gravity_closure_t *closure = NULL;
     closure = computed_property_create(NULL, NEW_FUNCTION(math_PI), NULL);
     closure = computed_property_create(NULL, NEW_FUNCTION(math_PI), NULL);
     gravity_class_bind(meta, "PI", VALUE_FROM_OBJECT(closure));
     gravity_class_bind(meta, "PI", VALUE_FROM_OBJECT(closure));
@@ -743,7 +743,7 @@ static void create_optional_class (void) {
     gravity_class_bind(meta, "SQRT2", VALUE_FROM_OBJECT(closure));
     gravity_class_bind(meta, "SQRT2", VALUE_FROM_OBJECT(closure));
     closure = computed_property_create(NULL, NEW_FUNCTION(math_SQRT1_2), NULL);
     closure = computed_property_create(NULL, NEW_FUNCTION(math_SQRT1_2), NULL);
     gravity_class_bind(meta, "SQRT1_2", VALUE_FROM_OBJECT(closure));
     gravity_class_bind(meta, "SQRT1_2", VALUE_FROM_OBJECT(closure));
-    
+
     SETMETA_INITED(gravity_class_math);
     SETMETA_INITED(gravity_class_math);
 }
 }
 
 
@@ -760,17 +760,17 @@ const char *gravity_math_name (void) {
 void gravity_math_register (gravity_vm *vm) {
 void gravity_math_register (gravity_vm *vm) {
     if (!gravity_class_math) create_optional_class();
     if (!gravity_class_math) create_optional_class();
     ++refcount;
     ++refcount;
-    
+
     if (!vm || gravity_vm_ismini(vm)) return;
     if (!vm || gravity_vm_ismini(vm)) return;
     gravity_vm_setvalue(vm, MATH_CLASS_NAME, VALUE_FROM_OBJECT(gravity_class_math));
     gravity_vm_setvalue(vm, MATH_CLASS_NAME, VALUE_FROM_OBJECT(gravity_class_math));
 }
 }
 
 
 void gravity_math_free (void) {
 void gravity_math_free (void) {
     if (!gravity_class_math) return;
     if (!gravity_class_math) return;
-    
+
     --refcount;
     --refcount;
     if (refcount) return;
     if (refcount) return;
-    
+
     mem_check(false);
     mem_check(false);
     gravity_class_t *meta = gravity_class_get_meta(gravity_class_math);
     gravity_class_t *meta = gravity_class_get_meta(gravity_class_math);
     computed_property_free(meta, "PI", true);
     computed_property_free(meta, "PI", true);
@@ -784,7 +784,7 @@ void gravity_math_free (void) {
     gravity_class_free_core(NULL, meta);
     gravity_class_free_core(NULL, meta);
     gravity_class_free_core(NULL, gravity_class_math);
     gravity_class_free_core(NULL, gravity_class_math);
     mem_check(true);
     mem_check(true);
-    
+
     gravity_class_math = NULL;
     gravity_class_math = NULL;
 }
 }
 
 

File diff suppressed because it is too large
+ 154 - 154
src/runtime/gravity_core.c


+ 1 - 1
src/runtime/gravity_core.h

@@ -31,7 +31,7 @@ gravity_value_t convert_value2string (gravity_vm *vm, gravity_value_t v);
 // internal functions
 // internal functions
 gravity_closure_t *computed_property_create (gravity_vm *vm, gravity_function_t *getter_func, gravity_function_t *setter_func);
 gravity_closure_t *computed_property_create (gravity_vm *vm, gravity_function_t *getter_func, gravity_function_t *setter_func);
 void              computed_property_free (gravity_class_t *c, const char *name, bool remove_flag);
 void              computed_property_free (gravity_class_t *c, const char *name, bool remove_flag);
-    
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

File diff suppressed because it is too large
+ 176 - 176
src/runtime/gravity_vm.c


+ 1 - 1
src/runtime/gravity_vm.h

@@ -43,7 +43,7 @@ GRAVITY_API gravity_value_t		gravity_vm_keyindex (gravity_vm *vm, uint32_t index
 GRAVITY_API bool				gravity_vm_isaborted (gravity_vm *vm);
 GRAVITY_API bool				gravity_vm_isaborted (gravity_vm *vm);
 GRAVITY_API void				gravity_vm_setaborted (gravity_vm *vm);
 GRAVITY_API void				gravity_vm_setaborted (gravity_vm *vm);
 GRAVITY_API gravity_closure_t   *gravity_vm_getclosure (gravity_vm *vm);
 GRAVITY_API gravity_closure_t   *gravity_vm_getclosure (gravity_vm *vm);
-    
+
 
 
 GRAVITY_API void				gravity_gray_value (gravity_vm* vm, gravity_value_t v);
 GRAVITY_API void				gravity_gray_value (gravity_vm* vm, gravity_value_t v);
 GRAVITY_API void				gravity_gray_object (gravity_vm* vm, gravity_object_t *obj);
 GRAVITY_API void				gravity_gray_object (gravity_vm* vm, gravity_object_t *obj);

+ 1 - 1
src/shared/gravity_array.h

@@ -9,7 +9,7 @@
 #ifndef __GRAVITY_MUTABLE_ARRAY__
 #ifndef __GRAVITY_MUTABLE_ARRAY__
 #define __GRAVITY_MUTABLE_ARRAY__
 #define __GRAVITY_MUTABLE_ARRAY__
 
 
-#include <stdint.h> 
+#include <stdint.h>
 
 
 // Inspired by https://github.com/attractivechaos/klib/blob/master/kvec.h
 // Inspired by https://github.com/attractivechaos/klib/blob/master/kvec.h
 
 

+ 2 - 2
src/shared/gravity_delegate.h

@@ -54,7 +54,7 @@ typedef void				(*gravity_bridge_free) (gravity_vm *vm, gravity_object_t *obj);
 typedef struct {
 typedef struct {
 	// user data
 	// user data
 	void						*xdata;					// optional user data transparently passed between callbacks
 	void						*xdata;					// optional user data transparently passed between callbacks
-	
+
 	// callbacks
 	// callbacks
 	gravity_log_callback		log_callback;			// log reporting callback
 	gravity_log_callback		log_callback;			// log reporting callback
 	gravity_error_callback		error_callback;			// error reporting callback
 	gravity_error_callback		error_callback;			// error reporting callback
@@ -63,7 +63,7 @@ typedef struct {
 	gravity_precode_callback	precode_callback;		// called at parse time in order to give the opportunity to add custom source code
 	gravity_precode_callback	precode_callback;		// called at parse time in order to give the opportunity to add custom source code
 	gravity_loadfile_callback	loadfile_callback;		// callback to give the opportunity to load a file from an import statement
 	gravity_loadfile_callback	loadfile_callback;		// callback to give the opportunity to load a file from an import statement
 	gravity_filename_callback	filename_callback;		// called while reporting an error in order to be able to convert a fileid to a real filename
 	gravity_filename_callback	filename_callback;		// called while reporting an error in order to be able to convert a fileid to a real filename
-	
+
 	// bridge
 	// bridge
 	gravity_bridge_initinstance	bridge_initinstance;	// init class
 	gravity_bridge_initinstance	bridge_initinstance;	// init class
 	gravity_bridge_setvalue		bridge_setvalue;		// setter
 	gravity_bridge_setvalue		bridge_setvalue;		// setter

+ 47 - 47
src/shared/gravity_hash.c

@@ -34,7 +34,7 @@ struct gravity_hash_t {
 	gravity_hash_isequal_fn	isequal_fn;
 	gravity_hash_isequal_fn	isequal_fn;
 	gravity_hash_iterate_fn free_fn;
 	gravity_hash_iterate_fn free_fn;
 	void					*data;
 	void					*data;
-	
+
 	// stats
 	// stats
 	#if GRAVITYHASH_ENABLE_STATS
 	#if GRAVITYHASH_ENABLE_STATS
 	uint32_t				ncollision;
 	uint32_t				ncollision;
@@ -47,15 +47,15 @@ struct gravity_hash_t {
 /*
 /*
 	Hash algorithm used in Gravity Hash Table is DJB2 which does a pretty good job with string keys and it is fast.
 	Hash algorithm used in Gravity Hash Table is DJB2 which does a pretty good job with string keys and it is fast.
 	Original algorithm is: http://www.cse.yorku.ca/~oz/hash.html
 	Original algorithm is: http://www.cse.yorku.ca/~oz/hash.html
-	
+
 	DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
 	DJBX33A (Daniel J. Bernstein, Times 33 with Addition)
- 
+
 	This is Daniel J. Bernstein's popular `times 33' hash function as
 	This is Daniel J. Bernstein's popular `times 33' hash function as
 	posted by him years ago on comp.lang.c. It basically uses a function
 	posted by him years ago on comp.lang.c. It basically uses a function
 	like ``hash(i) = hash(i-1) 	33 + str[i]''. This is one of the best
 	like ``hash(i) = hash(i-1) 	33 + str[i]''. This is one of the best
 	known hash functions for strings. Because it is both computed very
 	known hash functions for strings. Because it is both computed very
 	fast and distributes very well.
 	fast and distributes very well.
-	
+
 	Why 33? (<< 5 in the code)
 	Why 33? (<< 5 in the code)
 	The magic of number 33, i.e. why it works better than many other
 	The magic of number 33, i.e. why it works better than many other
 	constants, prime or not, has never been adequately explained by
 	constants, prime or not, has never been adequately explained by
@@ -65,7 +65,7 @@ struct gravity_hash_t {
 	(except for the number 1) work more or less all equally well. They
 	(except for the number 1) work more or less all equally well. They
 	all distribute in an acceptable way and this way fill a hash table
 	all distribute in an acceptable way and this way fill a hash table
 	with an average percent of approx. 86%.
 	with an average percent of approx. 86%.
-	
+
 	If one compares the Chi^2 values of the variants, the number 33 not
 	If one compares the Chi^2 values of the variants, the number 33 not
 	even has the best value. But the number 33 and a few other equally
 	even has the best value. But the number 33 and a few other equally
 	good numbers like 17, 31, 63, 127 and 129 have nevertheless a great
 	good numbers like 17, 31, 63, 127 and 129 have nevertheless a great
@@ -76,19 +76,19 @@ struct gravity_hash_t {
 	distribute good _and_ has to be very fast to compute, those few
 	distribute good _and_ has to be very fast to compute, those few
 	numbers should be preferred and seems to be the reason why Daniel J.
 	numbers should be preferred and seems to be the reason why Daniel J.
 	Bernstein also preferred it.
 	Bernstein also preferred it.
- 
+
 	Why 5381?
 	Why 5381?
 	1. odd number
 	1. odd number
 	2. prime number
 	2. prime number
 	3. deficient number (https://en.wikipedia.org/wiki/Deficient_number)
 	3. deficient number (https://en.wikipedia.org/wiki/Deficient_number)
 	4. 001/010/100/000/101 b
 	4. 001/010/100/000/101 b
-	
+
 	Practically any good multiplier works. I think you're worrying about
 	Practically any good multiplier works. I think you're worrying about
 	the fact that 31c + d doesn't cover any reasonable range of hash values
 	the fact that 31c + d doesn't cover any reasonable range of hash values
 	if c and d are between 0 and 255. That's why, when I discovered the 33 hash
 	if c and d are between 0 and 255. That's why, when I discovered the 33 hash
 	function and started using it in my compressors, I started with a hash value
 	function and started using it in my compressors, I started with a hash value
 	of 5381. I think you'll find that this does just as well as a 261 multiplier.
 	of 5381. I think you'll find that this does just as well as a 261 multiplier.
- 
+
 	Note that the starting value of the hash (5381) makes no difference for strings
 	Note that the starting value of the hash (5381) makes no difference for strings
 	of equal lengths, but will play a role in generating different hash values for
 	of equal lengths, but will play a role in generating different hash values for
 	strings of different lengths.
 	strings of different lengths.
@@ -107,9 +107,9 @@ static inline uint32_t murmur3_32 (const char *key, uint32_t len, uint32_t seed)
 	static const uint32_t r2 = 13;
 	static const uint32_t r2 = 13;
 	static const uint32_t m = 5;
 	static const uint32_t m = 5;
 	static const uint32_t n = 0xe6546b64;
 	static const uint32_t n = 0xe6546b64;
-	
+
 	uint32_t hash = seed;
 	uint32_t hash = seed;
-	
+
 	const int nblocks = len / 4;
 	const int nblocks = len / 4;
 	const uint32_t *blocks = (const uint32_t *) key;
 	const uint32_t *blocks = (const uint32_t *) key;
 	for (int i = 0; i < nblocks; i++) {
 	for (int i = 0; i < nblocks; i++) {
@@ -117,14 +117,14 @@ static inline uint32_t murmur3_32 (const char *key, uint32_t len, uint32_t seed)
 		k *= c1;
 		k *= c1;
 		k = ROT32(k, r1);
 		k = ROT32(k, r1);
 		k *= c2;
 		k *= c2;
-		
+
 		hash ^= k;
 		hash ^= k;
 		hash = ROT32(hash, r2) * m + n;
 		hash = ROT32(hash, r2) * m + n;
 	}
 	}
-	
+
 	const uint8_t *tail = (const uint8_t *) (key + nblocks * 4);
 	const uint8_t *tail = (const uint8_t *) (key + nblocks * 4);
 	uint32_t k1 = 0;
 	uint32_t k1 = 0;
-	
+
 	switch (len & 3) {
 	switch (len & 3) {
 		case 3:
 		case 3:
 			k1 ^= tail[2] << 16;
 			k1 ^= tail[2] << 16;
@@ -132,20 +132,20 @@ static inline uint32_t murmur3_32 (const char *key, uint32_t len, uint32_t seed)
 			k1 ^= tail[1] << 8;
 			k1 ^= tail[1] << 8;
 		case 1:
 		case 1:
 			k1 ^= tail[0];
 			k1 ^= tail[0];
-			
+
 			k1 *= c1;
 			k1 *= c1;
 			k1 = ROT32(k1, r1);
 			k1 = ROT32(k1, r1);
 			k1 *= c2;
 			k1 *= c2;
 			hash ^= k1;
 			hash ^= k1;
 	}
 	}
-	
+
 	hash ^= len;
 	hash ^= len;
 	hash ^= (hash >> 16);
 	hash ^= (hash >> 16);
 	hash *= 0x85ebca6b;
 	hash *= 0x85ebca6b;
 	hash ^= (hash >> 13);
 	hash ^= (hash >> 13);
 	hash *= 0xc2b2ae35;
 	hash *= 0xc2b2ae35;
 	hash ^= (hash >> 16);
 	hash ^= (hash >> 16);
-	
+
 	return hash;
 	return hash;
 }
 }
 
 
@@ -161,11 +161,11 @@ static void table_dump (gravity_hash_t *hashtable, gravity_value_t key, gravity_
 gravity_hash_t *gravity_hash_create (uint32_t size, gravity_hash_compute_fn compute, gravity_hash_isequal_fn isequal, gravity_hash_iterate_fn free_fn, void *data) {
 gravity_hash_t *gravity_hash_create (uint32_t size, gravity_hash_compute_fn compute, gravity_hash_isequal_fn isequal, gravity_hash_iterate_fn free_fn, void *data) {
 	if ((!compute) || (!isequal)) return NULL;
 	if ((!compute) || (!isequal)) return NULL;
 	if (size == 0) size = GRAVITYHASH_DEFAULT_SIZE;
 	if (size == 0) size = GRAVITYHASH_DEFAULT_SIZE;
-	
+
 	gravity_hash_t *hashtable = (gravity_hash_t *)mem_alloc(sizeof(gravity_hash_t));
 	gravity_hash_t *hashtable = (gravity_hash_t *)mem_alloc(sizeof(gravity_hash_t));
 	if (!hashtable) return NULL;
 	if (!hashtable) return NULL;
 	if (!(hashtable->nodes = mem_calloc(size, sizeof(hash_node_t*)))) {mem_free(hashtable); return NULL;}
 	if (!(hashtable->nodes = mem_calloc(size, sizeof(hash_node_t*)))) {mem_free(hashtable); return NULL;}
-	
+
 	hashtable->compute_fn = compute;
 	hashtable->compute_fn = compute;
 	hashtable->isequal_fn = isequal;
 	hashtable->isequal_fn = isequal;
 	hashtable->free_fn = free_fn;
 	hashtable->free_fn = free_fn;
@@ -177,7 +177,7 @@ gravity_hash_t *gravity_hash_create (uint32_t size, gravity_hash_compute_fn comp
 void gravity_hash_free (gravity_hash_t *hashtable) {
 void gravity_hash_free (gravity_hash_t *hashtable) {
 	if (!hashtable) return;
 	if (!hashtable) return;
 	gravity_hash_iterate_fn free_fn = hashtable->free_fn;
 	gravity_hash_iterate_fn free_fn = hashtable->free_fn;
-	
+
 	for (uint32_t n = 0; n < hashtable->size; ++n) {
 	for (uint32_t n = 0; n < hashtable->size; ++n) {
 		hash_node_t *node = hashtable->nodes[n];
 		hash_node_t *node = hashtable->nodes[n];
         hashtable->nodes[n] = NULL;
         hashtable->nodes[n] = NULL;
@@ -212,7 +212,7 @@ static inline int gravity_hash_resize (gravity_hash_t *hashtable) {
 		.compute_fn = hashtable->compute_fn
 		.compute_fn = hashtable->compute_fn
 	};
 	};
 	if (!(newtbl.nodes = mem_calloc(size, sizeof(hash_node_t*)))) return -1;
 	if (!(newtbl.nodes = mem_calloc(size, sizeof(hash_node_t*)))) return -1;
-	
+
 	hash_node_t *node, *next;
 	hash_node_t *node, *next;
 	for (uint32_t n = 0; n < hashtable->size; ++n) {
 	for (uint32_t n = 0; n < hashtable->size; ++n) {
 		for (node = hashtable->nodes[n]; node; node = next) {
 		for (node = hashtable->nodes[n]; node; node = next) {
@@ -226,20 +226,20 @@ static inline int gravity_hash_resize (gravity_hash_t *hashtable) {
 			hashtable->free_fn = free_fn;
 			hashtable->free_fn = free_fn;
 		}
 		}
 	}
 	}
-	
+
 	mem_free(hashtable->nodes);
 	mem_free(hashtable->nodes);
 	hashtable->size = newtbl.size;
 	hashtable->size = newtbl.size;
 	hashtable->count = newtbl.count;
 	hashtable->count = newtbl.count;
 	hashtable->nodes = newtbl.nodes;
 	hashtable->nodes = newtbl.nodes;
 	INC_RESIZE(hashtable);
 	INC_RESIZE(hashtable);
-	
+
 	return 0;
 	return 0;
 }
 }
 
 
 bool gravity_hash_remove (gravity_hash_t *hashtable, gravity_value_t key) {
 bool gravity_hash_remove (gravity_hash_t *hashtable, gravity_value_t key) {
 	register uint32_t hash = hashtable->compute_fn(key);
 	register uint32_t hash = hashtable->compute_fn(key);
 	register uint32_t position = hash % hashtable->size;
 	register uint32_t position = hash % hashtable->size;
-	
+
 	gravity_hash_iterate_fn free_fn = hashtable->free_fn;
 	gravity_hash_iterate_fn free_fn = hashtable->free_fn;
 	hash_node_t *node = hashtable->nodes[position];
 	hash_node_t *node = hashtable->nodes[position];
 	hash_node_t *prevnode = NULL;
 	hash_node_t *prevnode = NULL;
@@ -252,21 +252,21 @@ bool gravity_hash_remove (gravity_hash_t *hashtable, gravity_value_t key) {
 			hashtable->count--;
 			hashtable->count--;
 			return true;
 			return true;
 		}
 		}
-		
+
 		prevnode = node;
 		prevnode = node;
 		node = node->next;
 		node = node->next;
 	}
 	}
-	
+
 	return false;
 	return false;
 }
 }
 
 
 bool gravity_hash_insert (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value) {
 bool gravity_hash_insert (gravity_hash_t *hashtable, gravity_value_t key, gravity_value_t value) {
 	register uint32_t hash = hashtable->compute_fn(key);
 	register uint32_t hash = hashtable->compute_fn(key);
 	register uint32_t position = hash % hashtable->size;
 	register uint32_t position = hash % hashtable->size;
-	
+
 	hash_node_t *node = hashtable->nodes[position];
 	hash_node_t *node = hashtable->nodes[position];
 	if (node) INC_COLLISION(hashtable);
 	if (node) INC_COLLISION(hashtable);
-	
+
 	// check if the key is already in the table
 	// check if the key is already in the table
 	while (node) {
 	while (node) {
 		if ((node->hash == hash) && (hashtable->isequal_fn(key, node->key))) {
 		if ((node->hash == hash) && (hashtable->isequal_fn(key, node->key))) {
@@ -275,7 +275,7 @@ bool gravity_hash_insert (gravity_hash_t *hashtable, gravity_value_t key, gravit
 		}
 		}
 		node = node->next;
 		node = node->next;
 	}
 	}
-	
+
 	// resize table if the threshold is exceeded
 	// resize table if the threshold is exceeded
 	// default threshold is: <table size> * <load factor GRAVITYHASH_THRESHOLD>
 	// default threshold is: <table size> * <load factor GRAVITYHASH_THRESHOLD>
 	if (hashtable->count >= hashtable->size * GRAVITYHASH_THRESHOLD) {
 	if (hashtable->count >= hashtable->size * GRAVITYHASH_THRESHOLD) {
@@ -283,7 +283,7 @@ bool gravity_hash_insert (gravity_hash_t *hashtable, gravity_value_t key, gravit
 		// recompute position here because hashtable->size has changed!
 		// recompute position here because hashtable->size has changed!
 		position = hash % hashtable->size;
 		position = hash % hashtable->size;
 	}
 	}
-	
+
 	// allocate new entry and set new data
 	// allocate new entry and set new data
 	if (!(node = mem_alloc(sizeof(hash_node_t)))) return -1;
 	if (!(node = mem_alloc(sizeof(hash_node_t)))) return -1;
 	node->key = key;
 	node->key = key;
@@ -292,20 +292,20 @@ bool gravity_hash_insert (gravity_hash_t *hashtable, gravity_value_t key, gravit
 	node->next = hashtable->nodes[position];
 	node->next = hashtable->nodes[position];
 	hashtable->nodes[position] = node;
 	hashtable->nodes[position] = node;
 	++hashtable->count;
 	++hashtable->count;
-	
+
 	return true;
 	return true;
 }
 }
 
 
 gravity_value_t *gravity_hash_lookup (gravity_hash_t *hashtable, gravity_value_t key) {
 gravity_value_t *gravity_hash_lookup (gravity_hash_t *hashtable, gravity_value_t key) {
 	register uint32_t hash = hashtable->compute_fn(key);
 	register uint32_t hash = hashtable->compute_fn(key);
 	register uint32_t position = hash % hashtable->size;
 	register uint32_t position = hash % hashtable->size;
-	
+
 	hash_node_t *node = hashtable->nodes[position];
 	hash_node_t *node = hashtable->nodes[position];
 	while (node) {
 	while (node) {
 		if ((node->hash == hash) && (hashtable->isequal_fn(key, node->key))) return &node->value;
 		if ((node->hash == hash) && (hashtable->isequal_fn(key, node->key))) return &node->value;
 		node = node->next;
 		node = node->next;
 	}
 	}
-	
+
 	return NULL;
 	return NULL;
 }
 }
 
 
@@ -347,11 +347,11 @@ void gravity_hash_stat (gravity_hash_t *hashtable) {
 
 
 void gravity_hash_transform (gravity_hash_t *hashtable, gravity_hash_transform_fn transform, void *data) {
 void gravity_hash_transform (gravity_hash_t *hashtable, gravity_hash_transform_fn transform, void *data) {
 	if ((!hashtable) || (!transform)) return;
 	if ((!hashtable) || (!transform)) return;
-	
+
 	for (uint32_t i=0; i<hashtable->size; ++i) {
 	for (uint32_t i=0; i<hashtable->size; ++i) {
 		hash_node_t *node = hashtable->nodes[i];
 		hash_node_t *node = hashtable->nodes[i];
 		if (!node) continue;
 		if (!node) continue;
-		
+
 		while (node) {
 		while (node) {
 			transform(hashtable, node->key, &node->value, data);
 			transform(hashtable, node->key, &node->value, data);
 			node = node->next;
 			node = node->next;
@@ -361,11 +361,11 @@ void gravity_hash_transform (gravity_hash_t *hashtable, gravity_hash_transform_f
 
 
 void gravity_hash_iterate (gravity_hash_t *hashtable, gravity_hash_iterate_fn iterate, void *data) {
 void gravity_hash_iterate (gravity_hash_t *hashtable, gravity_hash_iterate_fn iterate, void *data) {
 	if ((!hashtable) || (!iterate)) return;
 	if ((!hashtable) || (!iterate)) return;
-	
+
 	for (uint32_t i=0; i<hashtable->size; ++i) {
 	for (uint32_t i=0; i<hashtable->size; ++i) {
 		hash_node_t *node = hashtable->nodes[i];
 		hash_node_t *node = hashtable->nodes[i];
 		if (!node) continue;
 		if (!node) continue;
-		
+
 		while (node) {
 		while (node) {
 			iterate(hashtable, node->key, node->value, data);
 			iterate(hashtable, node->key, node->value, data);
 			node = node->next;
 			node = node->next;
@@ -375,11 +375,11 @@ void gravity_hash_iterate (gravity_hash_t *hashtable, gravity_hash_iterate_fn it
 
 
 void gravity_hash_iterate2 (gravity_hash_t *hashtable, gravity_hash_iterate2_fn iterate, void *data1, void *data2) {
 void gravity_hash_iterate2 (gravity_hash_t *hashtable, gravity_hash_iterate2_fn iterate, void *data1, void *data2) {
 	if ((!hashtable) || (!iterate)) return;
 	if ((!hashtable) || (!iterate)) return;
-	
+
 	for (uint32_t i=0; i<hashtable->size; ++i) {
 	for (uint32_t i=0; i<hashtable->size; ++i) {
 		hash_node_t *node = hashtable->nodes[i];
 		hash_node_t *node = hashtable->nodes[i];
 		if (!node) continue;
 		if (!node) continue;
-		
+
 		while (node) {
 		while (node) {
 			iterate(hashtable, node->key, node->value, data1, data2);
 			iterate(hashtable, node->key, node->value, data1, data2);
 			node = node->next;
 			node = node->next;
@@ -395,7 +395,7 @@ void gravity_hash_append (gravity_hash_t *hashtable1, gravity_hash_t *hashtable2
 	for (uint32_t i=0; i<hashtable2->size; ++i) {
 	for (uint32_t i=0; i<hashtable2->size; ++i) {
 		hash_node_t *node = hashtable2->nodes[i];
 		hash_node_t *node = hashtable2->nodes[i];
 		if (!node) continue;
 		if (!node) continue;
-		
+
 		while (node) {
 		while (node) {
 			gravity_hash_insert(hashtable1, node->key, node->value);
 			gravity_hash_insert(hashtable1, node->key, node->value);
 			node = node->next;
 			node = node->next;
@@ -410,7 +410,7 @@ void gravity_hash_resetfree (gravity_hash_t *hashtable) {
 bool gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable2, gravity_hash_compare_fn compare, void *data) {
 bool gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable2, gravity_hash_compare_fn compare, void *data) {
     if (hashtable1->count != hashtable2->count) return false;
     if (hashtable1->count != hashtable2->count) return false;
     if (!compare) return false;
     if (!compare) return false;
-    
+
     // 1. allocate arrays of keys and values
     // 1. allocate arrays of keys and values
     gravity_value_r keys1; gravity_value_r values1;
     gravity_value_r keys1; gravity_value_r values1;
     gravity_value_r keys2; gravity_value_r values2;
     gravity_value_r keys2; gravity_value_r values2;
@@ -420,7 +420,7 @@ bool gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable
     marray_resize(gravity_value_t, keys2, hashtable1->count + MARRAY_DEFAULT_SIZE);
     marray_resize(gravity_value_t, keys2, hashtable1->count + MARRAY_DEFAULT_SIZE);
     marray_resize(gravity_value_t, values1, hashtable1->count + MARRAY_DEFAULT_SIZE);
     marray_resize(gravity_value_t, values1, hashtable1->count + MARRAY_DEFAULT_SIZE);
     marray_resize(gravity_value_t, values2, hashtable1->count + MARRAY_DEFAULT_SIZE);
     marray_resize(gravity_value_t, values2, hashtable1->count + MARRAY_DEFAULT_SIZE);
-    
+
     // 2. build arrays of keys and values for hashtable1
     // 2. build arrays of keys and values for hashtable1
     for (uint32_t i=0; i<hashtable1->size; ++i) {
     for (uint32_t i=0; i<hashtable1->size; ++i) {
         hash_node_t *node = hashtable1->nodes[i];
         hash_node_t *node = hashtable1->nodes[i];
@@ -431,7 +431,7 @@ bool gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable
             node = node->next;
             node = node->next;
         }
         }
     }
     }
-    
+
     // 3. build arrays of keys and values for hashtable2
     // 3. build arrays of keys and values for hashtable2
     for (uint32_t i=0; i<hashtable2->size; ++i) {
     for (uint32_t i=0; i<hashtable2->size; ++i) {
         hash_node_t *node = hashtable2->nodes[i];
         hash_node_t *node = hashtable2->nodes[i];
@@ -442,25 +442,25 @@ bool gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable
             node = node->next;
             node = node->next;
         }
         }
     }
     }
-    
+
     // sanity check
     // sanity check
     bool result = false;
     bool result = false;
     uint32_t count = (uint32_t)marray_size(keys1);
     uint32_t count = (uint32_t)marray_size(keys1);
     if (count != (uint32_t)marray_size(keys2)) goto cleanup;
     if (count != (uint32_t)marray_size(keys2)) goto cleanup;
-    
+
     // 4. compare keys and values
     // 4. compare keys and values
     for (uint32_t i=0; i<count; ++i) {
     for (uint32_t i=0; i<count; ++i) {
         if (!compare(marray_get(keys1, i), marray_get(keys2, i), data)) goto cleanup;
         if (!compare(marray_get(keys1, i), marray_get(keys2, i), data)) goto cleanup;
         if (!compare(marray_get(values1, i), marray_get(values2, i), data)) goto cleanup;
         if (!compare(marray_get(values1, i), marray_get(values2, i), data)) goto cleanup;
     }
     }
-    
+
     result = true;
     result = true;
-    
+
 cleanup:
 cleanup:
     marray_destroy(keys1);
     marray_destroy(keys1);
     marray_destroy(keys2);
     marray_destroy(keys2);
     marray_destroy(values1);
     marray_destroy(values1);
     marray_destroy(values2);
     marray_destroy(values2);
-    
+
     return result;
     return result;
 }
 }

+ 1 - 1
src/shared/gravity_hash.h

@@ -59,7 +59,7 @@ GRAVITY_API void				gravity_hash_append (gravity_hash_t *hashtable1, gravity_has
 GRAVITY_API void				gravity_hash_resetfree (gravity_hash_t *hashtable);
 GRAVITY_API void				gravity_hash_resetfree (gravity_hash_t *hashtable);
 
 
 GRAVITY_API bool                gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable2, gravity_hash_compare_fn compare, void *data);
 GRAVITY_API bool                gravity_hash_compare (gravity_hash_t *hashtable1, gravity_hash_t *hashtable2, gravity_hash_compare_fn compare, void *data);
-    
+
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }
 #endif
 #endif

+ 28 - 28
src/shared/gravity_memory.c

@@ -37,11 +37,11 @@ typedef struct {
 	void					*ptr;
 	void					*ptr;
 	size_t					size;
 	size_t					size;
 	size_t					nrealloc;
 	size_t					nrealloc;
-	
+
 	// record where it has been allocated/reallocated
 	// record where it has been allocated/reallocated
 	size_t					nframe;
 	size_t					nframe;
 	char					**frames;
 	char					**frames;
-	
+
 	// record where is has been freed
 	// record where is has been freed
 	size_t					nframe2;
 	size_t					nframe2;
 	char					**frames2;
 	char					**frames2;
@@ -67,28 +67,28 @@ static void memdebug_report (char *str, char **stack, size_t nstack, memslot *sl
 		if (_is_internal(stack[i])) continue;
 		if (_is_internal(stack[i])) continue;
 		printf("%s\n", stack[i]);
 		printf("%s\n", stack[i]);
 	}
 	}
-	
+
 	if (slot) {
 	if (slot) {
 		printf("\nallocated:\n");
 		printf("\nallocated:\n");
 		for (size_t i=0; i<slot->nframe; ++i) {
 		for (size_t i=0; i<slot->nframe; ++i) {
 			if (_is_internal(slot->frames[i])) continue;
 			if (_is_internal(slot->frames[i])) continue;
 			printf("%s\n", slot->frames[i]);
 			printf("%s\n", slot->frames[i]);
 		}
 		}
-		
+
 		printf("\nfreed:\n");
 		printf("\nfreed:\n");
 		for (size_t i=0; i<slot->nframe2; ++i) {
 		for (size_t i=0; i<slot->nframe2; ++i) {
 			if (_is_internal(slot->frames2[i])) continue;
 			if (_is_internal(slot->frames2[i])) continue;
 			printf("%s\n", slot->frames2[i]);
 			printf("%s\n", slot->frames2[i]);
 		}
 		}
 	}
 	}
-	
+
 	abort();
 	abort();
 }
 }
 
 
 void memdebug_init (void) {
 void memdebug_init (void) {
 	if (memdebug.slot) free(memdebug.slot);
 	if (memdebug.slot) free(memdebug.slot);
 	bzero(&memdebug, sizeof(_memdebug));
 	bzero(&memdebug, sizeof(_memdebug));
-	
+
 	memdebug.slot = (memslot *) malloc(sizeof(memslot) * SLOT_MIN);
 	memdebug.slot = (memslot *) malloc(sizeof(memslot) * SLOT_MIN);
 	memdebug.aslot = SLOT_MIN;
 	memdebug.aslot = SLOT_MIN;
 }
 }
@@ -101,7 +101,7 @@ void *memdebug_malloc(size_t size) {
 		memdebug_report(current_error, stack, n, NULL);
 		memdebug_report(current_error, stack, n, NULL);
 		return NULL;
 		return NULL;
 	}
 	}
-	
+
 	_ptr_add(ptr, size);
 	_ptr_add(ptr, size);
 	return ptr;
 	return ptr;
 }
 }
@@ -118,7 +118,7 @@ void *memdebug_calloc(size_t num, size_t size) {
 		memdebug_report(current_error, stack, n, NULL);
 		memdebug_report(current_error, stack, n, NULL);
 		return NULL;
 		return NULL;
 	}
 	}
-	
+
 	_ptr_add(ptr, num*size);
 	_ptr_add(ptr, num*size);
 	return ptr;
 	return ptr;
 }
 }
@@ -132,7 +132,7 @@ void *memdebug_realloc(void *ptr, size_t new_size) {
 		memdebug_report(current_error, stack, n, NULL);
 		memdebug_report(current_error, stack, n, NULL);
 		return NULL;
 		return NULL;
 	}
 	}
-	
+
 	void *new_ptr = realloc(ptr, new_size);
 	void *new_ptr = realloc(ptr, new_size);
 	if (!ptr) {
 	if (!ptr) {
 		BUILD_ERROR("Unable to reallocate a block of %zu bytes", new_size);
 		BUILD_ERROR("Unable to reallocate a block of %zu bytes", new_size);
@@ -140,7 +140,7 @@ void *memdebug_realloc(void *ptr, size_t new_size) {
 		memdebug_report(current_error, stack, n, &memdebug.slot[index]);
 		memdebug_report(current_error, stack, n, &memdebug.slot[index]);
 		return NULL;
 		return NULL;
 	}
 	}
-	
+
 	_ptr_replace(ptr, new_ptr, new_size);
 	_ptr_replace(ptr, new_ptr, new_size);
 	return new_ptr;
 	return new_ptr;
 }
 }
@@ -155,7 +155,7 @@ bool memdebug_remove(void *ptr) {
 			memdebug_report(current_error, stack, n, NULL);
 			memdebug_report(current_error, stack, n, NULL);
 			return false;
 			return false;
 		}
 		}
-		
+
 		memslot m = memdebug.slot[index];
 		memslot m = memdebug.slot[index];
 		if (m.deleted) {
 		if (m.deleted) {
 			BUILD_ERROR("Pointer already freed");
 			BUILD_ERROR("Pointer already freed");
@@ -164,7 +164,7 @@ bool memdebug_remove(void *ptr) {
 			return false;
 			return false;
 		}
 		}
 	}
 	}
-	
+
 	_ptr_remove(ptr);
 	_ptr_remove(ptr);
 	return true;
 	return true;
 }
 }
@@ -185,13 +185,13 @@ void memdebug_stat(void) {
 	printf("Leaked: %d (bytes)\n", memdebug.currmem);
 	printf("Leaked: %d (bytes)\n", memdebug.currmem);
 	printf("Max memory usage: %d (bytes)\n", memdebug.maxmem);
 	printf("Max memory usage: %d (bytes)\n", memdebug.maxmem);
 	printf("==================================\n\n");
 	printf("==================================\n\n");
-	
+
 	if (memdebug.currmem > 0) {
 	if (memdebug.currmem > 0) {
 		printf("\n");
 		printf("\n");
 		for (uint32_t i=0; i<memdebug.nslot; ++i) {
 		for (uint32_t i=0; i<memdebug.nslot; ++i) {
 			memslot m = memdebug.slot[i];
 			memslot m = memdebug.slot[i];
 			if ((!m.ptr) || (m.deleted)) continue;
 			if ((!m.ptr) || (m.deleted)) continue;
-						
+
 			printf("Block %p size: %zu (reallocated %zu)\n", m.ptr, m.size, m.nrealloc);
 			printf("Block %p size: %zu (reallocated %zu)\n", m.ptr, m.size, m.nrealloc);
 			printf("Call stack:\n");
 			printf("Call stack:\n");
 			printf("===========\n");
 			printf("===========\n");
@@ -215,7 +215,7 @@ size_t memdebug_leaks (void) {
 // Internals
 // Internals
 void _ptr_add (void *ptr, size_t size) {
 void _ptr_add (void *ptr, size_t size) {
 	CHECK_FLAG();
 	CHECK_FLAG();
-	
+
 	if (memdebug.nslot + 1 >= memdebug.aslot) {
 	if (memdebug.nslot + 1 >= memdebug.aslot) {
 		size_t old_size = sizeof(memslot) * memdebug.nslot;
 		size_t old_size = sizeof(memslot) * memdebug.nslot;
 		size_t new_size = sizeof(memslot) * SLOT_MIN;
 		size_t new_size = sizeof(memslot) * SLOT_MIN;
@@ -228,7 +228,7 @@ void _ptr_add (void *ptr, size_t size) {
 		memdebug.slot = new_slot;
 		memdebug.slot = new_slot;
 		memdebug.aslot += SLOT_MIN;
 		memdebug.aslot += SLOT_MIN;
 	}
 	}
-	
+
 	memslot slot = {
 	memslot slot = {
 		.deleted = false,
 		.deleted = false,
 		.ptr = ptr,
 		.ptr = ptr,
@@ -238,10 +238,10 @@ void _ptr_add (void *ptr, size_t size) {
 		.frames = NULL
 		.frames = NULL
 	};
 	};
 	slot.frames = _ptr_stacktrace(&slot.nframe);
 	slot.frames = _ptr_stacktrace(&slot.nframe);
-		
+
 	memdebug.slot[memdebug.nslot] = slot;
 	memdebug.slot[memdebug.nslot] = slot;
 	++memdebug.nslot;
 	++memdebug.nslot;
-	
+
 	++memdebug.nalloc;
 	++memdebug.nalloc;
 	memdebug.currmem += size;
 	memdebug.currmem += size;
 	if (memdebug.currmem > memdebug.maxmem)
 	if (memdebug.currmem > memdebug.maxmem)
@@ -250,14 +250,14 @@ void _ptr_add (void *ptr, size_t size) {
 
 
 void _ptr_replace (void *old_ptr, void *new_ptr, size_t new_size) {
 void _ptr_replace (void *old_ptr, void *new_ptr, size_t new_size) {
 	CHECK_FLAG();
 	CHECK_FLAG();
-	
+
 	uint32_t index = _ptr_lookup(old_ptr);
 	uint32_t index = _ptr_lookup(old_ptr);
-	
+
 	if (index == SLOT_NOTFOUND) {
 	if (index == SLOT_NOTFOUND) {
 		BUILD_ERROR("Unable to find old pointer to realloc");
 		BUILD_ERROR("Unable to find old pointer to realloc");
 		memdebug_report(current_error, NULL, 0, NULL);
 		memdebug_report(current_error, NULL, 0, NULL);
 	}
 	}
-	
+
 	memslot slot = memdebug.slot[index];
 	memslot slot = memdebug.slot[index];
 	if (slot.deleted) {
 	if (slot.deleted) {
 		BUILD_ERROR("Pointer already freed");
 		BUILD_ERROR("Pointer already freed");
@@ -270,7 +270,7 @@ void _ptr_replace (void *old_ptr, void *new_ptr, size_t new_size) {
 	if (slot.frames) free((void *)slot.frames);
 	if (slot.frames) free((void *)slot.frames);
 	slot.frames = _ptr_stacktrace(&slot.nframe);
 	slot.frames = _ptr_stacktrace(&slot.nframe);
 	++slot.nrealloc;
 	++slot.nrealloc;
-	
+
 	memdebug.slot[index] = slot;
 	memdebug.slot[index] = slot;
 	++memdebug.nrealloc;
 	++memdebug.nrealloc;
 	memdebug.currmem += (new_size - old_size);
 	memdebug.currmem += (new_size - old_size);
@@ -280,25 +280,25 @@ void _ptr_replace (void *old_ptr, void *new_ptr, size_t new_size) {
 
 
 void _ptr_remove (void *ptr) {
 void _ptr_remove (void *ptr) {
 	CHECK_FLAG();
 	CHECK_FLAG();
-	
+
 	uint32_t index = _ptr_lookup(ptr);
 	uint32_t index = _ptr_lookup(ptr);
-	
+
 	if (index == SLOT_NOTFOUND) {
 	if (index == SLOT_NOTFOUND) {
 		BUILD_ERROR("Unable to find old pointer to realloc");
 		BUILD_ERROR("Unable to find old pointer to realloc");
 		memdebug_report(current_error, NULL, 0, NULL);
 		memdebug_report(current_error, NULL, 0, NULL);
 	}
 	}
-	
+
 	memslot slot = memdebug.slot[index];
 	memslot slot = memdebug.slot[index];
 	if (slot.deleted) {
 	if (slot.deleted) {
 		BUILD_ERROR("Pointer already freed");
 		BUILD_ERROR("Pointer already freed");
 		BUILD_STACK(n, stack);
 		BUILD_STACK(n, stack);
 		memdebug_report(current_error, stack, n, &slot);
 		memdebug_report(current_error, stack, n, &slot);
 	}
 	}
-	
+
 	size_t old_size = memdebug.slot[index].size;
 	size_t old_size = memdebug.slot[index].size;
 	memdebug.slot[index].deleted = true;
 	memdebug.slot[index].deleted = true;
 	memdebug.slot[index].frames2 = _ptr_stacktrace(&memdebug.slot[index].nframe2);
 	memdebug.slot[index].frames2 = _ptr_stacktrace(&memdebug.slot[index].nframe2);
-	
+
 	++memdebug.nfree;
 	++memdebug.nfree;
 	memdebug.currmem -= old_size;
 	memdebug.currmem -= old_size;
 }
 }
@@ -326,7 +326,7 @@ char **_ptr_stacktrace (size_t *nframes) {
 // Default callback
 // Default callback
 bool _is_internal(const char *s) {
 bool _is_internal(const char *s) {
 	static const char *reserved[] = {"??? ", "libdyld.dylib ", "memdebug_", "_ptr_", NULL};
 	static const char *reserved[] = {"??? ", "libdyld.dylib ", "memdebug_", "_ptr_", NULL};
-	
+
 	const char **r = reserved;
 	const char **r = reserved;
 	while (*r) {
 	while (*r) {
 		if (strstr(s, *r)) return true;
 		if (strstr(s, *r)) return true;

+ 13 - 13
src/shared/gravity_opcodes.h

@@ -11,7 +11,7 @@
 
 
 /*
 /*
 		Big-endian vs Little-endian machines
 		Big-endian vs Little-endian machines
- 
+
 		ARM architecture runs both little & big endianess, but the android, iOS, and windows phone platforms run little endian.
 		ARM architecture runs both little & big endianess, but the android, iOS, and windows phone platforms run little endian.
 		95% of modern desktop computers are little-endian.
 		95% of modern desktop computers are little-endian.
 		All x86 desktops (which is nearly all desktops with the demise of the PowerPC-based Macs several years ago) are little-endian.
 		All x86 desktops (which is nearly all desktops with the demise of the PowerPC-based Macs several years ago) are little-endian.
@@ -22,22 +22,22 @@
 
 
 /*
 /*
 		Instructions are 32bit in lenght
 		Instructions are 32bit in lenght
- 
+
 		// 2 registers and 1 register/constant
 		// 2 registers and 1 register/constant
 		+------------------------------------+
 		+------------------------------------+
 		|  OP  |   Ax   |   Bx   |    Cx/K   |
 		|  OP  |   Ax   |   Bx   |    Cx/K   |
 		+------------------------------------+
 		+------------------------------------+
- 
+
 		// instructions with no parameters
 		// instructions with no parameters
 		+------------------------------------+
 		+------------------------------------+
 		|  OP  |0                            |
 		|  OP  |0                            |
 		+------------------------------------+
 		+------------------------------------+
- 
+
 		// unconditional JUMP
 		// unconditional JUMP
 		+------------------------------------+
 		+------------------------------------+
 		|  OP  |             N1              |
 		|  OP  |             N1              |
 		+------------------------------------+
 		+------------------------------------+
- 
+
 		// LOADI and JUMPF
 		// LOADI and JUMPF
 		+------------------------------------+
 		+------------------------------------+
 		|  OP  |   Ax   |S|       N2         |
 		|  OP  |   Ax   |S|       N2         |
@@ -53,7 +53,7 @@
  */
  */
 
 
 typedef enum {
 typedef enum {
-	
+
 	//		****************************************************************************************************
 	//		****************************************************************************************************
 	//		56 OPCODE INSTRUCTIONS (for a register based virtual machine)
 	//		56 OPCODE INSTRUCTIONS (for a register based virtual machine)
 	//		opcode is a 6 bit value so at maximum 2^6 = 64 opcodes can be declared
 	//		opcode is a 6 bit value so at maximum 2^6 = 64 opcodes can be declared
@@ -69,7 +69,7 @@ typedef enum {
 			NOP,			//	NONE		//	NOP									http://en.wikipedia.org/wiki/NOP
 			NOP,			//	NONE		//	NOP									http://en.wikipedia.org/wiki/NOP
 			RET,			//  A			//	return from a function				R(-1) = R(A)
 			RET,			//  A			//	return from a function				R(-1) = R(A)
 			CALL,			//	A, B, C		//	call a function						R(A) = B(C0...Cn) B is callable object and C is num args
 			CALL,			//	A, B, C		//	call a function						R(A) = B(C0...Cn) B is callable object and C is num args
-	
+
 											//	*** LOAD/STORE OPERATIONS (11) ***
 											//	*** LOAD/STORE OPERATIONS (11) ***
 			LOAD,			//	A, B, C		//	load C from B and store in A		R(A) = R(B)[C]
 			LOAD,			//	A, B, C		//	load C from B and store in A		R(A) = R(B)[C]
 			LOADS,			//	A, B, C		//	load C from B and store in A		R(A) = R(B)[C] (super variant)
 			LOADS,			//	A, B, C		//	load C from B and store in A		R(A) = R(B)[C] (super variant)
@@ -83,12 +83,12 @@ typedef enum {
 			STOREAT,		//	A, B, C		//	store A into R(B)[C]				R(B)[C] = R(A)
 			STOREAT,		//	A, B, C		//	store A into R(B)[C]				R(B)[C] = R(A)
 			STOREG,			//	A, B		//	store global						G[K(B)] = R(A)
 			STOREG,			//	A, B		//	store global						G[K(B)] = R(A)
 			STOREU,			//	A, B		//	store upvalue						U(B) = R(A)
 			STOREU,			//	A, B		//	store upvalue						U(B) = R(A)
-	
+
 											//	*** JUMP OPERATIONS (3) ***
 											//	*** JUMP OPERATIONS (3) ***
 			JUMP,			//	A			//	unconditional jump					PC += A
 			JUMP,			//	A			//	unconditional jump					PC += A
 			JUMPF,			//	A, B		//	jump if R(A) is false				(R(A) == 0)	? PC += B : 0
 			JUMPF,			//	A, B		//	jump if R(A) is false				(R(A) == 0)	? PC += B : 0
 			SWITCH,			//				//	switch statement
 			SWITCH,			//				//	switch statement
-	
+
 											//	*** MATH OPERATIONS (19) ***
 											//	*** MATH OPERATIONS (19) ***
 			ADD,			//	A, B, C		//	add operation						R(A) = R(B) + R(C)
 			ADD,			//	A, B, C		//	add operation						R(A) = R(B) + R(C)
 			SUB,			//	A, B, C		//	sub operation						R(A) = R(B) - R(C)
 			SUB,			//	A, B, C		//	sub operation						R(A) = R(B) - R(C)
@@ -109,7 +109,7 @@ typedef enum {
 			MATCH,			//	A, B, C		//	=~ pattern match					R(A) = R(B) =~ R(C)
 			MATCH,			//	A, B, C		//	=~ pattern match					R(A) = R(B) =~ R(C)
 			NEG,			//	A, B		//	neg operation						R(A) = -R(B)
 			NEG,			//	A, B		//	neg operation						R(A) = -R(B)
 			NOT,			//	A, B		//	not operation						R(A) = !R(B)
 			NOT,			//	A, B		//	not operation						R(A) = !R(B)
-	
+
 											// *** BIT OPERATIONS (6) ***
 											// *** BIT OPERATIONS (6) ***
 			LSHIFT,			//	A, B, C		// shift left							R(A) = R(B) << R(C)
 			LSHIFT,			//	A, B, C		// shift left							R(A) = R(B) << R(C)
 			RSHIFT,			//	A, B, C		// shift right							R(A) = R(B) >> R(C)
 			RSHIFT,			//	A, B, C		// shift right							R(A) = R(B) >> R(C)
@@ -117,17 +117,17 @@ typedef enum {
 			BOR,			//	A, B, C		// bit or								R(A) = R(B) | R(C)
 			BOR,			//	A, B, C		// bit or								R(A) = R(B) | R(C)
 			BXOR,			//	A, B, C		// bit xor								R(A) = R(B) ^ R(C)
 			BXOR,			//	A, B, C		// bit xor								R(A) = R(B) ^ R(C)
 			BNOT,			//	A, B		// bit not								R(A) = ~R(B)
 			BNOT,			//	A, B		// bit not								R(A) = ~R(B)
-	
+
 											// *** ARRAY/MAP/RANGE OPERATIONS (4) ***
 											// *** ARRAY/MAP/RANGE OPERATIONS (4) ***
 			MAPNEW,			//	A, B		//	create a new map					R(A) = Alloc a MAP(B)
 			MAPNEW,			//	A, B		//	create a new map					R(A) = Alloc a MAP(B)
 			LISTNEW,		//	A, B		//	create a new array					R(A) = Alloc a LIST(B)
 			LISTNEW,		//	A, B		//	create a new array					R(A) = Alloc a LIST(B)
 			RANGENEW,		//	A, B, C, f	//	create a new range					R(A) = Alloc a RANGE(B,C) f flag tells if B inclusive or exclusive
 			RANGENEW,		//	A, B, C, f	//	create a new range					R(A) = Alloc a RANGE(B,C) f flag tells if B inclusive or exclusive
 			SETLIST,		//	A, B, C		//	set list/map items
 			SETLIST,		//	A, B, C		//	set list/map items
-	
+
 											// *** CLOSURES (2) ***
 											// *** CLOSURES (2) ***
 			CLOSURE,		//	A, B		//	create a new closure				R(A) = closure(K(B))
 			CLOSURE,		//	A, B		//	create a new closure				R(A) = closure(K(B))
 			CLOSE,			//	A			//  close all upvalues from R(A)
 			CLOSE,			//	A			//  close all upvalues from R(A)
-	
+
 											// *** UNUSED (6) ***
 											// *** UNUSED (6) ***
 			RESERVED1,		//				// reserved for future use
 			RESERVED1,		//				// reserved for future use
 			RESERVED2,		//				// reserved for future use
 			RESERVED2,		//				// reserved for future use

File diff suppressed because it is too large
+ 155 - 155
src/shared/gravity_value.c


+ 18 - 18
src/shared/gravity_value.h

@@ -77,15 +77,15 @@ extern "C" {
 #ifndef GRAVITY_ENABLE_INT64
 #ifndef GRAVITY_ENABLE_INT64
 #define GRAVITY_ENABLE_INT64				1			// if 1 enable gravity_int_t to be a 64bit int (intead of a 32bit int)
 #define GRAVITY_ENABLE_INT64				1			// if 1 enable gravity_int_t to be a 64bit int (intead of a 32bit int)
 #endif
 #endif
-    
+
 #ifndef GRAVITY_COMPUTED_GOTO
 #ifndef GRAVITY_COMPUTED_GOTO
 #define GRAVITY_COMPUTED_GOTO				1			// if 1 enable faster computed goto (instead of switch) for compilers that support it
 #define GRAVITY_COMPUTED_GOTO				1			// if 1 enable faster computed goto (instead of switch) for compilers that support it
 #endif
 #endif
-    
+
 #ifndef GRAVITY_NULL_SILENT
 #ifndef GRAVITY_NULL_SILENT
 #define GRAVITY_NULL_SILENT					1			// if 1 then messages sent to null does not produce any runtime error
 #define GRAVITY_NULL_SILENT					1			// if 1 then messages sent to null does not produce any runtime error
 #endif
 #endif
-    
+
 #ifndef GRAVITY_MAP_DOTSUGAR
 #ifndef GRAVITY_MAP_DOTSUGAR
 #define GRAVITY_MAP_DOTSUGAR				1			// if 1 then map objects can be accessed with both map[key] and map.key
 #define GRAVITY_MAP_DOTSUGAR				1			// if 1 then map objects can be accessed with both map[key] and map.key
 #endif
 #endif
@@ -254,10 +254,10 @@ typedef struct {
 			float			purity;				// experimental value
 			float			purity;				// experimental value
 			bool			useargs;			// flag set by the compiler to optimize the creation of the arguments array only if needed
 			bool			useargs;			// flag set by the compiler to optimize the creation of the arguments array only if needed
 		};
 		};
-		
+
 		// tag == EXEC_TYPE_INTERNAL
 		// tag == EXEC_TYPE_INTERNAL
 		gravity_c_internal	internal;			// function callback
 		gravity_c_internal	internal;			// function callback
-		
+
 		// tag == EXEC_TYPE_SPECIAL
 		// tag == EXEC_TYPE_SPECIAL
 		struct {
 		struct {
 			uint16_t		index;				// property index to speed-up default getter and setter
 			uint16_t		index;				// property index to speed-up default getter and setter
@@ -269,7 +269,7 @@ typedef struct {
 typedef struct upvalue_s {
 typedef struct upvalue_s {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_value_t			*value;				// ptr to open value on the stack or to closed value on this struct
 	gravity_value_t			*value;				// ptr to open value on the stack or to closed value on this struct
 	gravity_value_t			closed;				// copy of the value once has been closed
 	gravity_value_t			closed;				// copy of the value once has been closed
 	struct upvalue_s		*next;				// ptr to the next open upvalue
 	struct upvalue_s		*next;				// ptr to the next open upvalue
@@ -278,7 +278,7 @@ typedef struct upvalue_s {
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_function_t		*f;					// function prototype
 	gravity_function_t		*f;					// function prototype
 	gravity_upvalue_t		**upvalue;			// upvalue array
 	gravity_upvalue_t		**upvalue;			// upvalue array
 } gravity_closure_t;
 } gravity_closure_t;
@@ -286,14 +286,14 @@ typedef struct {
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_value_r			array;				// dinamic array of values
 	gravity_value_r			array;				// dinamic array of values
 } gravity_list_t;
 } gravity_list_t;
 
 
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_hash_t			*hash;				// hash table
 	gravity_hash_t			*hash;				// hash table
 } gravity_map_t;
 } gravity_map_t;
 
 
@@ -312,17 +312,17 @@ typedef struct {
 typedef struct fiber_s {
 typedef struct fiber_s {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_value_t			*stack;				// stack buffer (grown as needed and it holds locals and temps)
 	gravity_value_t			*stack;				// stack buffer (grown as needed and it holds locals and temps)
 	gravity_value_t			*stacktop;			// current stack ptr
 	gravity_value_t			*stacktop;			// current stack ptr
 	uint32_t				stackalloc;			// number of allocated values
 	uint32_t				stackalloc;			// number of allocated values
-	
+
 	gravity_callframe_t		*frames;			// callframes buffer (grown as needed but never shrinks)
 	gravity_callframe_t		*frames;			// callframes buffer (grown as needed but never shrinks)
 	uint32_t				nframes;			// number of frames currently in use
 	uint32_t				nframes;			// number of frames currently in use
 	uint32_t				framesalloc;		// number of allocated frames
 	uint32_t				framesalloc;		// number of allocated frames
-	
+
 	gravity_upvalue_t		*upvalues;			// linked list used to keep track of open upvalues
 	gravity_upvalue_t		*upvalues;			// linked list used to keep track of open upvalues
-	
+
 	char					*error;				// runtime error message
 	char					*error;				// runtime error message
 	bool					trying;				// set when the try flag is set by the user
 	bool					trying;				// set when the try flag is set by the user
 	struct fiber_s			*caller;			// optional caller fiber
 	struct fiber_s			*caller;			// optional caller fiber
@@ -332,7 +332,7 @@ typedef struct fiber_s {
 typedef struct gravity_class_s {
 typedef struct gravity_class_s {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_class_t			*objclass;			// meta class
 	gravity_class_t			*objclass;			// meta class
 	const char				*identifier;		// class name
 	const char				*identifier;		// class name
 	bool					has_outer;			// flag used to automatically set ivar 0 to outer class (if any)
 	bool					has_outer;			// flag used to automatically set ivar 0 to outer class (if any)
@@ -350,7 +350,7 @@ typedef struct gravity_class_s {
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	const char				*identifier;		// module name
 	const char				*identifier;		// module name
 	gravity_hash_t			*htable;			// hash table
 	gravity_hash_t			*htable;			// hash table
 } gravity_module_t;
 } gravity_module_t;
@@ -358,7 +358,7 @@ typedef struct {
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_class_t			*objclass;			// real instance class
 	gravity_class_t			*objclass;			// real instance class
 	void					*xdata;				// extra bridged data
 	void					*xdata;				// extra bridged data
 	gravity_value_t			ivars[];			// instance variables (MUST BE LAST in the struct!)
 	gravity_value_t			ivars[];			// instance variables (MUST BE LAST in the struct!)
@@ -367,7 +367,7 @@ typedef struct {
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	char					*s;					// pointer to NULL terminated string
 	char					*s;					// pointer to NULL terminated string
 	uint32_t				hash;				// string hash (type to be keeped in sync with gravity_hash_size_t)
 	uint32_t				hash;				// string hash (type to be keeped in sync with gravity_hash_size_t)
 	uint32_t				len;				// actual string length
 	uint32_t				len;				// actual string length
@@ -377,7 +377,7 @@ typedef struct {
 typedef struct {
 typedef struct {
 	gravity_class_t			*isa;				// to be an object
 	gravity_class_t			*isa;				// to be an object
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
 	gravity_gc_t			gc;					// to be collectable by the garbage collector
-	
+
 	gravity_int_t			from;				// range start
 	gravity_int_t			from;				// range start
 	gravity_int_t			to;					// range end
 	gravity_int_t			to;					// range end
 } gravity_range_t;
 } gravity_range_t;

+ 33 - 33
src/utils/gravity_debug.c

@@ -50,12 +50,12 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 	uint32_t	*ip = NULL;
 	uint32_t	*ip = NULL;
 	uint32_t	pc = 0, inst = 0, ninsts = 0;
 	uint32_t	pc = 0, inst = 0, ninsts = 0;
 	opcode_t	op;
 	opcode_t	op;
-	
+
 	const int	rowlen = 256;
 	const int	rowlen = 256;
 	uint32_t	bindex = 0;
 	uint32_t	bindex = 0;
 	uint32_t	balloc = 0;
 	uint32_t	balloc = 0;
 	char		*buffer = NULL;
 	char		*buffer = NULL;
-	
+
 	if (deserialize) {
 	if (deserialize) {
 		// decode textual buffer to real bytecode
 		// decode textual buffer to real bytecode
 		ip = gravity_bytecode_deserialize(bcode, blen, &ninsts);
 		ip = gravity_bytecode_deserialize(bcode, blen, &ninsts);
@@ -64,37 +64,37 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 		ip = (uint32_t *)bcode;
 		ip = (uint32_t *)bcode;
 		ninsts = blen;
 		ninsts = blen;
 	}
 	}
-		
+
 	// allocate a buffer big enought to fit all disassembled bytecode
 	// allocate a buffer big enought to fit all disassembled bytecode
 	// I assume that each instruction (each row) will be 256 chars long
 	// I assume that each instruction (each row) will be 256 chars long
 	balloc = ninsts * rowlen;
 	balloc = ninsts * rowlen;
 	buffer = mem_alloc(balloc);
 	buffer = mem_alloc(balloc);
 	if (!buffer) goto abort_disassemble;
 	if (!buffer) goto abort_disassemble;
-		
+
 	// conversion loop
 	// conversion loop
 	while (pc < ninsts) {
 	while (pc < ninsts) {
 		inst = *ip++;
 		inst = *ip++;
 		op = (opcode_t)OPCODE_GET_OPCODE(inst);
 		op = (opcode_t)OPCODE_GET_OPCODE(inst);
-		
+
 		switch (op) {
 		switch (op) {
 			case NOP: {
 			case NOP: {
 				DUMP_VM(buffer, bindex, "NOP");
 				DUMP_VM(buffer, bindex, "NOP");
 				break;
 				break;
 			}
 			}
-				
+
 			case MOVE: {
 			case MOVE: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				DUMP_VM(buffer, bindex, "MOVE %d %d", r1, r2);
 				DUMP_VM(buffer, bindex, "MOVE %d %d", r1, r2);
 				break;
 				break;
 			}
 			}
-				
+
 			case LOADI: {
 			case LOADI: {
 				//OPCODE_GET_ONE8bit_ONE18bit(inst, uint32_t r1, int32_t value); if no support for signed int
 				//OPCODE_GET_ONE8bit_ONE18bit(inst, uint32_t r1, int32_t value); if no support for signed int
 				OPCODE_GET_ONE8bit_SIGN_ONE17bit(inst, const uint32_t r1, const int32_t value);
 				OPCODE_GET_ONE8bit_SIGN_ONE17bit(inst, const uint32_t r1, const int32_t value);
 				DUMP_VM(buffer, bindex, "LOADI %d %d", r1, value);
 				DUMP_VM(buffer, bindex, "LOADI %d %d", r1, value);
 				break;
 				break;
 			}
 			}
-				
+
 			case LOADK: {
 			case LOADK: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t index);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t index);
 				if (index < CPOOL_INDEX_MAX) {
 				if (index < CPOOL_INDEX_MAX) {
@@ -115,13 +115,13 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				}
 				}
 				break;
 				break;
 			}
 			}
-				
+
 			case LOADG: {
 			case LOADG: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, uint32_t r1, int32_t index);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, uint32_t r1, int32_t index);
 				DUMP_VM(buffer, bindex, "LOADG %d %d", r1, index);
 				DUMP_VM(buffer, bindex, "LOADG %d %d", r1, index);
 				break;
 				break;
 			}
 			}
-			
+
 			case LOAD:
 			case LOAD:
 			case LOADS:
 			case LOADS:
 			case LOADAT: {
 			case LOADAT: {
@@ -129,32 +129,32 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				DUMP_VM(buffer, bindex, "%s %d %d %d", (op == LOAD) ? "LOAD" : "LOADAT", r1, r2, r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", (op == LOAD) ? "LOAD" : "LOADAT", r1, r2, r3);
 				break;
 				break;
 			}
 			}
-				
+
 			case LOADU: {
 			case LOADU: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				DUMP_VM(buffer, bindex, "LOADU %d %d", r1, r2);
 				DUMP_VM(buffer, bindex, "LOADU %d %d", r1, r2);
 				break;
 				break;
 			}
 			}
-				
+
 			case STOREG: {
 			case STOREG: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, uint32_t r1, int32_t index);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, uint32_t r1, int32_t index);
 				DUMP_VM(buffer, bindex, "STOREG %d %d", r1, index);
 				DUMP_VM(buffer, bindex, "STOREG %d %d", r1, index);
 				break;
 				break;
 			}
 			}
-				
+
 			case STOREU: {
 			case STOREU: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				DUMP_VM(buffer, bindex, "STOREU %d %d", r1, r2);
 				DUMP_VM(buffer, bindex, "STOREU %d %d", r1, r2);
 				break;
 				break;
 			}
 			}
-				
+
 			case STORE:
 			case STORE:
 			case STOREAT: {
 			case STOREAT: {
 				OPCODE_GET_TWO8bit_ONE10bit(inst, const uint32_t r1, const uint32_t r2, const uint32_t r3);
 				OPCODE_GET_TWO8bit_ONE10bit(inst, const uint32_t r1, const uint32_t r2, const uint32_t r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", (op == STORE) ? "STORE" : "STOREAT", r1, r2, r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", (op == STORE) ? "STORE" : "STOREAT", r1, r2, r3);
 				break;
 				break;
 			}
 			}
-			
+
 			case EQQ:
 			case EQQ:
 			case NEQQ:
 			case NEQQ:
 			case ISA:
 			case ISA:
@@ -169,7 +169,7 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				break;
 				break;
 			}
 			}
-				
+
 			// binary operators
 			// binary operators
 			case LSHIFT:
 			case LSHIFT:
 			case RSHIFT:
 			case RSHIFT:
@@ -187,7 +187,7 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				break;
 				break;
 			}
 			}
-				
+
 			// unary operators
 			// unary operators
 			case BNOT:
 			case BNOT:
 			case NEG:
 			case NEG:
@@ -197,32 +197,32 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				break;
 				break;
 			}
 			}
-			
+
 			case RANGENEW: {
 			case RANGENEW: {
 				OPCODE_GET_TWO8bit_ONE10bit(inst, const uint32_t r1, const uint32_t r2, const uint32_t r3);
 				OPCODE_GET_TWO8bit_ONE10bit(inst, const uint32_t r1, const uint32_t r2, const uint32_t r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				DUMP_VM(buffer, bindex, "%s %d %d %d", opcode_name(op), r1, r2, r3);
 				break;
 				break;
 			}
 			}
-			
+
 			case JUMPF: {
 			case JUMPF: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const int32_t value);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const int32_t value);
 				DUMP_VM(buffer, bindex, "JUMPF %d %d", r1, value);
 				DUMP_VM(buffer, bindex, "JUMPF %d %d", r1, value);
 				break;
 				break;
 			}
 			}
-				
+
 			case JUMP: {
 			case JUMP: {
 				OPCODE_GET_ONE26bit(inst, const uint32_t value);
 				OPCODE_GET_ONE26bit(inst, const uint32_t value);
 				DUMP_VM(buffer, bindex, "JUMP %d", value);
 				DUMP_VM(buffer, bindex, "JUMP %d", value);
 				break;
 				break;
 			}
 			}
-				
+
 			case CALL: {
 			case CALL: {
 				// CALL A B C => R(A) = B(C0... CN)
 				// CALL A B C => R(A) = B(C0... CN)
 				OPCODE_GET_THREE8bit(inst, const uint32_t r1, const uint32_t r2, uint32_t r3);
 				OPCODE_GET_THREE8bit(inst, const uint32_t r1, const uint32_t r2, uint32_t r3);
 				DUMP_VM(buffer, bindex, "CALL %d %d %d", r1, r2, r3);
 				DUMP_VM(buffer, bindex, "CALL %d %d %d", r1, r2, r3);
 				break;
 				break;
 			}
 			}
-				
+
 			case RET0:
 			case RET0:
 			case RET: {
 			case RET: {
 				if (op == RET0) {
 				if (op == RET0) {
@@ -233,49 +233,49 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				}
 				}
 				break;
 				break;
 			}
 			}
-				
+
 			case HALT: {
 			case HALT: {
 				DUMP_VM(buffer, bindex, "HALT");
 				DUMP_VM(buffer, bindex, "HALT");
 				break;
 				break;
 			}
 			}
-				
+
 			case SWITCH: {
 			case SWITCH: {
 				DUMP_VM(buffer, bindex, "SWITCH instruction not yet implemented");
 				DUMP_VM(buffer, bindex, "SWITCH instruction not yet implemented");
 				break;
 				break;
 			}
 			}
-				
+
 			case MAPNEW: {
 			case MAPNEW: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t n);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t n);
 				DUMP_VM(buffer, bindex, "MAPNEW %d %d", r1, n);
 				DUMP_VM(buffer, bindex, "MAPNEW %d %d", r1, n);
 				break;
 				break;
 			}
 			}
-				
+
 			case LISTNEW: {
 			case LISTNEW: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t n);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t n);
 				DUMP_VM(buffer, bindex, "LISTNEW %d %d", r1, n);
 				DUMP_VM(buffer, bindex, "LISTNEW %d %d", r1, n);
 				break;
 				break;
 			}
 			}
-				
+
 			case SETLIST: {
 			case SETLIST: {
 				OPCODE_GET_TWO8bit_ONE10bit(inst, const uint32_t r1, uint32_t r2, const uint32_t r3);
 				OPCODE_GET_TWO8bit_ONE10bit(inst, const uint32_t r1, uint32_t r2, const uint32_t r3);
 				#pragma unused(r3)
 				#pragma unused(r3)
 				DUMP_VM(buffer, bindex, "SETLIST %d %d", r1, r2);
 				DUMP_VM(buffer, bindex, "SETLIST %d %d", r1, r2);
 				break;
 				break;
 			}
 			}
-			
+
 			case CLOSURE: {
 			case CLOSURE: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				DUMP_VM(buffer, bindex, "CLOSURE %d %d", r1, r2);
 				DUMP_VM(buffer, bindex, "CLOSURE %d %d", r1, r2);
 				break;
 				break;
 			}
 			}
-				
+
 			case CLOSE: {
 			case CLOSE: {
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				OPCODE_GET_ONE8bit_ONE18bit(inst, const uint32_t r1, const uint32_t r2);
 				#pragma unused(r2)
 				#pragma unused(r2)
 				DUMP_VM(buffer, bindex, "CLOSE %d", r1);
 				DUMP_VM(buffer, bindex, "CLOSE %d", r1);
 				break;
 				break;
 			}
 			}
-				
+
 			case RESERVED1:
 			case RESERVED1:
 			case RESERVED2:
 			case RESERVED2:
 			case RESERVED3:
 			case RESERVED3:
@@ -286,12 +286,12 @@ const char *gravity_disassemble (const char *bcode, uint32_t blen, bool deserial
 				break;
 				break;
 			}
 			}
 		}
 		}
-		
+
 		++pc;
 		++pc;
 	}
 	}
-	
+
 	return buffer;
 	return buffer;
-	
+
 abort_disassemble:
 abort_disassemble:
 	if (ip && deserialize) mem_free(ip);
 	if (ip && deserialize) mem_free(ip);
 	if (buffer) mem_free(buffer);
 	if (buffer) mem_free(buffer);

+ 39 - 39
src/utils/gravity_json.c

@@ -76,7 +76,7 @@ struct json_t {
 	size_t		blen;
 	size_t		blen;
 	size_t		bused;
 	size_t		bused;
 	uint32_t	ident;
 	uint32_t	ident;
-	
+
 	json_ctx_t	ctx[JSON_MAX_NESTED];
 	json_ctx_t	ctx[JSON_MAX_NESTED];
 	size_t		ctxidx;
 	size_t		ctxidx;
 };
 };
@@ -84,22 +84,22 @@ struct json_t {
 json_t *json_new (void) {
 json_t *json_new (void) {
 	json_t *json = mem_alloc(sizeof(json_t));
 	json_t *json = mem_alloc(sizeof(json_t));
 	assert(json);
 	assert(json);
-	
+
 	json->buffer = mem_alloc(JSON_MINSIZE);
 	json->buffer = mem_alloc(JSON_MINSIZE);
 	assert(json->buffer);
 	assert(json->buffer);
-	
+
 	json->blen = JSON_MINSIZE;
 	json->blen = JSON_MINSIZE;
 	json->bused = 0;
 	json->bused = 0;
 	json->ident = 0;
 	json->ident = 0;
 	json->ctxidx = 0;
 	json->ctxidx = 0;
-	
+
 	return json;
 	return json;
 }
 }
 
 
 static void json_write_raw (json_t *json, const char *buffer, size_t len, bool escape, bool is_pretty) {
 static void json_write_raw (json_t *json, const char *buffer, size_t len, bool escape, bool is_pretty) {
 	size_t	prettylen = (is_pretty) ? (json->ident * JSON_PRETTYSIZE)+1 : 0;
 	size_t	prettylen = (is_pretty) ? (json->ident * JSON_PRETTYSIZE)+1 : 0;
 	size_t	escapelen = (escape) ? 2 : 0;
 	size_t	escapelen = (escape) ? 2 : 0;
-	
+
 	// check buffer reallocation
 	// check buffer reallocation
 	size_t reqlen = json->bused + len + prettylen + escapelen + JSON_MINSIZE;
 	size_t reqlen = json->bused + len + prettylen + escapelen + JSON_MINSIZE;
 	if (reqlen >= json->blen) {
 	if (reqlen >= json->blen) {
@@ -107,22 +107,22 @@ static void json_write_raw (json_t *json, const char *buffer, size_t len, bool e
 		assert(json->buffer);
 		assert(json->buffer);
 		json->blen += reqlen;
 		json->blen += reqlen;
 	}
 	}
-	
+
 	if (is_pretty) {
 	if (is_pretty) {
 		for (uint32_t i=0; i<json->ident; ++i) {
 		for (uint32_t i=0; i<json->ident; ++i) {
 			memcpy(json->buffer+json->bused, JSON_PRETTYLINE, JSON_PRETTYSIZE);
 			memcpy(json->buffer+json->bused, JSON_PRETTYLINE, JSON_PRETTYSIZE);
 			json->bused += JSON_PRETTYSIZE;
 			json->bused += JSON_PRETTYSIZE;
 		}
 		}
 	}
 	}
-	
+
 	if (escape) {
 	if (escape) {
 		memcpy(json->buffer+json->bused, "\"", 1);
 		memcpy(json->buffer+json->bused, "\"", 1);
 		json->bused += 1;
 		json->bused += 1;
 	}
 	}
-	
+
 	memcpy(json->buffer+json->bused, buffer, len);
 	memcpy(json->buffer+json->bused, buffer, len);
 	json->bused += len;
 	json->bused += len;
-	
+
 	if (escape) {
 	if (escape) {
 		memcpy(json->buffer+json->bused, "\"", 1);
 		memcpy(json->buffer+json->bused, "\"", 1);
 		json->bused += 1;
 		json->bused += 1;
@@ -134,11 +134,11 @@ static void json_write_escaped (json_t *json, const char *buffer, size_t len, bo
 		json_write_raw(json, "", 0, escape, is_pretty);
 		json_write_raw(json, "", 0, escape, is_pretty);
 		return;
 		return;
 	}
 	}
-	
+
 	char	*new_buffer = mem_alloc (len*2);
 	char	*new_buffer = mem_alloc (len*2);
 	size_t	j = 0;
 	size_t	j = 0;
 	assert(new_buffer);
 	assert(new_buffer);
-	
+
 	for (size_t i=0; i<len; ++i) {
 	for (size_t i=0; i<len; ++i) {
 		char c = buffer[i];
 		char c = buffer[i];
 		switch (c) {
 		switch (c) {
@@ -149,11 +149,11 @@ static void json_write_escaped (json_t *json, const char *buffer, size_t len, bo
 			case '\n': JSON_ESCAPE ('n');   continue;
 			case '\n': JSON_ESCAPE ('n');   continue;
 			case '\r': JSON_ESCAPE ('r');   continue;
 			case '\r': JSON_ESCAPE ('r');   continue;
 			case '\t': JSON_ESCAPE ('t');   continue;
 			case '\t': JSON_ESCAPE ('t');   continue;
-				
+
 			default: new_buffer[j] = c; ++j;break;
 			default: new_buffer[j] = c; ++j;break;
 		};
 		};
 	}
 	}
-	
+
 	json_write_raw(json, new_buffer, j, escape, is_pretty);
 	json_write_raw(json, new_buffer, j, escape, is_pretty);
 	mem_free(new_buffer);
 	mem_free(new_buffer);
 }
 }
@@ -169,25 +169,25 @@ void json_begin_object (json_t *json, const char *key) {
 		json_write_raw (json, key, strlen(key), true, true);
 		json_write_raw (json, key, strlen(key), true, true);
 		JSON_WRITE_SEP;
 		JSON_WRITE_SEP;
 	}
 	}
-	
+
 	JSON_PUSH_CTX(json, json_ctx_object);
 	JSON_PUSH_CTX(json, json_ctx_object);
 	json_write_raw(json, "{", 1, false, (key == NULL));
 	json_write_raw(json, "{", 1, false, (key == NULL));
 	json_write_raw(json, JSON_NEWLINE, 1, false, false);
 	json_write_raw(json, JSON_NEWLINE, 1, false, false);
-	
+
 	++json->ident;
 	++json->ident;
 }
 }
 
 
 void json_end_object (json_t *json) {
 void json_end_object (json_t *json) {
 	--json->ident;
 	--json->ident;
 	JSON_POP_CTX(json);
 	JSON_POP_CTX(json);
-	
+
 	// check latest 2 characters
 	// check latest 2 characters
 	if ((json->buffer[json->bused-1] == JSON_NEWLINE_CHAR) && (json->buffer[json->bused-2] == ',')) {
 	if ((json->buffer[json->bused-1] == JSON_NEWLINE_CHAR) && (json->buffer[json->bused-2] == ',')) {
 		json->buffer[json->bused-2] = JSON_NEWLINE_CHAR;
 		json->buffer[json->bused-2] = JSON_NEWLINE_CHAR;
 		json->buffer[json->bused-1] = 0;
 		json->buffer[json->bused-1] = 0;
 		--json->bused;
 		--json->bused;
 	}
 	}
-	
+
 	json_write_raw(json, "}", 1, false, true);
 	json_write_raw(json, "}", 1, false, true);
 	if (json->ident) {JSON_TERM_FIELD;}
 	if (json->ident) {JSON_TERM_FIELD;}
 	else json_write_raw(json, JSON_NEWLINE, 1, false, false);
 	else json_write_raw(json, JSON_NEWLINE, 1, false, false);
@@ -203,25 +203,25 @@ void json_begin_array (json_t *json, const char *key) {
 		json_write_raw (json, key, strlen(key), true, true);
 		json_write_raw (json, key, strlen(key), true, true);
 		JSON_WRITE_SEP;
 		JSON_WRITE_SEP;
 	}
 	}
-	
+
 	JSON_PUSH_CTX(json, json_ctx_array);
 	JSON_PUSH_CTX(json, json_ctx_array);
 	json_write_raw(json, "[", 1, false, (key == NULL));
 	json_write_raw(json, "[", 1, false, (key == NULL));
 	json_write_raw(json, JSON_NEWLINE, 1, false, false);
 	json_write_raw(json, JSON_NEWLINE, 1, false, false);
-	
+
 	++json->ident;
 	++json->ident;
 }
 }
 
 
 void json_end_array (json_t *json) {
 void json_end_array (json_t *json) {
 	--json->ident;
 	--json->ident;
 	JSON_POP_CTX(json);
 	JSON_POP_CTX(json);
-	
+
 	// check latest 2 characters
 	// check latest 2 characters
 	if ((json->buffer[json->bused-1] == JSON_NEWLINE_CHAR) && (json->buffer[json->bused-2] == ',')) {
 	if ((json->buffer[json->bused-1] == JSON_NEWLINE_CHAR) && (json->buffer[json->bused-2] == ',')) {
 		json->buffer[json->bused-2] = JSON_NEWLINE_CHAR;
 		json->buffer[json->bused-2] = JSON_NEWLINE_CHAR;
 		json->buffer[json->bused-1] = 0;
 		json->buffer[json->bused-1] = 0;
 		--json->bused;
 		--json->bused;
 	}
 	}
-	
+
 	json_write_raw(json, "]", 1, false, true);
 	json_write_raw(json, "]", 1, false, true);
 	JSON_TERM_FIELD;
 	JSON_TERM_FIELD;
 }
 }
@@ -231,12 +231,12 @@ void json_add_string (json_t *json, const char *key, const char *value, size_t l
 		json_add_null(json, key);
 		json_add_null(json, key);
 		return;
 		return;
 	}
 	}
-	
+
 	if (key) {
 	if (key) {
 		json_write_raw (json, key, strlen(key), true, true);
 		json_write_raw (json, key, strlen(key), true, true);
 		JSON_WRITE_SEP;
 		JSON_WRITE_SEP;
 	}
 	}
-	
+
 	// check if string value needs to be escaped
 	// check if string value needs to be escaped
 	bool write_escaped = false;
 	bool write_escaped = false;
 	for (size_t i=0; i<len; ++i) {
 	for (size_t i=0; i<len; ++i) {
@@ -244,7 +244,7 @@ void json_add_string (json_t *json, const char *key, const char *value, size_t l
 	}
 	}
 	if (len == 0)
 	if (len == 0)
 		write_escaped = true;
 		write_escaped = true;
-	
+
 	if (write_escaped)
 	if (write_escaped)
 		json_write_escaped(json, value, len, true, (key == NULL));
 		json_write_escaped(json, value, len, true, (key == NULL));
 	else
 	else
@@ -259,20 +259,20 @@ void json_add_cstring (json_t *json, const char *key, const char *value) {
 void json_add_int (json_t *json, const char *key, int64_t value) {
 void json_add_int (json_t *json, const char *key, int64_t value) {
 	char buffer[512];
 	char buffer[512];
 	size_t len = snprintf(buffer, sizeof(buffer), "%" PRId64, value);
 	size_t len = snprintf(buffer, sizeof(buffer), "%" PRId64, value);
-	
+
 	if (key) {
 	if (key) {
 		json_write_raw (json, key, strlen(key), true, true);
 		json_write_raw (json, key, strlen(key), true, true);
 		JSON_WRITE_SEP;
 		JSON_WRITE_SEP;
 	}
 	}
 	json_write_raw(json, buffer, len, false, (key == NULL));
 	json_write_raw(json, buffer, len, false, (key == NULL));
 	JSON_TERM_FIELD;
 	JSON_TERM_FIELD;
-	
+
 }
 }
 
 
 void json_add_double (json_t *json, const char *key, double value) {
 void json_add_double (json_t *json, const char *key, double value) {
 	char buffer[512];
 	char buffer[512];
 	size_t len = snprintf(buffer, sizeof(buffer), "%f", value);
 	size_t len = snprintf(buffer, sizeof(buffer), "%f", value);
-	
+
 	if (key) {
 	if (key) {
 		json_write_raw (json, key, strlen(key), true, true);
 		json_write_raw (json, key, strlen(key), true, true);
 		JSON_WRITE_SEP;
 		JSON_WRITE_SEP;
@@ -283,7 +283,7 @@ void json_add_double (json_t *json, const char *key, double value) {
 
 
 void json_add_bool (json_t *json, const char *key, bool bvalue) {
 void json_add_bool (json_t *json, const char *key, bool bvalue) {
 	const char *value = (bvalue) ? "true" : "false";
 	const char *value = (bvalue) ? "true" : "false";
-	
+
 	if (key) {
 	if (key) {
 		json_write_raw (json, key, strlen(key), true, true);
 		json_write_raw (json, key, strlen(key), true, true);
 		JSON_WRITE_SEP;
 		JSON_WRITE_SEP;
@@ -499,7 +499,7 @@ static const long
    flag_next             = 1 << 0,
    flag_next             = 1 << 0,
    flag_reproc           = 1 << 1,
    flag_reproc           = 1 << 1,
    flag_need_comma       = 1 << 2,
    flag_need_comma       = 1 << 2,
-   flag_seek_value       = 1 << 3, 
+   flag_seek_value       = 1 << 3,
    flag_escaped          = 1 << 4,
    flag_escaped          = 1 << 4,
    flag_string           = 1 << 5,
    flag_string           = 1 << 5,
    flag_need_colon       = 1 << 6,
    flag_need_colon       = 1 << 6,
@@ -567,7 +567,7 @@ json_value * json_parse_ex (json_settings * settings,
       for (state.ptr = json ;; ++ state.ptr)
       for (state.ptr = json ;; ++ state.ptr)
       {
       {
          json_char b = (state.ptr == end ? 0 : *state.ptr);
          json_char b = (state.ptr == end ? 0 : *state.ptr);
-         
+
          if (flags & flag_string)
          if (flags & flag_string)
          {
          {
             if (!b)
             if (!b)
@@ -591,7 +591,7 @@ json_value * json_parse_ex (json_settings * settings,
                   case 't':  string_add ('\t');  break;
                   case 't':  string_add ('\t');  break;
                   case 'u':
                   case 'u':
 
 
-                    if (end - state.ptr < 4 || 
+                    if (end - state.ptr < 4 ||
                         (uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
                         (uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
                         (uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
                         (uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
                         (uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
                         (uc_b3 = hex_value (*++ state.ptr)) == 0xFF ||
@@ -607,7 +607,7 @@ json_value * json_parse_ex (json_settings * settings,
 
 
                     if ((uchar & 0xF800) == 0xD800) {
                     if ((uchar & 0xF800) == 0xD800) {
                         json_uchar uchar2;
                         json_uchar uchar2;
-                        
+
                         if (end - state.ptr < 6 || (*++ state.ptr) != '\\' || (*++ state.ptr) != 'u' ||
                         if (end - state.ptr < 6 || (*++ state.ptr) != '\\' || (*++ state.ptr) != 'u' ||
                             (uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
                             (uc_b1 = hex_value (*++ state.ptr)) == 0xFF ||
                             (uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
                             (uc_b2 = hex_value (*++ state.ptr)) == 0xFF ||
@@ -621,7 +621,7 @@ json_value * json_parse_ex (json_settings * settings,
                         uc_b1 = (uc_b1 << 4) | uc_b2;
                         uc_b1 = (uc_b1 << 4) | uc_b2;
                         uc_b2 = (uc_b3 << 4) | uc_b4;
                         uc_b2 = (uc_b3 << 4) | uc_b4;
                         uchar2 = (uc_b1 << 8) | uc_b2;
                         uchar2 = (uc_b1 << 8) | uc_b2;
-                        
+
                         uchar = 0x010000 | ((uchar & 0x3FF) << 10) | (uchar2 & 0x3FF);
                         uchar = 0x010000 | ((uchar & 0x3FF) << 10) | (uchar2 & 0x3FF);
                     }
                     }
 
 
@@ -651,7 +651,7 @@ json_value * json_parse_ex (json_settings * settings,
                            string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F);
                            string [string_length ++] = 0x80 | ((uchar >> 6) & 0x3F);
                            string [string_length ++] = 0x80 | (uchar & 0x3F);
                            string [string_length ++] = 0x80 | (uchar & 0x3F);
                         }
                         }
-                        
+
                         break;
                         break;
                     }
                     }
 
 
@@ -701,7 +701,7 @@ json_value * json_parse_ex (json_settings * settings,
                      if (state.first_pass)
                      if (state.first_pass)
                         (*(json_char **) &top->u.object.values) += string_length + 1;
                         (*(json_char **) &top->u.object.values) += string_length + 1;
                      else
                      else
-                     {  
+                     {
                         top->u.object.values [top->u.object.length].name
                         top->u.object.values [top->u.object.length].name
                            = (json_char *) top->_reserved.object_mem;
                            = (json_char *) top->_reserved.object_mem;
 
 
@@ -846,7 +846,7 @@ json_value * json_parse_ex (json_settings * settings,
                         continue;
                         continue;
                      }
                      }
                      else
                      else
-                     { 
+                     {
                         sprintf (error, "%d:%d: Expected : before %c",
                         sprintf (error, "%d:%d: Expected : before %c",
                                  state.cur_line, state.cur_col, b);
                                  state.cur_line, state.cur_col, b);
 
 
@@ -984,7 +984,7 @@ json_value * json_parse_ex (json_settings * settings,
             switch (top->type)
             switch (top->type)
             {
             {
             case json_object:
             case json_object:
-               
+
                switch (b)
                switch (b)
                {
                {
                   whitespace:
                   whitespace:
@@ -1003,7 +1003,7 @@ json_value * json_parse_ex (json_settings * settings,
                      string_length = 0;
                      string_length = 0;
 
 
                      break;
                      break;
-                  
+
                   case '}':
                   case '}':
 
 
                      flags = (flags & ~ flag_need_comma) | flag_next;
                      flags = (flags & ~ flag_need_comma) | flag_next;
@@ -1159,7 +1159,7 @@ json_value * json_parse_ex (json_settings * settings,
 
 
             if (top->parent->type == json_array)
             if (top->parent->type == json_array)
                flags |= flag_seek_value;
                flags |= flag_seek_value;
-               
+
             if (!state.first_pass)
             if (!state.first_pass)
             {
             {
                json_value * parent = top->parent;
                json_value * parent = top->parent;

+ 9 - 9
src/utils/gravity_json.h

@@ -117,14 +117,14 @@ typedef enum
 } json_type;
 } json_type;
 
 
 extern const struct _json_value json_value_none;
 extern const struct _json_value json_value_none;
-       
+
 typedef struct _json_object_entry
 typedef struct _json_object_entry
 {
 {
     json_char * name;
     json_char * name;
     unsigned int name_length;
     unsigned int name_length;
-    
+
     struct _json_value * value;
     struct _json_value * value;
-    
+
 } json_object_entry;
 } json_object_entry;
 
 
 typedef struct _json_value
 typedef struct _json_value
@@ -219,7 +219,7 @@ typedef struct _json_value
          }
          }
 
 
          inline const struct _json_value &operator [] (const char * index) const
          inline const struct _json_value &operator [] (const char * index) const
-         { 
+         {
             if (type != json_object)
             if (type != json_object)
                return json_value_none;
                return json_value_none;
 
 
@@ -231,7 +231,7 @@ typedef struct _json_value
          }
          }
 
 
          inline operator const char * () const
          inline operator const char * () const
-         {  
+         {
             switch (type)
             switch (type)
             {
             {
                case json_string:
                case json_string:
@@ -243,7 +243,7 @@ typedef struct _json_value
          }
          }
 
 
          inline operator json_int_t () const
          inline operator json_int_t () const
-         {  
+         {
             switch (type)
             switch (type)
             {
             {
                case json_integer:
                case json_integer:
@@ -258,7 +258,7 @@ typedef struct _json_value
          }
          }
 
 
          inline operator bool () const
          inline operator bool () const
-         {  
+         {
             if (type != json_boolean)
             if (type != json_boolean)
                return false;
                return false;
 
 
@@ -266,7 +266,7 @@ typedef struct _json_value
          }
          }
 
 
          inline operator double () const
          inline operator double () const
-         {  
+         {
             switch (type)
             switch (type)
             {
             {
                case json_integer:
                case json_integer:
@@ -286,7 +286,7 @@ typedef struct _json_value
 
 
 #define EMPTY_SETTINGS_STRUCT	{0,0,0,0,0,0}
 #define EMPTY_SETTINGS_STRUCT	{0,0,0,0,0,0}
 #define EMPTY_STATE_STRUCT		{0,0,0,EMPTY_SETTINGS_STRUCT,0,0,0,0}
 #define EMPTY_STATE_STRUCT		{0,0,0,EMPTY_SETTINGS_STRUCT,0,0,0,0}
-       
+
 json_value * json_parse (const json_char * json,
 json_value * json_parse (const json_char * json,
                          size_t length);
                          size_t length);
 
 

+ 54 - 54
src/utils/gravity_utils.c

@@ -35,44 +35,44 @@
 
 
 nanotime_t nanotime (void) {
 nanotime_t nanotime (void) {
 	nanotime_t value;
 	nanotime_t value;
-	
+
 	#if defined(_WIN32)
 	#if defined(_WIN32)
 	static LARGE_INTEGER	win_frequency;
 	static LARGE_INTEGER	win_frequency;
 	QueryPerformanceFrequency(&win_frequency);
 	QueryPerformanceFrequency(&win_frequency);
 	LARGE_INTEGER			t;
 	LARGE_INTEGER			t;
-	
+
 	if (!QueryPerformanceCounter(&t)) return 0;
 	if (!QueryPerformanceCounter(&t)) return 0;
 	value = (t.QuadPart / win_frequency.QuadPart) * 1000000000;
 	value = (t.QuadPart / win_frequency.QuadPart) * 1000000000;
 	value += (t.QuadPart % win_frequency.QuadPart) * 1000000000 / win_frequency.QuadPart;
 	value += (t.QuadPart % win_frequency.QuadPart) * 1000000000 / win_frequency.QuadPart;
-	
+
 	#elif defined(__MACH__)
 	#elif defined(__MACH__)
 	mach_timebase_info_data_t	info;
 	mach_timebase_info_data_t	info;
 	kern_return_t				r;
 	kern_return_t				r;
 	nanotime_t					t;
 	nanotime_t					t;
-	
+
 	t = mach_absolute_time();
 	t = mach_absolute_time();
 	r = mach_timebase_info(&info);
 	r = mach_timebase_info(&info);
 	if (r != 0) return 0;
 	if (r != 0) return 0;
 	value = (t / info.denom) * info.numer;
 	value = (t / info.denom) * info.numer;
 	value += (t % info.denom) * info.numer / info.denom;
 	value += (t % info.denom) * info.numer / info.denom;
-	
+
 	#elif defined(__linux)
 	#elif defined(__linux)
 	struct timespec ts;
 	struct timespec ts;
 	int				r;
 	int				r;
-	
+
 	r = clock_gettime(CLOCK_MONOTONIC, &ts);
 	r = clock_gettime(CLOCK_MONOTONIC, &ts);
 	if (r != 0) return 0;
 	if (r != 0) return 0;
 	value = ts.tv_sec * (nanotime_t)1000000000 + ts.tv_nsec;
 	value = ts.tv_sec * (nanotime_t)1000000000 + ts.tv_nsec;
-	
+
 	#else
 	#else
 	struct timeval	tv;
 	struct timeval	tv;
 	int				r;
 	int				r;
-	
+
 	r = gettimeofday(&tv, 0);
 	r = gettimeofday(&tv, 0);
 	if (r != 0) return 0;
 	if (r != 0) return 0;
 	value = tv.tv_sec * (nanotime_t)1000000000 + tv.tv_usec * 1000;
 	value = tv.tv_sec * (nanotime_t)1000000000 + tv.tv_usec * 1000;
 	#endif
 	#endif
-	
+
 	return value;
 	return value;
 }
 }
 
 
@@ -96,7 +96,7 @@ static ssize_t getline (char **lineptr, size_t *n, FILE *stream) {
 	// see http://stackoverflow.com/questions/3302255/c-scanf-vs-gets-vs-fgets
 	// see http://stackoverflow.com/questions/3302255/c-scanf-vs-gets-vs-fgets
 	// we should implement something like ggets here
 	// we should implement something like ggets here
 	// http://web.archive.org/web/20080525133110/http://cbfalconer.home.att.net/download/
 	// http://web.archive.org/web/20080525133110/http://cbfalconer.home.att.net/download/
-	
+
 	return -1;
 	return -1;
 }
 }
 #endif
 #endif
@@ -104,13 +104,13 @@ static ssize_t getline (char **lineptr, size_t *n, FILE *stream) {
 char *readline (char *prompt, int *length) {
 char *readline (char *prompt, int *length) {
 	char	*line = NULL;
 	char	*line = NULL;
 	size_t	size = 0;
 	size_t	size = 0;
-	
+
 	printf("%s", prompt);
 	printf("%s", prompt);
 	fflush(stdout);
 	fflush(stdout);
-	
+
 	ssize_t nread = getline(&line, &size, stdin);
 	ssize_t nread = getline(&line, &size, stdin);
 	if (nread == -1 || feof(stdin)) return NULL;
 	if (nread == -1 || feof(stdin)) return NULL;
-	
+
 	*length = (int)nread;
 	*length = (int)nread;
 	return line;
 	return line;
 }
 }
@@ -134,24 +134,24 @@ const char *file_read(const char *path, size_t *len) {
 	off_t	fsize = 0;
 	off_t	fsize = 0;
 	size_t	fsize2 = 0;
 	size_t	fsize2 = 0;
 	char	*buffer = NULL;
 	char	*buffer = NULL;
-	
+
 	fsize = (size_t) file_size(path);
 	fsize = (size_t) file_size(path);
 	if (fsize < 0) goto abort_read;
 	if (fsize < 0) goto abort_read;
-	
+
 	fd = open(path, O_RDONLY);
 	fd = open(path, O_RDONLY);
 	if (fd < 0) goto abort_read;
 	if (fd < 0) goto abort_read;
-	
+
 	buffer = (char *)mem_alloc((size_t)fsize + 1);
 	buffer = (char *)mem_alloc((size_t)fsize + 1);
 	if (buffer == NULL) goto abort_read;
 	if (buffer == NULL) goto abort_read;
 	buffer[fsize] = 0;
 	buffer[fsize] = 0;
-	
+
 	fsize2 = read(fd, buffer, (size_t)fsize);
 	fsize2 = read(fd, buffer, (size_t)fsize);
 	if (fsize2 == -1) goto abort_read;
 	if (fsize2 == -1) goto abort_read;
-	
+
 	if (len) *len = fsize2;
 	if (len) *len = fsize2;
 	close(fd);
 	close(fd);
 	return (const char *)buffer;
 	return (const char *)buffer;
-	
+
 abort_read:
 abort_read:
 	if (buffer) mem_free((void *)buffer);
 	if (buffer) mem_free((void *)buffer);
 	if (fd >= 0) close(fd);
 	if (fd >= 0) close(fd);
@@ -162,23 +162,23 @@ bool file_exists (const char *path) {
 	#ifdef WIN32
 	#ifdef WIN32
 	BOOL isDirectory;
 	BOOL isDirectory;
 	DWORD attributes = GetFileAttributesA(path);
 	DWORD attributes = GetFileAttributesA(path);
-	
+
 	// special directory case to drive the network path check
 	// special directory case to drive the network path check
 	if (attributes == INVALID_FILE_ATTRIBUTES)
 	if (attributes == INVALID_FILE_ATTRIBUTES)
 		isDirectory = (GetLastError() == ERROR_BAD_NETPATH);
 		isDirectory = (GetLastError() == ERROR_BAD_NETPATH);
 	else
 	else
 		isDirectory = (FILE_ATTRIBUTE_DIRECTORY & attributes);
 		isDirectory = (FILE_ATTRIBUTE_DIRECTORY & attributes);
-	
+
 	if (isDirectory) {
 	if (isDirectory) {
 		if (PathIsNetworkPathA(path)) return true;
 		if (PathIsNetworkPathA(path)) return true;
 		if (PathIsUNCA(path)) return true;
 		if (PathIsUNCA(path)) return true;
 	}
 	}
-	
+
 	if (PathFileExistsA(path) == 1) return true;
 	if (PathFileExistsA(path) == 1) return true;
 	#else
 	#else
 	if (access(path, F_OK)==0) return true;
 	if (access(path, F_OK)==0) return true;
 	#endif
 	#endif
-	
+
 	return false;
 	return false;
 }
 }
 
 
@@ -189,16 +189,16 @@ const char *file_buildpath (const char *filename, const char *dirpath) {
 	size_t len1 = strlen(filename);
 	size_t len1 = strlen(filename);
 	size_t len2 = strlen(dirpath);
 	size_t len2 = strlen(dirpath);
 	size_t len = len1+len2+2;
 	size_t len = len1+len2+2;
-	
+
 	char *full_path = (char *)mem_alloc(len);
 	char *full_path = (char *)mem_alloc(len);
 	if (!full_path) return NULL;
 	if (!full_path) return NULL;
-	
+
 	if ((len2) && (dirpath[len2-1] != '/'))
 	if ((len2) && (dirpath[len2-1] != '/'))
 		snprintf(full_path, len, "%s/%s", dirpath, filename);
 		snprintf(full_path, len, "%s/%s", dirpath, filename);
 	else
 	else
 		snprintf(full_path, len, "%s%s", dirpath, filename);
 		snprintf(full_path, len, "%s%s", dirpath, filename);
 //	#endif
 //	#endif
-	
+
 	return (const char *)full_path;
 	return (const char *)full_path;
 }
 }
 
 
@@ -209,13 +209,13 @@ bool file_write (const char *path, const char *buffer, size_t len) {
 	#else
 	#else
 	mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 	mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
 	#endif
 	#endif
-	
+
 	int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
 	int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, mode);
 	if (fd < 0) return false;
 	if (fd < 0) return false;
-	
+
 	ssize_t nwrite = write(fd, buffer, len);
 	ssize_t nwrite = write(fd, buffer, len);
 	close(fd);
 	close(fd);
-	
+
 	return (nwrite == len);
 	return (nwrite == len);
 }
 }
 
 
@@ -224,17 +224,17 @@ bool file_write (const char *path, const char *buffer, size_t len) {
 bool is_directory (const char *path) {
 bool is_directory (const char *path) {
 	#ifdef WIN32
 	#ifdef WIN32
 	DWORD dwAttrs;
 	DWORD dwAttrs;
-	
+
 	dwAttrs = GetFileAttributesA(path);
 	dwAttrs = GetFileAttributesA(path);
 	if (dwAttrs == INVALID_FILE_ATTRIBUTES) return false;
 	if (dwAttrs == INVALID_FILE_ATTRIBUTES) return false;
 	if (dwAttrs & FILE_ATTRIBUTE_DIRECTORY) return true;
 	if (dwAttrs & FILE_ATTRIBUTE_DIRECTORY) return true;
 	#else
 	#else
 	struct stat buf;
 	struct stat buf;
-	
+
 	if (lstat(path, &buf) < 0) return false;
 	if (lstat(path, &buf) < 0) return false;
 	if (S_ISDIR(buf.st_mode)) return true;
 	if (S_ISDIR(buf.st_mode)) return true;
 	#endif
 	#endif
-	
+
 	return false;
 	return false;
 }
 }
 
 
@@ -248,10 +248,10 @@ DIRREF directory_init (const char *dirpath) {
 
 
 	// convert dirpath to dirpathW
 	// convert dirpath to dirpathW
 	MultiByteToWideChar(CP_UTF8, 0, dirpath, -1, dirpathW, MAX_PATH);
 	MultiByteToWideChar(CP_UTF8, 0, dirpath, -1, dirpathW, MAX_PATH);
-	
+
 	// in this way I can be sure that the first file returned (and lost) is .
 	// in this way I can be sure that the first file returned (and lost) is .
 	PathCombineW(path, dirpathW, _T("*"));
 	PathCombineW(path, dirpathW, _T("*"));
-	
+
 	// if the path points to a symbolic link, the WIN32_FIND_DATA buffer contains
 	// if the path points to a symbolic link, the WIN32_FIND_DATA buffer contains
 	// information about the symbolic link, not the target
 	// information about the symbolic link, not the target
 	return FindFirstFileW(path, &findData);
 	return FindFirstFileW(path, &findData);
@@ -262,12 +262,12 @@ DIRREF directory_init (const char *dirpath) {
 
 
 const char *directory_read (DIRREF ref) {
 const char *directory_read (DIRREF ref) {
 	if (ref == NULL) return NULL;
 	if (ref == NULL) return NULL;
-	
+
 	while (1) {
 	while (1) {
 		#ifdef WIN32
 		#ifdef WIN32
 		WIN32_FIND_DATA findData;
 		WIN32_FIND_DATA findData;
 		char 			*file_name;
 		char 			*file_name;
-		
+
 		if (FindNextFile(ref, &findData) == 0) {
 		if (FindNextFile(ref, &findData) == 0) {
 			FindClose(ref);
 			FindClose(ref);
 			return NULL;
 			return NULL;
@@ -299,7 +299,7 @@ int string_nocasencmp(const char *s1, const char *s2, size_t n) {
 		s2++;
 		s2++;
 		n--;
 		n--;
 	}
 	}
-	
+
 	if(n == 0) return 0;
 	if(n == 0) return 0;
 	return tolower((unsigned char)*s1) - tolower((unsigned char)*s2);
 	return tolower((unsigned char)*s1) - tolower((unsigned char)*s2);
 }
 }
@@ -311,7 +311,7 @@ int string_casencmp(const char *s1, const char *s2, size_t n) {
 		s2++;
 		s2++;
 		n--;
 		n--;
 	}
 	}
-	
+
 	if(n == 0) return 0;
 	if(n == 0) return 0;
 	return ((unsigned char)*s1) - ((unsigned char)*s2);
 	return ((unsigned char)*s1) - ((unsigned char)*s2);
 }
 }
@@ -324,7 +324,7 @@ int string_cmp (const char *s1, const char *s2) {
 const char *string_dup (const char *s1) {
 const char *string_dup (const char *s1) {
 	size_t	len = (size_t)strlen(s1);
 	size_t	len = (size_t)strlen(s1);
 	char	*s = (char *)mem_alloc(len + 1);
 	char	*s = (char *)mem_alloc(len + 1);
-	
+
 	memcpy(s, s1, len);
 	memcpy(s, s1, len);
 	return s;
 	return s;
 }
 }
@@ -351,7 +351,7 @@ uint32_t string_size (const char *p) {
 char *string_strnstr(const char *s, const char *find, size_t slen) {
 char *string_strnstr(const char *s, const char *find, size_t slen) {
     char c, sc;
     char c, sc;
     size_t len;
     size_t len;
-    
+
     if ((c = *find++) != '\0') {
     if ((c = *find++) != '\0') {
         len = strlen(find);
         len = strlen(find);
         do {
         do {
@@ -382,18 +382,18 @@ char *string_strnstr(const char *s, const char *find, size_t slen) {
 	UTF8-4      = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
 	UTF8-4      = %xF0 %x90-BF 2( UTF8-tail ) / %xF1-F3 3( UTF8-tail ) /
 				  %xF4 %x80-8F 2( UTF8-tail )
 				  %xF4 %x80-8F 2( UTF8-tail )
 	UTF8-tail   = %x80-BF
 	UTF8-tail   = %x80-BF
- 
+
  */
  */
 
 
 inline uint32_t utf8_charbytes (const char *s, uint32_t i) {
 inline uint32_t utf8_charbytes (const char *s, uint32_t i) {
 	unsigned char c = s[i];
 	unsigned char c = s[i];
-	
+
 	// determine bytes needed for character, based on RFC 3629
 	// determine bytes needed for character, based on RFC 3629
 	if ((c > 0) && (c <= 127)) return 1;
 	if ((c > 0) && (c <= 127)) return 1;
 	if ((c >= 194) && (c <= 223)) return 2;
 	if ((c >= 194) && (c <= 223)) return 2;
 	if ((c >= 224) && (c <= 239)) return 3;
 	if ((c >= 224) && (c <= 239)) return 3;
 	if ((c >= 240) && (c <= 244)) return 4;
 	if ((c >= 240) && (c <= 244)) return 4;
-	
+
 	// means error
 	// means error
 	return 0;
 	return 0;
 }
 }
@@ -410,13 +410,13 @@ uint32_t utf8_nbytes (uint32_t n) {
 // from: https://github.com/munificent/wren/blob/master/src/vm/wren_utils.c
 // from: https://github.com/munificent/wren/blob/master/src/vm/wren_utils.c
 uint32_t utf8_encode(char *buffer, uint32_t value) {
 uint32_t utf8_encode(char *buffer, uint32_t value) {
 	char *bytes = buffer;
 	char *bytes = buffer;
-	
+
 	if (value <= 0x7f) {
 	if (value <= 0x7f) {
 		// single byte (i.e. fits in ASCII).
 		// single byte (i.e. fits in ASCII).
 		*bytes = value & 0x7f;
 		*bytes = value & 0x7f;
 		return 1;
 		return 1;
 	}
 	}
-	
+
 	if (value <= 0x7ff) {
 	if (value <= 0x7ff) {
 		// two byte sequence: 110xxxxx 10xxxxxx.
 		// two byte sequence: 110xxxxx 10xxxxxx.
 		*bytes = 0xc0 | ((value & 0x7c0) >> 6);
 		*bytes = 0xc0 | ((value & 0x7c0) >> 6);
@@ -424,7 +424,7 @@ uint32_t utf8_encode(char *buffer, uint32_t value) {
 		*bytes = 0x80 | (value & 0x3f);
 		*bytes = 0x80 | (value & 0x3f);
 		return 2;
 		return 2;
 	}
 	}
-	
+
 	if (value <= 0xffff) {
 	if (value <= 0xffff) {
 		// three byte sequence: 1110xxxx 10xxxxxx 10xxxxxx.
 		// three byte sequence: 1110xxxx 10xxxxxx 10xxxxxx.
 		*bytes = 0xe0 | ((value & 0xf000) >> 12);
 		*bytes = 0xe0 | ((value & 0xf000) >> 12);
@@ -434,7 +434,7 @@ uint32_t utf8_encode(char *buffer, uint32_t value) {
 		*bytes = 0x80 | (value & 0x3f);
 		*bytes = 0x80 | (value & 0x3f);
 		return 3;
 		return 3;
 	}
 	}
-	
+
 	if (value <= 0x10ffff) {
 	if (value <= 0x10ffff) {
 		// four byte sequence: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx.
 		// four byte sequence: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx.
 		*bytes = 0xf0 | ((value & 0x1c0000) >> 18);
 		*bytes = 0xf0 | ((value & 0x1c0000) >> 18);
@@ -446,23 +446,23 @@ uint32_t utf8_encode(char *buffer, uint32_t value) {
 		*bytes = 0x80 | (value & 0x3f);
 		*bytes = 0x80 | (value & 0x3f);
 		return 4;
 		return 4;
 	}
 	}
-	
+
 	return 0;
 	return 0;
 }
 }
 
 
 uint32_t utf8_len (const char *s, uint32_t nbytes) {
 uint32_t utf8_len (const char *s, uint32_t nbytes) {
 	if (nbytes == 0) nbytes = (uint32_t)strlen(s);
 	if (nbytes == 0) nbytes = (uint32_t)strlen(s);
-	
+
 	uint32_t pos = 1;
 	uint32_t pos = 1;
 	uint32_t len = 0;
 	uint32_t len = 0;
-	
+
 	while (pos <= nbytes) {
 	while (pos <= nbytes) {
 		++len;
 		++len;
 		uint32_t n = utf8_charbytes(s, pos);
 		uint32_t n = utf8_charbytes(s, pos);
 		if (n == 0) return 0; // means error
 		if (n == 0) return 0; // means error
 		pos += n;
 		pos += n;
 	}
 	}
-	
+
 	return len;
 	return len;
 }
 }
 
 
@@ -470,7 +470,7 @@ uint32_t utf8_len (const char *s, uint32_t nbytes) {
 bool utf8_reverse (char *p) {
 bool utf8_reverse (char *p) {
 	char *q = p;
 	char *q = p;
 	string_reverse(p);
 	string_reverse(p);
-	
+
 	// now fix bass-ackwards UTF chars.
 	// now fix bass-ackwards UTF chars.
 	while(q && *q) ++q; // find eos
 	while(q && *q) ++q; // find eos
 	while(p < --q)
 	while(p < --q)
@@ -508,7 +508,7 @@ uint32_t power_of2_ceil (uint32_t n) {
 	n |= n >> 8;
 	n |= n >> 8;
 	n |= n >> 16;
 	n |= n >> 16;
 	n++;
 	n++;
-	
+
 	return n;
 	return n;
 }
 }
 
 
@@ -524,7 +524,7 @@ int64_t number_from_oct (const char *s, uint32_t len) {
 
 
 int64_t number_from_bin (const char *s, uint32_t len) {
 int64_t number_from_bin (const char *s, uint32_t len) {
 	int64_t value = 0;
 	int64_t value = 0;
-	
+
 	for (uint32_t i=0; i<len; ++i) {
 	for (uint32_t i=0; i<len; ++i) {
 		int c = s[i];
 		int c = s[i];
 		value = (value << 1) + (c - '0');
 		value = (value << 1) + (c - '0');

Some files were not shown because too many files changed in this diff