1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 09:47:17 +00:00

Make the assembler optional during compilation.

This commit is contained in:
Calvin Rose 2018-09-29 10:58:57 -04:00
parent 03b01c6c0b
commit e963672977
6 changed files with 18 additions and 10 deletions

View File

@ -24,6 +24,9 @@
#include <janet/janet.h> #include <janet/janet.h>
#include "util.h" #include "util.h"
/* Conditionally compile this file */
#ifdef JANET_ASSEMBLER
/* Definition for an instruction in the assembler */ /* Definition for an instruction in the assembler */
typedef struct JanetInstructionDef JanetInstructionDef; typedef struct JanetInstructionDef JanetInstructionDef;
struct JanetInstructionDef { struct JanetInstructionDef {
@ -932,3 +935,5 @@ int janet_lib_asm(JanetArgs args) {
janet_cfuns(env, NULL, cfuns); janet_cfuns(env, NULL, cfuns);
return 0; return 0;
} }
#endif

View File

@ -48,12 +48,6 @@
[name & more] [name & more]
(tuple.slice (array.concat @['def name :private] more) 0)) (tuple.slice (array.concat @['def name :private] more) 0))
(defmacro defasm
"Define a function using assembly"
[name & body]
(def tab (apply table body))
(tuple 'def name (tuple asm (tuple 'quote tab))))
(defn defglobal (defn defglobal
"Dynamically create a global def." "Dynamically create a global def."
[name value] [name value]

View File

@ -594,9 +594,11 @@ JanetTable *janet_core_env(void) {
janet_lib_os(args); janet_lib_os(args);
janet_lib_parse(args); janet_lib_parse(args);
janet_lib_compile(args); janet_lib_compile(args);
janet_lib_asm(args);
janet_lib_string(args); janet_lib_string(args);
janet_lib_marsh(args); janet_lib_marsh(args);
#ifdef JANET_ASSEMBLER
janet_lib_asm(args);
#endif
} }
/* Allow references to the environment */ /* Allow references to the environment */

View File

@ -53,7 +53,9 @@ int janet_lib_os(JanetArgs args);
int janet_lib_string(JanetArgs args); int janet_lib_string(JanetArgs args);
int janet_lib_marsh(JanetArgs args); int janet_lib_marsh(JanetArgs args);
int janet_lib_parse(JanetArgs args); int janet_lib_parse(JanetArgs args);
#ifdef JANET_ASSEMBLER
int janet_lib_asm(JanetArgs args); int janet_lib_asm(JanetArgs args);
#endif
int janet_lib_compile(JanetArgs args); int janet_lib_compile(JanetArgs args);
#endif #endif

View File

@ -109,6 +109,11 @@ extern "C" {
#define JANET_DYNAMIC_MODULES #define JANET_DYNAMIC_MODULES
#endif #endif
/* Enable or disable the assembler. Enabled by default. */
#ifndef JANET_NO_ASSEMBLER
#define JANET_ASSEMBLER
#endif
/* How to export symbols */ /* How to export symbols */
#ifndef JANET_API #ifndef JANET_API
#ifdef JANET_WINDOWS #ifdef JANET_WINDOWS
@ -852,8 +857,8 @@ JANET_API void janet_parser_flush(JanetParser *parser);
JANET_API JanetParser *janet_check_parser(Janet x); JANET_API JanetParser *janet_check_parser(Janet x);
/* Assembly */ /* Assembly */
#ifdef JANET_ASSEMBLER
typedef struct JanetAssembleResult JanetAssembleResult; typedef struct JanetAssembleResult JanetAssembleResult;
typedef struct JanetAssembleOptions JanetAssembleOptions;
enum JanetAssembleStatus { enum JanetAssembleStatus {
JANET_ASSEMBLE_OK, JANET_ASSEMBLE_OK,
JANET_ASSEMBLE_ERROR JANET_ASSEMBLE_ERROR
@ -866,9 +871,9 @@ struct JanetAssembleResult {
JANET_API JanetAssembleResult janet_asm(Janet source, int flags); JANET_API JanetAssembleResult janet_asm(Janet source, int flags);
JANET_API Janet janet_disasm(JanetFuncDef *def); JANET_API Janet janet_disasm(JanetFuncDef *def);
JANET_API Janet janet_asm_decode_instruction(uint32_t instr); JANET_API Janet janet_asm_decode_instruction(uint32_t instr);
#endif
/* Compilation */ /* Compilation */
typedef struct JanetCompileOptions JanetCompileOptions;
typedef struct JanetCompileResult JanetCompileResult; typedef struct JanetCompileResult JanetCompileResult;
enum JanetCompileStatus { enum JanetCompileStatus {
JANET_COMPILE_OK, JANET_COMPILE_OK,

View File

@ -46,7 +46,7 @@
(+= i (dohandler (string.slice arg 1 2) i)) (+= i (dohandler (string.slice arg 1 2) i))
(do (do
(:= *no-file* false) (:= *no-file* false)
(import* _env arg :exit *exit-on-error*) (import* _env arg :prefix "" :exit *exit-on-error*)
(++ i)))) (++ i))))
(when (or *should-repl* *no-file*) (when (or *should-repl* *no-file*)