summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/help.txt2
-rw-r--r--docs/stats.txt2
-rw-r--r--docs/version.txt2
-rw-r--r--src/build.h2
-rw-r--r--src/core/interpret.c10
-rw-r--r--src/core/scope.c22
-rw-r--r--src/core/token.c6
-rw-r--r--src/data/hash.c4
-rw-r--r--src/data/stack.c9
-rw-r--r--src/data/stack.h2
-rw-r--r--src/defines.h2
-rw-r--r--tmp/test.fy10
-rw-r--r--tmp/test.out119
13 files changed, 137 insertions, 55 deletions
diff --git a/docs/help.txt b/docs/help.txt
index 0a5fa00..66881ef 100644
--- a/docs/help.txt
+++ b/docs/help.txt
@@ -1,4 +1,4 @@
-Fype v0.1-devel Build 9596
+Fype v0.1-devel Build 9640
Copyright by Paul C. Buetow (2005 - 2008) <fype@dev.buetow.org>
-e Executes given code string (see synopses)
-h Prints this help
diff --git a/docs/stats.txt b/docs/stats.txt
index d390ccd..207f2b8 100644
--- a/docs/stats.txt
+++ b/docs/stats.txt
@@ -1,4 +1,4 @@
===> Num of C source files : 42
-===> Num of C source lines : 7713
+===> Num of C source lines : 7714
===> Num of Fype source examples : 13
===> Num of Fype source lines : 323
diff --git a/docs/version.txt b/docs/version.txt
index 8869d61..549fead 100644
--- a/docs/version.txt
+++ b/docs/version.txt
@@ -1 +1 @@
-Fype v0.1-devel Build 9596
+Fype v0.1-devel Build 9640
diff --git a/src/build.h b/src/build.h
index df9738e..cb7e720 100644
--- a/src/build.h
+++ b/src/build.h
@@ -35,7 +35,7 @@
#ifndef BUILD_H
#define BUILD_H
-#define BUILDNR 9607
+#define BUILDNR 9654
#define OS_FREEBSD
#endif
diff --git a/src/core/interpret.c b/src/core/interpret.c
index a53f193..86d5a36 100644
--- a/src/core/interpret.c
+++ b/src/core/interpret.c
@@ -104,7 +104,7 @@ interpret_new(List *p_list_token, Hash *p_hash_syms) {
void
interpret_delete(Interpret *p_interpret) {
- if (!p_interpret)
+ if (p_interpret == NULL)
return;
if (p_interpret->b_scope_delete)
@@ -523,16 +523,16 @@ _control(Interpret *p_interpret) {
switch (tt) {
case TT_IF:
if (convert_to_integer_get(p_token_top)) {
- scope_up(p_interpret->p_scope);
+ //scope_up(p_interpret->p_scope);
ret = interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
+ //scope_down(p_interpret->p_scope);
}
break;
case TT_IFNOT:
if (!convert_to_integer_get(p_token_top)) {
- scope_up(p_interpret->p_scope);
+ //scope_up(p_interpret->p_scope);
ret = interpret_subprocess(p_interpret, p_list_block);
- scope_down(p_interpret->p_scope);
+ //scope_down(p_interpret->p_scope);
}
break;
NO_DEFAULT;
diff --git a/src/core/scope.c b/src/core/scope.c
index 1eaac8f..ecf5933 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -61,41 +61,41 @@ scope_delete(Scope *p_scope) {
void
scope_up(Scope *p_scope) {
-#ifdef EXTRA_CHECKS
+#ifdef EXTRA_CHECKS
int i_before = (int) stack_size(p_scope->p_stack_scopes);
#elif DEBUG_SCOPE_UPDOWN
int i_before = (int) stack_size(p_scope->p_stack_scopes);
#endif
stack_push(p_scope->p_stack_scopes, hash_new(24));
#ifdef DEBUG_SCOPE_UPDOWN
- printf("SCOPE UPPED %d => %d\n",
- i_before,
- (int) stack_size(p_scope->p_stack_scopes));
+ printf("SCOPE UPPED %d => %d\n",
+ i_before,
+ (int) stack_size(p_scope->p_stack_scopes));
#endif /* DEBUG_SCOPE_UPDOWN */
#ifdef EXTRA_CHECKS
if (i_before >= (int) stack_size(p_scope->p_stack_scopes))
- _SCOPE_ERROR("Scope should be higher");
+ _SCOPE_ERROR("Scope should be higher");
#endif /* EXTRA_CHECKS */
}
void
scope_down(Scope *p_scope) {
-#ifdef EXTRA_CHECKS
+#ifdef EXTRA_CHECKS
int i_before = (int) stack_size(p_scope->p_stack_scopes);
#elif DEBUG_SCOPE_UPDOWN
int i_before = (int) stack_size(p_scope->p_stack_scopes);
-#endif
+#endif
Hash *p_hash_syms = stack_pop(p_scope->p_stack_scopes);
hash_iterate(p_hash_syms, symbol_cleanup_hash_syms_cb);
hash_delete(p_hash_syms);
#ifdef DEBUG_SCOPE_UPDOWN
- printf("SCOPE DOWNED %d => %d\n",
- i_before,
- (int) stack_size(p_scope->p_stack_scopes));
+ printf("SCOPE DOWNED %d => %d\n",
+ i_before,
+ (int) stack_size(p_scope->p_stack_scopes));
#endif /* DEBUG_SCOPE_UPDOWN */
#ifdef EXTRA_CHECKS
if (i_before <= (int) stack_size(p_scope->p_stack_scopes))
- _SCOPE_ERROR("Scope should be lower");
+ _SCOPE_ERROR("Scope should be lower");
#endif /* EXTRA_CHECKS */
}
diff --git a/src/core/token.c b/src/core/token.c
index 9162c4d..4bed0e0 100644
--- a/src/core/token.c
+++ b/src/core/token.c
@@ -396,10 +396,10 @@ token_delete(Token *p_token) {
_token_free(p_token);
- }
+ }
#ifdef DEBUG_TOKEN_REFCOUNT
- else if (p_token->i_ref_count < 0) {
- token_print_ln(p_token);
+ else if (p_token->i_ref_count < 0) {
+ token_print_ln(p_token);
printf("Token ref count is 0 > %d\n",
p_token->i_ref_count);
}
diff --git a/src/data/hash.c b/src/data/hash.c
index 5555eb1..d3f7634 100644
--- a/src/data/hash.c
+++ b/src/data/hash.c
@@ -44,13 +44,13 @@ hash_new(unsigned i_size) {
p_hash->i_size = i_size;
p_hash->i_cur_size = 0;
- p_hash->p_elems = (HashElem *) calloc(i_size, sizeof(HashElem));
+ p_hash->p_elems = (HashElem *) calloc((int)i_size, sizeof(HashElem));
/*Set all positions as "free" */
for (int i = 0; i < i_size; ++i)
p_hash->p_elems[i].flag = 'f';
- return p_hash;
+ return (p_hash);
}
void
diff --git a/src/data/stack.c b/src/data/stack.c
index 778e41e..0f5f58e 100644
--- a/src/data/stack.c
+++ b/src/data/stack.c
@@ -63,7 +63,7 @@ stack_empty(Stack *p_stack) {
void
stack_debug(Stack *p_stack, void *p_val) {
- printf("bPUSH %d %d\n", stack_size(p_stack), (int)p_stack);
+ printf("bPUSH %d %d\n", stack_size(p_stack), (int)p_stack);
StackElem *p_elem = stackelem_new();
p_elem->p_val = p_val;
@@ -74,13 +74,12 @@ stack_debug(Stack *p_stack, void *p_val) {
p_stack->p_last = p_stack->p_first;
++p_stack->i_size;
- printf("aPUSH %d %d\n", stack_size(p_stack), (int)p_stack);
+ printf("aPUSH %d %d\n", stack_size(p_stack), (int)p_stack);
}
-void
+unsigned
stack_push(Stack *p_stack, void *p_val) {
StackElem *p_elem = stackelem_new();
-
p_elem->p_val = p_val;
p_elem->p_next = p_stack->p_first;
p_stack->p_first = p_elem;
@@ -88,7 +87,7 @@ stack_push(Stack *p_stack, void *p_val) {
if (p_stack->p_last == NULL)
p_stack->p_last = p_stack->p_first;
- ++p_stack->i_size;
+ return (++p_stack->i_size);
}
void*
diff --git a/src/data/stack.h b/src/data/stack.h
index 721ed31..e9fafea 100644
--- a/src/data/stack.h
+++ b/src/data/stack.h
@@ -59,7 +59,7 @@ Stack *stack_new();
StackElem *stackelem_new();
_Bool stack_empty(Stack *p_stack);
void stack_iterate(Stack *p_stack, void (*func)(void *p_void));
-void stack_push(Stack *p_stack, void *p_val);
+unsigned stack_push(Stack *p_stack, void *p_val);
void stack_debug(Stack *p_stack, void *p_val);
void *stack_pop(Stack *p_stack);
void stack_clear(Stack *p_stack);
diff --git a/src/defines.h b/src/defines.h
index 9842c4f..29df2c2 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -79,7 +79,7 @@
#define DEBUG_SCOPE_UPDOWN
//#define DEBUG_TOKEN_REFCOUNT
//#define DEBUG_FUNCTION_PROCESS
-//#define DEBUG_TRACK
+#define DEBUG_TRACK
//#define DEBUG_BLOCK_GET
//#define DEBUG_EXPRESSION_GET
//#define DEBUG_ARRAY_GET
diff --git a/tmp/test.fy b/tmp/test.fy
index adb8384..da59a2a 100644
--- a/tmp/test.fy
+++ b/tmp/test.fy
@@ -1,4 +1,12 @@
+my foo = 1;
+
+if 1 {
+ say foo;
+}
+
+say 1 + 1;
+
#my foo = [1 2 3];
# Prints num of elements in foo
@@ -15,4 +23,4 @@
# Prints "1 3 5 6\n"
#say [1 3 5 6];
-my foo = 2 * 3 + 1.2;
+#my foo = 2 * 3 + 1.2;
diff --git a/tmp/test.out b/tmp/test.out
index 4b4fdc1..9028487 100644
--- a/tmp/test.out
+++ b/tmp/test.out
@@ -1,4 +1,12 @@
+my foo = 1;
+
+if 1 {
+ say foo;
+}
+
+say 1 + 1;
+
#my foo = [1 2 3];
# Prints num of elements in foo
@@ -15,25 +23,92 @@
# Prints "1 3 5 6\n"
#say [1 3 5 6];
-my foo = 2 * 3 + 1.2;
-Token (org=1, id=00000, line=00018, pos=0003, type=TT_MY, val=my, ival=0, dval=0.000000, refs=1)
-Token (org=1, id=00001, line=00018, pos=0007, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
-Token (org=1, id=00002, line=00018, pos=0009, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
-Token (org=1, id=00003, line=00018, pos=0011, type=TT_INTEGER, val=2, ival=2, dval=0.000000, refs=1)
-Token (org=1, id=00004, line=00018, pos=0013, type=TT_MULT, val=*, ival=0, dval=0.000000, refs=1)
-Token (org=1, id=00005, line=00018, pos=0015, type=TT_INTEGER, val=3, ival=3, dval=0.000000, refs=1)
-Token (org=1, id=00006, line=00018, pos=0017, type=TT_ADD, val=+, ival=0, dval=0.000000, refs=1)
-Token (org=1, id=00009, line=00018, pos=0021, type=TT_DOUBLE, val=1.2, ival=2, dval=1.200000, refs=1)
-Token (org=1, id=00010, line=00018, pos=0022, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
-(org=0, id=00011, line=00018, pos=0015, type=TT_INTEGER, val=3, ival=6, dval=0.000000, refs=-1)
-Token ref count is 0 > -1
-(org=0, id=00012, line=00018, pos=0011, type=TT_INTEGER, val=2, ival=2, dval=0.000000, refs=-1)
-Token ref count is 0 > -1
-(org=0, id=00013, line=00018, pos=0021, type=TT_INTEGER, val=1.2, ival=4, dval=7.200000, refs=-1)
-Token ref count is 0 > -1
-(org=0, id=00014, line=00018, pos=0015, type=TT_DOUBLE, val=3, ival=6, dval=6.000000, refs=-1)
-Token ref count is 0 > -1
-The garbage collector still has 2 registered items which don't have a zero ref count!
-(org=1, id=00007, line=00018, pos=0019, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
-(org=1, id=00008, line=00018, pos=0020, type=TT_DOT, val=., ival=0, dval=0.000000, refs=1)
-Garbage left: Garbage error (Fype @ ./src/core/garbage.c line 88)
+#my foo = 2 * 3 + 1.2;
+Token (org=1, id=00000, line=00002, pos=0003, type=TT_MY, val=my, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00001, line=00002, pos=0007, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00002, line=00002, pos=0009, type=TT_ASSIGN, val==, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00003, line=00002, pos=0011, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
+Token (org=1, id=00004, line=00002, pos=0012, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00005, line=00004, pos=0003, type=TT_IF, val=if, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00006, line=00004, pos=0005, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
+Token (org=1, id=00007, line=00004, pos=0007, type=TT_PARANT_CL, val={, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00008, line=00005, pos=0005, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00009, line=00005, pos=0009, type=TT_IDENT, val=foo, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00010, line=00005, pos=0010, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00011, line=00006, pos=0002, type=TT_PARANT_CR, val=}, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00012, line=00008, pos=0004, type=TT_IDENT, val=say, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00013, line=00008, pos=0006, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
+Token (org=1, id=00014, line=00008, pos=0008, type=TT_ADD, val=+, ival=0, dval=0.000000, refs=1)
+Token (org=1, id=00015, line=00008, pos=0010, type=TT_INTEGER, val=1, ival=1, dval=0.000000, refs=1)
+Token (org=1, id=00016, line=00008, pos=0011, type=TT_SEMICOLON, val=;, ival=0, dval=0.000000, refs=1)
+DEBUG(Track: ./src/core/interpret.c:_program:166)
+DEBUG(Token: my)
+DEBUG(Track: ./src/core/interpret.c:_statement:448)
+DEBUG(Token: my)
+DEBUG(Track: ./src/core/interpret.c:_proc_decl:380)
+DEBUG(Token: my)
+DEBUG(Track: ./src/core/interpret.c:_func_decl:414)
+DEBUG(Token: my)
+DEBUG(Track: ./src/core/interpret.c:_var_decl:181)
+DEBUG(Token: my)
+DEBUG(Track: ./src/core/interpret.c:_var_assign:216)
+DEBUG(Token: foo)
+DEBUG(Track: ./src/core/interpret.c:_compare:640)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_sum:691)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_product:742)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_product2:780)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_term:814)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_var_list:260)
+DEBUG(Token: ;)
+DEBUG(Track: ./src/core/interpret.c:_statement:448)
+DEBUG(Token: if)
+DEBUG(Track: ./src/core/interpret.c:_proc_decl:380)
+DEBUG(Token: if)
+DEBUG(Track: ./src/core/interpret.c:_func_decl:414)
+DEBUG(Token: if)
+DEBUG(Track: ./src/core/interpret.c:_var_decl:181)
+DEBUG(Token: if)
+DEBUG(Track: ./src/core/interpret.c:_control:507)
+DEBUG(Token: if)
+DEBUG(Track: ./src/core/interpret.c:_compare:640)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_sum:691)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_product:742)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_product2:780)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_term:814)
+DEBUG(Token: 1)
+DEBUG(Track: ./src/core/interpret.c:_program:166)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_statement:448)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_proc_decl:380)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_func_decl:414)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_var_decl:181)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_control:507)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_expression:483)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_compare:640)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_sum:691)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_product:742)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_product2:780)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_term:814)
+DEBUG(Token: say)
+DEBUG(Track: ./src/core/interpret.c:_compare:640)
+DEBUG(Token: foo)
+DEBUG(Track: ./src/core/ \ No newline at end of file