Nicolas Cannasse пре 7 година
родитељ
комит
fe02b1cea2
2 измењених фајлова са 55 додато и 6 уклоњено
  1. 49 0
      other/statics/Statics.hx
  2. 6 6
      src/jit.c

+ 49 - 0
other/statics/Statics.hx

@@ -0,0 +1,49 @@
+class Statics {
+
+	static var BASE_PATH = "../../";
+
+	static function loopRec( dir : String ) {
+		for( f in sys.FileSystem.readDirectory(BASE_PATH+dir) ) {
+			var path = dir + "/" + f;
+			if( sys.FileSystem.isDirectory(BASE_PATH+path) ) {
+				loopRec(path);
+				continue;
+			}
+			var ext = f.split(".").pop().toLowerCase();
+			if( ext != "c" && ext != "cpp" ) continue;
+			
+			var lineNum = 0;
+			for( l in sys.io.File.getContent(BASE_PATH+path).split("\n") ) {
+				lineNum++;
+				var l = StringTools.rtrim(l);
+				if( l == "" ) continue;
+				switch( l.charCodeAt(0) ) {
+				case '\t'.code, '*'.code, '#'.code, '}'.code:
+					continue;
+				default:
+					if( !StringTools.endsWith(l,";") )
+						continue;
+					// function decl
+					if( StringTools.endsWith(l,");") )
+						continue;
+					if( l.indexOf(" const ") > 0 )
+						continue;
+					for( w in ["HL_PRIM ","HL_API ","DEFINE_PRIM","typedef","struct","//","/*"," *"," "] )
+						if( StringTools.startsWith(l,w) ) {
+							l = null;
+							break;
+						}
+					if( l == null )
+						continue;
+					Sys.println('$path:$lineNum: $l');
+				}
+			}
+		}
+	}
+
+	static function main() {
+		for( dir in ["src","libs"] )
+			loopRec(dir);
+	}
+
+}

+ 6 - 6
src/jit.c

@@ -142,7 +142,7 @@ typedef enum {
 #	define W64(wv)	W(wv)
 #endif
 
-static int SIB_MULT[] = {-1, 0, 1, -1, 2, -1, -1, -1, 3};
+static const int SIB_MULT[] = {-1, 0, 1, -1, 2, -1, -1, -1, 3};
 
 #define MOD_RM(mod,reg,rm)		B(((mod) << 6) | (((reg)&7) << 3) | ((rm)&7))
 #define SIB(mult,rmult,rbase)	B((SIB_MULT[mult]<<6) | (((rmult)&7)<<3) | ((rbase)&7))
@@ -215,14 +215,14 @@ struct vreg {
 #		define CALL_NREGS			4
 #		define RCPU_SCRATCH_COUNT	7
 #		define RFPU_SCRATCH_COUNT	6
-static int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx, R8, R9, R10, R11 };
-static CpuReg CALL_REGS[] = { Ecx, Edx, R8, R9 };
+static const int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx, R8, R9, R10, R11 };
+static const CpuReg CALL_REGS[] = { Ecx, Edx, R8, R9 };
 #	else
 #		define CALL_NREGS			6 // TODO : XMM6+XMM7 are FPU reg parameters
 #		define RCPU_SCRATCH_COUNT	9
 #		define RFPU_SCRATCH_COUNT	16
-static int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx, Esi, Edi, R8, R9, R10, R11 };
-static CpuReg CALL_REGS[] = { Edi, Esi, Edx, Ecx, R8, R9 };
+static const int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx, Esi, Edi, R8, R9, R10, R11 };
+static const CpuReg CALL_REGS[] = { Edi, Esi, Edx, Ecx, R8, R9 };
 #	endif
 #else
 #	define CALL_NREGS	0
@@ -230,7 +230,7 @@ static CpuReg CALL_REGS[] = { Edi, Esi, Edx, Ecx, R8, R9 };
 #	define RFPU_COUNT	8
 #	define RCPU_SCRATCH_COUNT	3
 #	define RFPU_SCRATCH_COUNT	8
-static int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx };
+static const int RCPU_SCRATCH_REGS[] = { Eax, Ecx, Edx };
 #endif
 
 #define XMM(i)			((i) + RCPU_COUNT)