Commit 2deac920 authored by Chris Müller's avatar Chris Müller
Browse files

Reorganize core runtime functions

Move and rename some core- and system functions for the toplevel
environment.
parent 6b36f4e8
......@@ -20,16 +20,14 @@
#include "cherry/runtime.h"
struct org_cherry_value* org_cherry_core_type(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_core_raise(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_core_add(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_core_sub(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_core_mul(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_core_div(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_io_println(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_primitive_println(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_primitive_raise(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_primitive_exit(struct org_cherry_environment* env, struct org_cherry_value* args);
struct org_cherry_value* org_cherry_system_exit(struct org_cherry_environment* env, struct org_cherry_value* args);
......@@ -7,7 +7,7 @@ set(CORE_SOURCES
tables.c
exception.c
primitives/core.c
primitives/print.c
primitives/io.c
primitives/system.c)
set(INTERPRETER_SOURCES
......
......@@ -210,5 +210,14 @@ org_cherry_core_div(struct org_cherry_environment* env, struct org_cherry_value*
return v;
}
struct org_cherry_value*
org_cherry_core_raise(struct org_cherry_environment* env, struct org_cherry_value* args)
{
if(IS_NULL(args))
org_cherry_env_raise(env, org_cherry_emptylist);
else
org_cherry_env_raise(env, HEAD(args));
return org_cherry_false;
}
......@@ -20,7 +20,7 @@
#include <stdio.h>
struct org_cherry_value*
org_cherry_primitive_println(struct org_cherry_environment* env, struct org_cherry_value* args)
org_cherry_io_println(struct org_cherry_environment* env, struct org_cherry_value* args)
{
while(!IS_NULL(args)) {
struct org_cherry_value* v = HEAD(args);
......
......@@ -20,18 +20,9 @@
#include <stdlib.h>
struct org_cherry_value*
org_cherry_primitive_exit(struct org_cherry_environment* env, struct org_cherry_value* args)
org_cherry_system_exit(struct org_cherry_environment* env, struct org_cherry_value* args)
{
return org_cherry_false;
}
struct org_cherry_value*
org_cherry_primitive_raise(struct org_cherry_environment* env, struct org_cherry_value* args)
{
if(IS_NULL(args))
org_cherry_env_raise(env, org_cherry_emptylist);
else
org_cherry_env_raise(env, HEAD(args));
return org_cherry_false;
}
......@@ -400,8 +400,8 @@ org_cherry_environment(void)
#define proc_to_env(ENV, STR, FUN) \
org_cherry_env_add(ENV, org_cherry_symbol(STR), org_cherry_primitive(FUN))
proc_to_env(env, "println", org_cherry_primitive_println);
proc_to_env(env, "raise", org_cherry_primitive_raise);
proc_to_env(env, "println", org_cherry_io_println);
proc_to_env(env, "raise", org_cherry_core_raise);
proc_to_env(env, "type", org_cherry_core_type);
proc_to_env(env, "+", org_cherry_core_add);
proc_to_env(env, "-", org_cherry_core_sub);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment