nitron

commit 01e21584342deaf8e66191d917b7e7440a86bf40

Author: mesyeti <mesyeti@mesyeti.uk>

fix compiler bugs

 basic-std/std/file.bas | 14 +++++++-------
 basic/source/frontend/c89.c | 24 +++++++++++++++++++-----
 basic/source/parser.c | 4 ++++


diff --git a/basic/source/frontend/c89.c b/basic/source/frontend/c89.c
index 7b42d247cb1fc5f0cd9097d02342d8feb23f9a09..79cf2fcd6e32f328a51f894e585f066d44cd2568 100644
--- a/basic/source/frontend/c89.c
+++ b/basic/source/frontend/c89.c
@@ -100,8 +100,10 @@
 	// add parameters
 	for (size_t i = 0; i < node->dec.paramsNum; ++ i) {
 		Var var;
-		var.type = SemanticAnalysis_NodeAsUsedType(node->dec.params[i].type);
-		var.name = NewString(node->dec.params[i].name);
+		var.type     = SemanticAnalysis_NodeAsUsedType(node->dec.params[i].type);
+		var.name     = NewString(node->dec.params[i].name);
+		var.private  = false;
+		var.isStatic = false;
 
 		State_AddVar(var);
 	}
@@ -130,8 +132,10 @@ 	);
 
 	// add variable to state
 	Var var;
-	var.type = SemanticAnalysis_NodeAsUsedType(node->varType);
-	var.name = NewString(node->name);
+	var.type     = SemanticAnalysis_NodeAsUsedType(node->varType);
+	var.name     = NewString(node->name);
+	var.private  = SemanticAnalysis_GetExternal() && node->private;
+	var.isStatic = false;
 
 	if (node->array) {
 		var.type.array = node->arrayLen->integer.value;
@@ -192,6 +196,12 @@
 			if (!var) {
 				Const* constant = State_GetConst(node->ident.name);
 
+				if (!constant) {
+					fprintf(stderr, "WARNING! The error message below is an INTERNAL ERROR! ");
+					fprintf(stderr, "Please report it as a bug!\n");
+					PrintError(node->i.err, "Could not find variable/constant '%s'", node->ident.name);
+				}
+
 				fprintf(out, "%lld", constant->value);
 				break;
 			}
@@ -271,6 +281,8 @@ 					}
 					else {
 						fprintf(out, ".");
 					}
+
+					fprintf(out, "nitron_%s", node->bin.right->ident.name);
 					break;
 				}
 				case TOKEN_LPAREN: break; // function call, nothing to do
@@ -278,7 +290,9 @@ 				case TOKEN_LSQUARE: fprintf(out, "["); break;
 				default: assert(0);
 			}
 
-			CompileExprNode(node->bin.right);
+			if (node->bin.op != TOKEN_DOT) {
+				CompileExprNode(node->bin.right);
+			}
 
 			if (node->bin.op == TOKEN_LSQUARE) {
 				fprintf(out, "]");




diff --git a/basic/source/parser.c b/basic/source/parser.c
index d7a010a9be92d6adeabb30512dc7b46b1299149f..7983756bb3606ba39d6cb7f2a7a471404dce6517 100644
--- a/basic/source/parser.c
+++ b/basic/source/parser.c
@@ -505,6 +505,10 @@ 	Advance(p);
 	Expect(p, TOKEN_IDENTIFIER);
 	ret.name = NewString(p->tokens[p->i].contents);
 
+	if (p->private) {
+		printf("Making private dim node '%s'\n", ret.name);
+	}
+
 	Advance(p);
 
 	if (p->tokens[p->i].type == TOKEN_LSQUARE) {




diff --git a/basic-std/std/file.bas b/basic-std/std/file.bas
index 0c8fe4aae59d0ac74276b32a6e3984d61822370f..a1a74577afeed129f06a4e2a9751dab838359598 100644
--- a/basic-std/std/file.bas
+++ b/basic-std/std/file.bas
@@ -42,10 +42,10 @@ func File_Read(this as ptr(File), size as uint, output as ptr(unit)) uint
 	return fread(output, 1, size, this.file)
 end
 
-'func File_Peek(this as ptr(File)) uint
-''	return ftell(this.file) as uint
-'end
-''
-'func File_Seek(this as ptr(File), where as uint, offset as int) bool
-''	return fseek(this.file, offset, where as i32) == 0
-'end
+func File_Peek(this as ptr(File)) uint
+	return ftell(this.file) as uint
+end
+
+func File_Seek(this as ptr(File), where as uint, offset as int) bool
+	return fseek(this.file, offset, where as i32) == 0
+end