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

Move asm into core and rename to asm/disasm (no prefix)

This commit is contained in:
Calvin Rose 2018-06-29 22:52:55 -04:00
parent 1ea9ebf04f
commit fde9751eab
9 changed files with 25 additions and 78 deletions

View File

@ -34,10 +34,6 @@ SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
include_directories(src/include)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(ASSEMBLER_SOURCES
src/assembler/asm.c
)
set(COMPILER_SOURCES
src/compiler/compile.c
src/compiler/cfuns.c
@ -52,6 +48,7 @@ src/compiler/compile.h
set(CORE_SOURCES
src/core/abstract.c
src/core/array.c
src/core/asm.c
src/core/buffer.c
src/core/bytecode.c
src/core/corelib.c
@ -88,12 +85,7 @@ src/mainclient/line.c
src/mainclient/line.h
)
set(TESTLIB_SOURCES
src/testlib/testlib.c
)
set(REPL_SOURCES
${ASSEMBLER_SOURCES}
${COMPILER_SOURCES}
${CORE_SOURCES}
${MAINCLIENT_SOURCES}
@ -102,7 +94,6 @@ ${MAINCLIENT_SOURCES}
# Set Public headers
set(DST_PUBLIC_HEADERS
src/include/dst/dst.h
src/include/dst/dstasm.h
src/include/dst/dstcompile.h
src/include/dst/dstconfig.h
src/include/dst/dstcorelib.h

View File

@ -58,7 +58,6 @@ DST_ALL_HEADERS=$(DST_HEADERS) \
$(DST_GENERATED_HEADERS)
# Source files
DST_ASM_SOURCES=$(sort $(wildcard src/assembler/*.c))
DST_COMPILER_SOURCES=$(sort $(wildcard src/compiler/*.c))
DST_CORE_SOURCES=$(sort $(wildcard src/core/*.c))
DST_MAINCLIENT_SOURCES=$(sort $(wildcard src/mainclient/*.c))
@ -86,8 +85,7 @@ src/compiler/dststlbootstrap.gen.h: src/compiler/boot.dst xxd
##### The main interpreter program and shared object #####
##########################################################
DST_LIB_SOURCES=$(DST_ASM_SOURCES) \
$(DST_COMPILER_SOURCES) \
DST_LIB_SOURCES=$(DST_COMPILER_SOURCES) \
$(DST_CONTEXT_SOURCES) \
$(DST_CORE_SOURCES)

View File

@ -16,4 +16,4 @@
(bork 3)
1)
(pupper)
(do (pupper) 1)

View File

@ -247,7 +247,7 @@ value."
(error ("unexpected loop predicate: " verb)))
(switch
verb
:in-while (do
:iterate (do
(def preds @['and (tuple ':= bindings object)])
(def subloop (doone (+ i 3) preds))
(tuple 'do

View File

@ -23,7 +23,6 @@
#include <dst/dst.h>
#include <dst/dstopcodes.h>
#include <dst/dstcorelib.h>
#include <dst/dstasm.h>
#include <dst/dstcompile.h>
/* Generated header */

View File

@ -23,7 +23,6 @@
#include <setjmp.h>
#include <dst/dst.h>
#include <dst/dstasm.h>
#include <dst/dstopcodes.h>
#include <headerlibs/strbinsearch.h>
@ -904,7 +903,7 @@ Dst dst_disasm(DstFuncDef *def) {
}
/* C Function for assembly */
int dst_asm_cfun(DstArgs args) {
static int cfun_asm(DstArgs args) {
DstAssembleResult res;
DST_FIXARITY(args, 1);
res = dst_asm(args.v[0], 0);
@ -915,7 +914,7 @@ int dst_asm_cfun(DstArgs args) {
}
}
int dst_disasm_cfun(DstArgs args) {
int cfun_disasm(DstArgs args) {
DstFunction *f;
DST_FIXARITY(args, 1);
DST_ARG_FUNCTION(f, args, 0);
@ -923,8 +922,8 @@ int dst_disasm_cfun(DstArgs args) {
}
static const DstReg cfuns[] = {
{"asm.asm", dst_asm_cfun},
{"asm.disasm", dst_disasm_cfun},
{"asm", cfun_asm},
{"disasm", cfun_disasm},
{NULL, NULL}
};

View File

@ -46,6 +46,22 @@ const char *dst_parser_error(DstParser *parser);
void dst_parser_flush(DstParser *parser);
DstParser *dst_check_parser(Dst x);
/* Assembly */
typedef struct DstAssembleResult DstAssembleResult;
typedef struct DstAssembleOptions DstAssembleOptions;
enum DstAssembleStatus {
DST_ASSEMBLE_OK,
DST_ASSEMBLE_ERROR
};
struct DstAssembleResult {
DstFuncDef *funcdef;
const uint8_t *error;
enum DstAssembleStatus status;
};
DstAssembleResult dst_asm(Dst source, int flags);
Dst dst_disasm(DstFuncDef *def);
Dst dst_asm_decode_instruction(uint32_t instr);
/* Number scanning */
Dst dst_scan_number(const uint8_t *src, int32_t len);
int32_t dst_scan_integer(const uint8_t *str, int32_t len, int *err);

View File

@ -1,56 +0,0 @@
/*
* Copyright (c) 2018 Calvin Rose
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef DST_ASM_H_defined
#define DST_ASM_H_defined
#ifdef __cplusplus
extern "C" {
#endif
#include "dsttypes.h"
/* Assembly */
typedef struct DstAssembleResult DstAssembleResult;
typedef struct DstAssembleOptions DstAssembleOptions;
enum DstAssembleStatus {
DST_ASSEMBLE_OK,
DST_ASSEMBLE_ERROR
};
struct DstAssembleResult {
DstFuncDef *funcdef;
const uint8_t *error;
enum DstAssembleStatus status;
};
DstAssembleResult dst_asm(Dst source, int flags);
Dst dst_disasm(DstFuncDef *def);
Dst dst_asm_decode_instruction(uint32_t instr);
int dst_asm_cfun(DstArgs args);
int dst_disasm_cfun(DstArgs args);
int dst_lib_asm(DstArgs args);
#ifdef __cplusplus
}
#endif
#endif /* DST_ASM_H_defined */

View File

@ -101,7 +101,7 @@ int dst_lib_os(DstArgs args);
int dst_lib_string(DstArgs args);
int dst_lib_marsh(DstArgs args);
int dst_lib_parse(DstArgs args);
int dst_lib_asm(DstArgs args);
/* Useful for compiler */
Dst dst_op_add(Dst lhs, Dst rhs);