1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-03 00:53:01 +00:00

Add makefile back.

This commit is contained in:
Calvin Rose
2018-03-18 09:13:21 -04:00
parent 17c466873d
commit 82e5d915f7
14 changed files with 81 additions and 52 deletions

View File

@@ -324,8 +324,8 @@ static uint32_t doarg(
int32_t arg = doarg_1(a, argtype, x);
/* Calculate the min and max values that can be stored given
* nbytes, and whether or not the storage is signed */
int32_t min = (-hassign) << ((nbytes << 3) - 1);
int32_t max = ~((-1) << ((nbytes << 3) - hassign));
int32_t max = (1 << ((nbytes << 3) - hassign)) - 1;
int32_t min = hassign ? -max - 1 : 0;
if (arg < min)
dst_asm_errorv(a, dst_formatc("instruction argument %v is too small, must be %d byte%s",
x, nbytes, nbytes > 1 ? "s" : ""));

View File

@@ -415,15 +415,19 @@ onvalue."
{:more more :next next})
(fn [env chunks onvalue onerr]
(defn doone [source]
(var good true)
(def f (fiber (fn []
(def res (compile source env))
(if (= (type res) :function)
(res)
(onerr "compile" (get res :error))))))
(do
(:= good false)
(onerr "compile" (get res :error)))))))
(def res (resume f))
(if (= (fiber-status f) :error)
(onerr "runtime" res)
(onvalue res)))
(if good
(if (= (fiber-status f) :error)
(onerr "runtime" res)
(onvalue res))))
(foreach (val-stream chunks onerr) doone)
env)))

View File

@@ -378,9 +378,10 @@ static void dstc_loadconst(DstCompiler *c, DstAst *ast, Dst k, int32_t dest) {
DOP_LOAD_INTEGER);
break;
}
/* fallthrough */
goto do_constant;
}
default:
do_constant:
{
int32_t cindex = dstc_const(c, ast, k);
dstc_emit(c, ast,

View File

@@ -28,7 +28,7 @@
#include <dst/dstcompile.h>
/* Generated header */
#include "dststlbootstrap.h"
#include "dststlbootstrap.gen.h"
static const DstReg cfuns[] = {
{"native", dst_core_native},

View File

@@ -219,8 +219,8 @@ static void inc_counter(uint8_t *digits, int base, int len) {
* symbol will be of the format prefix--XXXXXX, where X is a base64 digit, and
* prefix is the argument passed. */
const uint8_t *dst_symbol_gen(const uint8_t *buf, int32_t len) {
const uint8_t **bucket;
int32_t hash;
const uint8_t **bucket = NULL;
int32_t hash = 0;
uint8_t counter[6] = {63, 63, 63, 63, 63, 63};
/* Leave spaces for 6 base 64 digits and two dashes. That means 64^6 possible suffixes, which
* is enough for resolving collisions. */

View File

@@ -810,7 +810,7 @@ int dst_init() {
* a collection pretty much every cycle, which is
* horrible for performance, but helps ensure
* there are no memory bugs during dev */
dst_vm_gc_interval = 0x100000;
dst_vm_gc_interval = 0x10000;
dst_symcache_init();
/* Initialize gc roots */
dst_vm_roots = NULL;

View File

@@ -71,13 +71,13 @@ https://github.com/antirez/linenoise/blob/master/linenoise.c
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include <headerlibs/vector.h>
@@ -103,6 +103,15 @@ static const char *badterms[] = {
NULL
};
static char *sdup(const char *s) {
size_t len = strlen(s) + 1;
char *mem = malloc(len);
if (!mem) {
return NULL;
}
return memcpy(mem, s, len);
}
/* Ansi terminal raw mode */
static int rawmode() {
struct termios t;
@@ -227,7 +236,7 @@ static int insert(char c) {
static void historymove(int delta) {
if (dst_v_count(history) > 1) {
free(history[historyi]);
history[historyi] = strdup(buf);
history[historyi] = sdup(buf);
historyi += delta;
if (historyi < 0) {
@@ -247,7 +256,7 @@ static void historymove(int delta) {
static void addhistory() {
int i, len;
char *newline = strdup(buf);
char *newline = sdup(buf);
if (!newline) return;
len = dst_v_count(history);
if (len < DST_HISTORY_MAX) {
@@ -261,7 +270,7 @@ static void addhistory() {
}
static void replacehistory() {
char *newline = strdup(buf);
char *newline = sdup(buf);
if (!newline) return;
history[0] = newline;
}
@@ -418,7 +427,7 @@ static int checktermsupport() {
int i;
if (!t) return 1;
for (i = 0; badterms[i]; i++)
if (!strcasecmp(t, badterms[i])) return 0;
if (!strcmp(t, badterms[i])) return 0;
return 1;
}

View File

@@ -23,7 +23,7 @@
#include <dst/dst.h>
#include <dst/dstcompile.h>
#include "clientinit.h"
#include "clientinit.gen.h"
#include "line.h"
int main(int argc, char **argv) {