-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfwc-vm.h
More file actions
76 lines (67 loc) · 2.1 KB
/
fwc-vm.h
File metadata and controls
76 lines (67 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// A Tachyon inspired system, MIT license, (c) 2025 Chris Curl
#ifndef __QWC_H__
#define VERSION 20260309
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define IS_WINDOWS 1
#define strEqI(s, d) (_strcmpi(s, d) == 0)
#define BIN_DIR "\\bin\\"
#else
#define strEqI(s, d) (strcasecmp(s, d) == 0)
#define BIN_DIR "/home/chris/bin/"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#if INTPTR_MAX > INT32_MAX
#define LIT_MASK 0x7FF8000000000000
#define LIT_BITS 0x0007FFFFFFFFFFFF
#define CELL_SZ 8
#define cell int64_t
#define ucell uint64_t
#else
#define LIT_MASK 0x40000000
#define LIT_BITS 0x3FFFFFFF
#define CELL_SZ 4
#define cell int32_t
#define ucell uint32_t
#endif
#define byte uint8_t
#define MEM_SZ 0x1000000
#define STK_SZ 63
#define IMMED 0x80
#define INLINE 0x40
#define btwi(n,l,h) ((l<=n) && (n<=h))
#define TOS dstk[dsp]
#define NOS dstk[dsp-1]
#define L0 lstk[lsp]
#define L1 lstk[lsp-1]
#define L2 lstk[lsp-2]
enum { INTERPRET=0, COMPILE=1, BYE=999 };
typedef struct { ucell xt; byte sz; byte fl; byte ln; char nm[1]; } DE_T;
typedef struct { char *name; ucell value; } NVP_T;
// These are defined by fwc-vm.c
extern void inner(ucell start);
extern void outer(const char *src);
extern void addLit(const char *name, cell val);
extern void fwcInit();
extern int nextWord();
extern DE_T *addToDict(const char *w);
extern void compileNum(cell n);
extern cell state;
extern ucell outputFp;
extern char mem[];
// fwc-vm.c needs these to be defined
extern void zType(const char *str);
extern void emit(const char ch);
extern int key();
extern int qKey();
extern cell timer();
extern void ms(cell sleepForMS);
extern cell fOpen(cell name, cell mode);
extern void fClose(cell fh);
extern cell fRead(cell buf, cell sz, cell fh);
extern cell fWrite(cell buf, cell sz, cell fh);
#endif // __QWC_H__