Browse Source

move stuff around, fix strset issue

master
Martin Dørum 3 years ago
parent
commit
5b5dc3a43d
11 changed files with 4 additions and 5 deletions
  1. 1
    1
      build.bx
  2. 0
    0
      cmd/main.c
  3. 0
    3
      include/lang2/vm/vm.h
  4. 0
    0
      lib/bitset.c
  5. 0
    0
      lib/gen/gen.c
  6. 0
    0
      lib/io.c
  7. 0
    0
      lib/parse/lex.c
  8. 0
    0
      lib/parse/parse.c
  9. 3
    1
      lib/strset.c
  10. 0
    0
      lib/vm/namespace.c
  11. 0
    0
      lib/vm/vm.c

+ 1
- 1
build.bx View File

includes := include/lang2 includes := include/lang2
files := src
files := lib cmd

src/main.c → cmd/main.c View File


+ 0
- 3
include/lang2/vm/vm.h View File

l2_word data[]; l2_word data[];
}; };


void l2_vm_array_mark(struct l2_vm_value *arr);

struct l2_vm_namespace { struct l2_vm_namespace {
struct l2_vm_value *parent; struct l2_vm_value *parent;
size_t len; size_t len;
l2_word data[]; l2_word data[];
}; };


void l2_vm_namespace_mark(struct l2_vm_value *ns);
void l2_vm_namespace_set(struct l2_vm_value *ns, l2_word key, l2_word val); void l2_vm_namespace_set(struct l2_vm_value *ns, l2_word key, l2_word val);
l2_word l2_vm_namespace_get(struct l2_vm_value *ns, l2_word key); l2_word l2_vm_namespace_get(struct l2_vm_value *ns, l2_word key);



src/bitset.c → lib/bitset.c View File


src/gen/gen.c → lib/gen/gen.c View File


src/io.c → lib/io.c View File


src/parse/lex.c → lib/parse/lex.c View File


src/parse/parse.c → lib/parse/parse.c View File


src/strset.c → lib/strset.c View File

for (size_t j = 0; ; ++j) { for (size_t j = 0; ; ++j) {
size_t index = (h + j) & set->mask; size_t index = (h + j) & set->mask;
char *k = set->keys[index]; char *k = set->keys[index];
if (k == NULL || strcmp(oldkey, k) != 0) {
if (k != NULL) {
continue; continue;
} }


if (k == NULL) { if (k == NULL) {
set->keys[index] = *str; set->keys[index] = *str;
set->vals[index] = set->next++; set->vals[index] = set->next++;
set->len += 1;
*str = NULL; *str = NULL;
return set->vals[index]; return set->vals[index];
} else if (strcmp(*str, k) == 0) { } else if (strcmp(*str, k) == 0) {
if (k == NULL) { if (k == NULL) {
set->keys[index] = strdup(str); set->keys[index] = strdup(str);
set->vals[index] = set->next++; set->vals[index] = set->next++;
set->len += 1;
return set->vals[index]; return set->vals[index];
} else if (strcmp(str, k) == 0) { } else if (strcmp(str, k) == 0) {
return set->vals[index]; return set->vals[index];

src/vm/namespace.c → lib/vm/namespace.c View File


src/vm/vm.c → lib/vm/vm.c View File


Loading…
Cancel
Save