Moved type info into a flags field in the lisp objects
This commit is contained in:
+7
-7
@@ -292,7 +292,7 @@ namespace Parser {
|
||||
|
||||
// okay there is something
|
||||
Lisp_Object* head = Memory::create_lisp_object();
|
||||
head->type = Lisp_Object_Type::Pair;
|
||||
Memory::set_type(head, Lisp_Object_Type::Pair);
|
||||
// head->value.pair = new(Pair);
|
||||
Lisp_Object* expression = head;
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace Parser {
|
||||
}
|
||||
|
||||
// check if we have to create or delete or run macros
|
||||
if (expression->value.pair.first->type == Lisp_Object_Type::Symbol) {
|
||||
if (Memory::get_type(expression->value.pair.first) == Lisp_Object_Type::Symbol) {
|
||||
if (string_equal("define-syntax", expression->value.pair.first->value.identifier)) {
|
||||
// create a new macro
|
||||
Lisp_Object* arguments = expression->value.pair.rest;
|
||||
@@ -378,12 +378,12 @@ namespace Parser {
|
||||
|
||||
// Function* function = new(Function);
|
||||
Lisp_Object* macro = Memory::create_lisp_object();
|
||||
macro->type = Lisp_Object_Type::Function;
|
||||
Memory::set_type(macro, Lisp_Object_Type::Function);
|
||||
macro->value.function.parent_environment = environment_for_macros;
|
||||
macro->value.function.type = Function_Type::Macro;
|
||||
|
||||
// if parameters were specified
|
||||
if (arguments->value.pair.first->type != Lisp_Object_Type::Nil) {
|
||||
if (Memory::get_type(arguments->value.pair.first) != Lisp_Object_Type::Nil) {
|
||||
try {
|
||||
assert_type(arguments->value.pair.first, Lisp_Object_Type::Pair);
|
||||
}
|
||||
@@ -398,7 +398,7 @@ namespace Parser {
|
||||
|
||||
arguments = arguments->value.pair.rest;
|
||||
// if there is a docstring, use it
|
||||
if (arguments->value.pair.first->type == Lisp_Object_Type::String) {
|
||||
if (Memory::get_type(arguments->value.pair.first) == Lisp_Object_Type::String) {
|
||||
macro->value.function.docstring = arguments->value.pair.first->value.string;
|
||||
arguments = arguments->value.pair.rest;
|
||||
} else {
|
||||
@@ -439,7 +439,7 @@ namespace Parser {
|
||||
|
||||
for (int i = 0; i < environment_for_macros->next_index; ++i) {
|
||||
if (string_equal(expression->value.pair.first->value.identifier, environment_for_macros->keys[i]) &&
|
||||
environment_for_macros->values[i]->type == Lisp_Object_Type::Function &&
|
||||
Memory::get_type(environment_for_macros->values[i]) == Lisp_Object_Type::Function &&
|
||||
environment_for_macros->values[i]->value.function.type == Function_Type::Macro)
|
||||
{
|
||||
try {
|
||||
@@ -543,7 +543,7 @@ namespace Parser {
|
||||
|
||||
for (int i = 0; i < program->next_index; ++i) {
|
||||
// a macro will parse as nil for now, so we skip those
|
||||
if (program->data[i]->type == Lisp_Object_Type::Nil)
|
||||
if (program->data[i] == Memory::nil)
|
||||
continue;
|
||||
print(program->data[i], true, f);
|
||||
fprintf(f, "\n\n");
|
||||
|
||||
Reference in New Issue
Block a user