changeset 167:50a6d232176c

rewrite GlobalExpressions, moved DsymbolTable to Global, some cleanup
author korDen
date Thu, 30 Sep 2010 12:13:49 +0400
parents d8565fbd755c
children ceed63f310fb
files dmd/CompoundStatement.d dmd/CppMangleState.d dmd/FuncDeclaration.d dmd/Global.d dmd/GlobalExpressions.d
diffstat 5 files changed, 30 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/CompoundStatement.d	Thu Sep 30 10:30:15 2010 +0400
+++ b/dmd/CompoundStatement.d	Thu Sep 30 12:13:49 2010 +0400
@@ -71,10 +71,7 @@
 		}
 	}
 	
-	static int indent = 0;
-	static int depth = 0;
-	
-    override Statement semantic(Scope sc)
+	override Statement semantic(Scope sc)
 	{
 		Statement s;
 
--- a/dmd/CppMangleState.d	Thu Sep 30 10:30:15 2010 +0400
+++ b/dmd/CppMangleState.d	Thu Sep 30 12:13:49 2010 +0400
@@ -6,7 +6,10 @@
 
 struct CppMangleState
 {
-    static __gshared Array components;
+	/**
+	 * Get rid of it or move to CompilerState
+	 */
+    // static __gshared Array components;
 
     int substitute(OutBuffer buf, void* p)
 	{
--- a/dmd/FuncDeclaration.d	Thu Sep 30 10:30:15 2010 +0400
+++ b/dmd/FuncDeclaration.d	Thu Sep 30 12:13:49 2010 +0400
@@ -2210,7 +2210,7 @@
 	 */
     BUILTIN isBuiltin()
 	{
-		static string FeZe = "FNaNbeZe";	// pure nothrow real function(real)
+		enum FeZe = "FNaNbeZe";	// pure nothrow real function(real)
 
 		//printf("FuncDeclaration::isBuiltin() %s\n", toChars());
 		if (builtin == BUILTIN.BUILTINunknown)
@@ -3101,21 +3101,17 @@
 		FuncDeclaration fd;
 		TypeFunction tf;
 		Dsymbol s;
-		static DsymbolTable st = null;
 
 		//printf("genCfunc(name = '%s')\n", id.toChars());
 		//printf("treturn\n\t"); treturn.print();
 
 		// See if already in table
-		if (!st)
-			st = new DsymbolTable();
-
-		s = st.lookup(id);
+		s = global.st.lookup(id);
 		if (s)
 		{
-			fd = s.isFuncDeclaration();
-			assert(fd);
-			assert(fd.type.nextOf().equals(treturn));
+			debug fd = s.isFuncDeclaration();
+			debug assert(fd);
+			debug assert(fd.type.nextOf().equals(treturn));
 		}
 		else
 		{
@@ -3124,7 +3120,7 @@
 			fd.protection = PROT.PROTpublic;
 			fd.linkage = LINK.LINKc;
 
-			st.insert(fd);
+			global.st.insert(fd);
 		}
 		return fd;
 	}
--- a/dmd/Global.d	Thu Sep 30 10:30:15 2010 +0400
+++ b/dmd/Global.d	Thu Sep 30 12:13:49 2010 +0400
@@ -4,6 +4,7 @@
 import dmd.Array;
 import dmd.Param;
 import dmd.ClassDeclaration;
+import dmd.DsymbolTable;
 
 class Global
 {
@@ -49,9 +50,13 @@
 	ClassDeclaration object;
     ClassDeclaration classinfo;
 	
+	// Used in FuncDeclaration.genCfunc()
+	DsymbolTable st;
+	
 	this()
 	{
 		params.versionids = new Array();
+		st = new DsymbolTable();
 	}
 }
 
--- a/dmd/GlobalExpressions.d	Thu Sep 30 10:30:15 2010 +0400
+++ b/dmd/GlobalExpressions.d	Thu Sep 30 12:13:49 2010 +0400
@@ -2,31 +2,22 @@
 
 import dmd.common;
 import dmd.Expression;
-import dmd.TOK;
-import dmd.Loc;
 
-Expression EXP_CANT_INTERPRET;
-Expression EXP_CONTINUE_INTERPRET;
-Expression EXP_BREAK_INTERPRET;
-Expression EXP_GOTO_INTERPRET;
-Expression EXP_VOID_INTERPRET;
-
-void* castToVoid(int i)
-{
-	return cast(void*)i;
-}
+__gshared Expression EXP_CANT_INTERPRET = castToExpression(1);
+__gshared Expression EXP_CONTINUE_INTERPRET = castToExpression(2);
+__gshared Expression EXP_BREAK_INTERPRET = castToExpression(3);
+__gshared Expression EXP_GOTO_INTERPRET = castToExpression(4);
+__gshared Expression EXP_VOID_INTERPRET = castToExpression(5);
 
-static this()
+Expression castToExpression(int i)
 {
-	//EXP_CANT_INTERPRET = new Expression(Loc(0), TOK.init, 0);
-	//EXP_CONTINUE_INTERPRET = new Expression(Loc(0), TOK.init, 0);
-	//EXP_BREAK_INTERPRET = new Expression(Loc(0), TOK.init, 0);
-	//EXP_GOTO_INTERPRET = new Expression(Loc(0), TOK.init, 0);
-	//EXP_VOID_INTERPRET = new Expression(Loc(0), TOK.init, 0);
+	union U
+	{
+		int i;
+		Expression e;
+	}
 	
-	EXP_CANT_INTERPRET = cast(Expression)castToVoid(1);
-	EXP_CONTINUE_INTERPRET = cast(Expression)castToVoid(2);
-	EXP_BREAK_INTERPRET = cast(Expression)castToVoid(3);
-	EXP_GOTO_INTERPRET = cast(Expression)castToVoid(4);
-	EXP_VOID_INTERPRET = cast(Expression)castToVoid(5);
+	U u;
+	u.i = i;
+	return u.e;
 }
\ No newline at end of file