OSDN Git Service

main.c変数の宣言をまとめた
authorhikarupsp <hikarupsp@users.sourceforge.jp>
Mon, 10 Mar 2014 12:12:14 +0000 (21:12 +0900)
committerhikarupsp <hikarupsp@users.sourceforge.jp>
Mon, 10 Mar 2014 12:12:14 +0000 (21:12 +0900)
main.c

diff --git a/main.c b/main.c
index cee2db6..d62473a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -12,26 +12,42 @@ void putKeybuf(int i)
 
 int osecpuMain(int argc, char **argv)
 {
-       unsigned char *appbin = malloc(APPSIZ1), *up;
-       unsigned char *jitbuf = mallocRWE(1024 * 1024); /* とりあえず1MBで */
+    FILE *fp, *fp2;
+    unsigned char *appbin, *up;
+    unsigned char *jitbuf, *sysjit00, *sysjit;
+    unsigned char *systmp0, *systmp1, *systmp2;
+    unsigned char *opTbl;
+    HOSECPU_LabelListTag *label;
+    int level;
+    int tmpsiz, i;
+    jmp_buf setjmpEnv;
+       double tm0, tm1, tm2;
+       HOSECPU_PointerControlTag *ptrCtrl;
+    unsigned char *syslib;
+    int appsiz0, appsiz1;
+    const char *argv1;
+    int argDebug = 0, stacksiz = 1;
+    const  char *cp;
+    HOSECPU_RuntimeEnvironment regs;
+       void(*jitfunc)(char *);
+    unsigned char *jp;
+    
+       appbin = malloc(APPSIZ1);
+       jitbuf = mallocRWE(1024 * 1024); /* とりあえず1MBで */
        //unsigned char *sysjit0 = mallocRWE(SJITSIZ1), *sysjit1 = sysjit0, *sysjit00 = sysjit0;
-
        // syslib.oseのjitc結果を格納する領域を確保。
-       unsigned char *sysjit00 = mallocRWE(SJITSIZ1);
-
+       sysjit00 = mallocRWE(SJITSIZ1);
        // 現在の、jitc結果を格納するメモリへの書き込み位置のアドレス
-       unsigned char *sysjit = sysjit00;
-
-       unsigned char *systmp0 = malloc(SYSTMP0SIZ);
-       unsigned char *systmp1 = malloc(SYSTMP1SIZ);
-       unsigned char *systmp2 = malloc(1024 * 1024), *opTbl = malloc(256);
-       HOSECPU_LabelListTag *label = malloc(JITC_MAXLABELS * sizeof (HOSECPU_LabelListTag));
-       int level = JITC_LV_SLOWEST, tmpsiz, i;
+       sysjit = sysjit00;
+       systmp0 = malloc(SYSTMP0SIZ);
+       systmp1 = malloc(SYSTMP1SIZ);
+       systmp2 = malloc(1024 * 1024);
+    opTbl = malloc(256);
+       label = malloc(JITC_MAXLABELS * sizeof (HOSECPU_LabelListTag));
+       level = JITC_LV_SLOWEST;
        keybuf = malloc(KEYBUFSIZ * sizeof (int));
        keybuf_r = keybuf_w = keybuf_c = 0;
-       jmp_buf setjmpEnv;
-       double tm0, tm1, tm2;
-       HOSECPU_PointerControlTag *ptrCtrl = malloc(PTRCTRLSIZ * sizeof (HOSECPU_PointerControlTag));
+       ptrCtrl = malloc(PTRCTRLSIZ * sizeof (HOSECPU_PointerControlTag));
 
        randStatInit((unsigned int)time(NULL));
        for (i = 0; i < PTRCTRLSIZ; i++) {
@@ -41,15 +57,18 @@ int osecpuMain(int argc, char **argv)
        ptrCtrl[0].size = -2;
 
        /* syslibの読み込み */
-       unsigned char *syslib = malloc(SYSLIBSIZ1);
-       int appsiz0, appsiz1;
-       FILE *fp = fopen(SYSLIB_OSE, "rb");
+       syslib = malloc(SYSLIBSIZ1);
+       fp = fopen(SYSLIB_OSE, "rb");
        if (fp == NULL) {
                syslib[0] = '/';
                strcpy((char *)syslib + 1, argv[0]);
                up = syslib + 1;
-               while (*up != '\0') up++;
-               while (*up != '/' && *up != 0x5c) up--;
+               while (*up != '\0'){
+            up++;
+        }
+               while (*up != '/' && *up != 0x5c){
+            up--;
+        }
                up++;
                strcpy((char *)up, SYSLIB_OSE);
                fp = fopen((char *)syslib + 1, "rb");
@@ -74,7 +93,7 @@ int osecpuMain(int argc, char **argv)
                syslib[1] = 0x1b;
        }
 
-       FILE *fp2 = fopen("syslib_dbg.ose", "wb");
+       fp2 = fopen("syslib_dbg.ose", "wb");
        fwrite(syslib, 1, SYSLIBSIZ1, fp2);
        fclose(fp2);
 
@@ -99,7 +118,7 @@ int osecpuMain(int argc, char **argv)
        if (argc <= 1) {
         return 0;
     }
-       const char *argv1 = argv[1];
+       argv1 = argv[1];
        if (argv1[0] == ':' && argv1[2] == ':') {
                level = argv1[1] - '0';
                if (level < 0 || level > 9){
@@ -137,9 +156,7 @@ header_error:
                        return 1;
                }
        }
-
-       int argDebug = 0, stacksiz = 1;
-       const  char *cp = searchArg(argc, (const char **)argv, "debug:", 0);
+       cp = searchArg(argc, (const char **)argv, "debug:", 0);
        if (cp != NULL){
         argDebug = *cp - '0';
     }
@@ -147,9 +164,7 @@ header_error:
        if (cp != NULL){
         stacksiz = strtol(cp, NULL, 0);
     }
-       HOSECPU_RuntimeEnvironment regs;
-       void(*jitfunc)(char *);
-       unsigned char *jp = jitbuf; /* JIT-pointer */
+       jp = jitbuf; /* JIT-pointer */
 
        /* フロントエンドコードをバックエンドコードに変換する */
        if ((appbin[2] & 0xf0) != 0) {