1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-30 23:23:07 +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

@@ -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);