changeset 391:c1d83336e1d1

Fixed problem with structure member registration and fixed detection of operator{} type symbols in expression evaluation
author lost@l-w.ca
date Wed, 21 Jul 2010 21:26:43 -0600
parents 027d7fbcdcfc
children e3567a9f0d54
files lwasm/lwasm.c lwasm/pseudo.c
diffstat 2 files changed, 34 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/lwasm.c	Wed Jul 14 22:46:56 2010 -0600
+++ b/lwasm/lwasm.c	Wed Jul 21 21:26:43 2010 -0600
@@ -415,6 +415,13 @@
 		}
 		if (l == 0)
 			return NULL;
+
+		if ((*p)[l] == '{')
+		{
+			while ((*p)[l] && (*p)[l] != '}')
+				l++;
+			l++;
+		}
 		
 		if (havedol || **p < '0' || **p > '9')
 		{
--- a/lwasm/pseudo.c	Wed Jul 14 22:46:56 2010 -0600
+++ b/lwasm/pseudo.c	Wed Jul 21 21:26:43 2010 -0600
@@ -305,6 +305,7 @@
 		lwasm_register_error(as, l, "Bad expression");
 	}
 
+	l -> lint = 0;
 	if (as -> instruct)
 	{
 		lwasm_reduce_expr(as, expr);
@@ -318,6 +319,8 @@
 			e = lw_expr_intval(expr);
 			register_struct_entry(as, l, e, NULL);
 			l -> len = 0;
+			l -> lint = 1;
+			l -> symset = 1;
 		}
 	}
 	
@@ -328,6 +331,9 @@
 {
 	lw_expr_t expr;
 	
+	if (l -> lint)
+		return;
+	
 	if (l -> len >= 0)
 		return;
 	
@@ -341,6 +347,9 @@
 
 EMITFUNC(pseudo_emit_rmb)
 {
+	if (l -> lint)
+		return;
+
 	if (l -> len < 0)
 		lwasm_register_error(as, l, "Expression not constant");
 }
@@ -349,6 +358,7 @@
 {
 	lw_expr_t expr;
 	
+	l -> lint = 0;
 	expr = lwasm_parse_expr(as, p);
 	if (!expr)
 	{
@@ -368,6 +378,8 @@
 			e = lw_expr_intval(expr) * 2;
 			register_struct_entry(as, l, e, NULL);
 			l -> len = 0;
+			l -> symset = 1;
+			l -> lint = 1;
 		}
 	}
 	lwasm_save_expr(l, 0, expr);
@@ -377,6 +389,9 @@
 {
 	lw_expr_t expr;
 	
+	if (l -> lint)
+		return;
+	
 	if (l -> len >= 0)
 		return;
 	
@@ -390,6 +405,9 @@
 
 EMITFUNC(pseudo_emit_rmd)
 {
+	if (l -> lint)
+		return;
+
 	if (l -> len < 0)
 		lwasm_register_error(as, l, "Expression not constant");
 }
@@ -399,6 +417,7 @@
 {
 	lw_expr_t expr;
 	
+	l -> lint = 0;
 	expr = lwasm_parse_expr(as, p);
 	if (!expr)
 	{
@@ -417,6 +436,8 @@
 			e = lw_expr_intval(expr) * 4;
 			register_struct_entry(as, l, e, NULL);
 			l -> len = 0;
+			l -> symset = 1;
+			l -> lint = 1;
 		}
 	}
 	
@@ -426,6 +447,9 @@
 RESOLVEFUNC(pseudo_resolve_rmq)
 {
 	lw_expr_t expr;
+
+	if (l -> lint)
+		return;
 	
 	if (l -> len >= 0)
 		return;
@@ -440,6 +464,9 @@
 
 EMITFUNC(pseudo_emit_rmq)
 {
+	if (l -> lint)
+		return;
+
 	if (l -> len < 0)
 		lwasm_register_error(as, l, "Expression not constant");
 }