RPA Toolkit
used types cleaned up... - 3
authorMartin Stoilov <martin@rpasearch.com>
Wed, 27 Jul 2011 06:03:32 +0000 (23:03 -0700)
committerMartin Stoilov <martin@rpasearch.com>
Wed, 27 Jul 2011 06:03:32 +0000 (23:03 -0700)
arch/windows/x64/rtypes.h
rjs/rjscompiler.c
rlib/rstring.h
rpa/rpacompiler.c
rpa/rpastat.c
rpa/rpastatpriv.h
rpa/rpavm.c
rpa/rpavm.h
rvm/rvmcodemap.c
rvm/rvmcpu.c
rvm/rvmoperatorbin.c

index afbbd58..ec323bc 100644 (file)
@@ -19,12 +19,12 @@ typedef ruint64 ruword;
 typedef rint64 rword;
 
 #ifndef _RSIZE_T_DEFINED
-typedef ruint64 rsize_t;
+typedef unsigned long rsize_t;
 #define _RSIZE_T_DEFINED
 #endif
 
 #ifndef _RSSIZE_T_DEFINED
-typedef rint64 rssize_t;
+typedef long rssize_t;
 #define _RSSIZE_T_DEFINED
 #endif
 
index 272d32e..1b9d59c 100644 (file)
@@ -61,7 +61,7 @@ void rjs_compiler_adderror(rjs_compiler_t *co, long code, rparecord_t *prec)
        co->error->type = RJS_ERRORTYPE_SYNTAX;
        co->error->error = code;
        co->error->script = co->script;
-       co->error->offset = prec->input - co->script;
+       co->error->offset = (long)(prec->input - co->script);
        co->error->size = prec->inputsiz;
        co->error->line = rjs_parser_offset2line(co->script, co->error->offset);
        co->error->lineoffset = rjs_parser_offset2lineoffset(co->script, co->error->offset);
index 92d07c6..b09c774 100644 (file)
@@ -73,7 +73,7 @@ typedef struct rstring_s {
 rstring_t *r_string_create();
 rstring_t *r_string_create_from_ansistr(const char *str);
 rstring_t *r_string_create_from_double(double d);
-rstring_t *r_string_create_from_signed(long l);
+rstring_t *r_string_create_from_signed(rword l);
 rstring_t *r_string_create_strsize(const char *str, unsigned int size);
 rstring_t *r_string_create_from_rstr(const rstr_t *str);
 void r_string_destroy(rstring_t *string);
index 13931f3..a2469d8 100644 (file)
@@ -327,7 +327,7 @@ long rpa_compiler_addblob(rpa_compiler_t *co, long ruleid, long ruleuid, unsigne
        pblob->namesize = namesize;
        r_strncpy(ptr, name, namesize);
        ptr += namesize;
-       pblob->size = ptr - blob + 1;
+       pblob->size = (long)(ptr - blob + 1);
        return rvm_codegen_adddata_s(co->cg, NULL, pblob, pblob->size);
 }
 
index 8d54966..8b90d0d 100644 (file)
@@ -64,7 +64,7 @@ void rpa_stat_cachedisable(rpastat_t *stat, unsigned int disable)
 
 int rpa_stat_init(rpastat_t *stat, unsigned int encoding, const char *input, const char *start, const char *end, rarray_t *records)
 {
-       unsigned long size;
+       long size;
 
        if (!stat) {
                return -1;
@@ -76,7 +76,7 @@ int rpa_stat_init(rpastat_t *stat, unsigned int encoding, const char *input, con
                return -1;
        }
        r_memset(&stat->err, 0, sizeof(stat->err));
-       size = end - start;
+       size = (long)(end - start);
        stat->encoding = encoding;
        stat->start = start;
        stat->end = end;
@@ -203,7 +203,7 @@ long rpa_stat_scan(rpastat_t *stat, rparule_t rid, unsigned int encoding, const
                }
                if (topsiz > 0) {
                        ptp = &stat->instack[topsiz];
-                       ret = (ptp->input - input);
+                       ret = (long)(ptp->input - input);
                        *where = input;
                        return ret;
                }
index a254d3c..ecd6fe2 100644 (file)
@@ -35,9 +35,9 @@
 extern "C" {
 #endif
 
-#define RPA_STAT_SETERROR_CODE(__d__, __e__) do { (__d__)->err.code = __e__; (__d__)->err.mask |= RPA_ERRINFO_CODE;} while (0)
-#define RPA_STAT_SETERRINFO_OFFSET(__d__, __o__) do { (__d__)->err.offset = __o__; (__d__)->err.mask |= RPA_ERRINFO_OFFSET; } while (0)
-#define RPA_STAT_SETERRINFO_RULEUID(__d__, __r__) do { (__d__)->err.ruleuid = __r__; (__d__)->err.mask |= RPA_ERRINFO_RULEUID; } while (0)
+#define RPA_STAT_SETERROR_CODE(__d__, __e__) do { (__d__)->err.code = (long)(__e__); (__d__)->err.mask |= RPA_ERRINFO_CODE;} while (0)
+#define RPA_STAT_SETERRINFO_OFFSET(__d__, __o__) do { (__d__)->err.offset = (long)(__o__); (__d__)->err.mask |= RPA_ERRINFO_OFFSET; } while (0)
+#define RPA_STAT_SETERRINFO_RULEUID(__d__, __r__) do { (__d__)->err.ruleuid = (long)(__r__); (__d__)->err.mask |= RPA_ERRINFO_RULEUID; } while (0)
 #define RPA_STAT_SETERRINFO_NAME(__d__, __n__, __s__) do { \
        (__d__)->err.mask |= RPA_ERRINFO_NAME; \
        r_memset((__d__)->err.name, 0, sizeof((__d__)->err.name)); \
index c6fb08d..02f28f4 100644 (file)
@@ -328,9 +328,9 @@ static void rpavm_swi_emitstart(rvmcpu_t *cpu, rvm_asmins_t *ins)
        RVM_CPUREG_SETL(cpu, R_REC, index);
        rec = (rparecord_t *)r_array_slot(stat->records, index);
        rec->rule = name.str;
-       rec->top = tp;
-       rec->ruleid = ruledata->ruleid;
-       rec->ruleuid = ruledata->ruleuid;
+       rec->top = (ruint32)tp;
+       rec->ruleid = (ruint32)ruledata->ruleid;
+       rec->ruleuid = (ruint32)ruledata->ruleuid;
        rec->type = RPA_RECORD_START;
        rec->input = stat->instack[tp].input;
        rec->inputoff = stat->instack[tp].input - stat->start;
@@ -360,15 +360,15 @@ static void rpavm_swi_emitend(rvmcpu_t *cpu, rvm_asmins_t *ins)
        rec = (rparecord_t *)r_array_slot(stat->records, index);
        startrec = (rparecord_t *)r_array_slot(stat->records, startindex);
        rec->rule = name.str;
-       rec->top = tp;
-       rec->size = tplen;
+       rec->top = (ruint32)tp;
+       rec->size = (ruint32)tplen;
        rec->type = RPA_RECORD_END;
-       rec->ruleid = ruledata->ruleid;
-       rec->ruleuid = ruledata->ruleuid;
+       rec->ruleid = (ruint32)ruledata->ruleid;
+       rec->ruleuid = (ruint32)ruledata->ruleuid;
        rec->input = stat->instack[tp].input;
        rec->inputsiz = stat->instack[tp + tplen].input - stat->instack[tp].input;
        rec->inputoff = stat->instack[tp].input - stat->start;
-       startrec->size = tplen;
+       startrec->size = (ruint32)tplen;
        startrec->inputsiz = rec->inputsiz;
 }
 
index e272d9f..0b55686 100644 (file)
@@ -94,12 +94,12 @@ typedef struct rpainmap_s {
 
 
 typedef struct rpa_ruledata_s {
-       long size;
-       long ruleid;
-       long ruleuid;
-       unsigned long flags;
-       unsigned long namesize;
-       unsigned long name;
+       ruword size;
+       ruword ruleid;
+       ruword ruleuid;
+       ruword flags;
+       ruword namesize;
+       ruword name;
 } rpa_ruledata_t;
 
 
index e0cb5b8..5e6fa9b 100644 (file)
@@ -39,9 +39,8 @@ rvm_codemap_t *rvm_codemap_create()
 
 void rvm_codemap_destroy(rvm_codemap_t *codemap)
 {
-       long i;
        rvm_codelabel_t *label;
-       long len = r_array_length(codemap->labels);
+       rsize_t i, len = r_array_length(codemap->labels);
 
        for (i = 0; i < len; i++) {
                label = (rvm_codelabel_t*)r_array_slot(codemap->labels, i);
@@ -89,7 +88,7 @@ static long rvm_codemap_add(rvm_codemap_t *codemap, const char *name, unsigned i
 
        labelidx = rvm_codemap_dolookup(codemap, name, namesize);
        if (labelidx < 0) {
-               labelidx = r_array_add(codemap->labels, NULL);
+               labelidx = (long)r_array_add(codemap->labels, NULL);
                label = rvm_codemap_label(codemap, labelidx);
                if (name) {
                        label->name = r_rstrdup(name, namesize);
@@ -136,7 +135,7 @@ long rvm_codemap_addoffset(rvm_codemap_t *codemap, const char *name, unsigned in
 
 long rvm_codemap_addoffset_s(rvm_codemap_t *codemap, const char *name, unsigned long base, unsigned long offset)
 {
-       return rvm_codemap_addoffset(codemap, name, r_strlen(name), base, offset);
+       return rvm_codemap_addoffset(codemap, name, (unsigned int)r_strlen(name), base, offset);
 }
 
 
@@ -154,7 +153,7 @@ long rvm_codemap_addpointer(rvm_codemap_t *codemap, const char *name, unsigned i
 
 long rvm_codemap_addpointer_s(rvm_codemap_t *codemap, const char *name, rpointer ptr)
 {
-       return rvm_codemap_addpointer(codemap, name, r_strlen(name), ptr);
+       return rvm_codemap_addpointer(codemap, name, (unsigned int)r_strlen(name), ptr);
 }
 
 
@@ -182,13 +181,13 @@ long rvm_codemap_validindex(rvm_codemap_t *codemap, long labelidx)
 
 long rvm_codemap_invalid_add_s(rvm_codemap_t *codemap, const char *name)
 {
-       return rvm_codemap_invalid_add(codemap, name, r_strlen(name));
+       return rvm_codemap_invalid_add(codemap, name, (unsigned int)r_strlen(name));
 }
 
 
 long rvm_codemap_lastlabel(rvm_codemap_t *codemap)
 {
-       return r_array_length(codemap->labels) - 1;
+       return (long)(r_array_length(codemap->labels) - 1);
 }
 
 
@@ -205,7 +204,7 @@ long rvm_codemap_lookupadd(rvm_codemap_t *codemap, const char *name, unsigned in
 
 long rvm_codemap_lookupadd_s(rvm_codemap_t *codemap, const char *name)
 {
-       return rvm_codemap_lookupadd(codemap, name, r_strlen(name));
+       return rvm_codemap_lookupadd(codemap, name, (unsigned int)r_strlen(name));
 }
 
 
@@ -220,7 +219,7 @@ long rvm_codemap_lookup(rvm_codemap_t *codemap, const char *name, unsigned int n
 
 long rvm_codemap_lookup_s(rvm_codemap_t *codemap, const char *name)
 {
-       return rvm_codemap_lookup(codemap, name, r_strlen(name));
+       return rvm_codemap_lookup(codemap, name, (unsigned int)r_strlen(name));
 }
 
 
@@ -247,9 +246,9 @@ ruword rvm_codemap_resolve(rvm_codemap_t *codemap, long index, rvm_codelabel_t *
 
 void rvm_codemap_dump(rvm_codemap_t *codemap)
 {
-       rsize_t i = 0;
+       long i = 0;
 
-       for (i = 0; i < r_array_length(codemap->labels); i++) {
+       for (i = 0; i < (long)r_array_length(codemap->labels); i++) {
                rvm_codelabel_t *label = rvm_codemap_label(codemap, i);
                r_printf("%d: %s(%d), type: %d, base: %ld, value: %ld\n", i, label->name->str, label->name->size, label->type, label->base, label->value);
        }
index f589a1d..7300c23 100644 (file)
@@ -1642,7 +1642,7 @@ static void rvm_op_mapaddr(rvmcpu_t *cpu, rvm_asmins_t *ins)
        long index;
 
        rvm_opmap_invoke_binary_handler(cpu->opmap, RVM_OPID_CAST, cpu, &tmp, RVM_CPUREG_PTR(cpu, ins->op3), &tmp);
-       index = RVM_REG_GETL(&tmp);
+       index = (long)RVM_REG_GETL(&tmp);
        if (rvm_reg_gettype(arg2) != RVM_DTYPE_JSOBJECT)
                RVM_ABORT(cpu, RVM_E_NOTOBJECT);
        a = (rmap_t*)RVM_REG_GETP(arg2);
@@ -1665,7 +1665,7 @@ static void rvm_op_mapldr(rvmcpu_t *cpu, rvm_asmins_t *ins)
        long index;
 
        rvm_opmap_invoke_binary_handler(cpu->opmap, RVM_OPID_CAST, cpu, &tmp, RVM_CPUREG_PTR(cpu, ins->op3), &tmp);
-       index = RVM_REG_GETL(&tmp);
+       index = (long)RVM_REG_GETL(&tmp);
        if (rvm_reg_gettype(arg2) != RVM_DTYPE_JSOBJECT)
                RVM_ABORT(cpu, RVM_E_NOTOBJECT);
        a = (rmap_t*)RVM_REG_GETP(arg2);
@@ -1689,7 +1689,7 @@ static void rvm_op_mapstr(rvmcpu_t *cpu, rvm_asmins_t *ins)
        long index;
 
        rvm_opmap_invoke_binary_handler(cpu->opmap, RVM_OPID_CAST, cpu, &tmp, RVM_CPUREG_PTR(cpu, ins->op3), &tmp);
-       index = RVM_REG_GETL(&tmp);
+       index = (long)RVM_REG_GETL(&tmp);
        if (rvm_reg_gettype(arg2) != RVM_DTYPE_JSOBJECT)
                RVM_ABORT(cpu, RVM_E_NOTOBJECT);
        a = (rmap_t*)RVM_REG_GETP(arg2);
@@ -1709,7 +1709,7 @@ static void rvm_op_addra(rvmcpu_t *cpu, rvm_asmins_t *ins)
        long index;
 
        rvm_opmap_invoke_binary_handler(cpu->opmap, RVM_OPID_CAST, cpu, &tmp, RVM_CPUREG_PTR(cpu, ins->op3), &tmp);
-       index = RVM_REG_GETL(&tmp);
+       index = (long)RVM_REG_GETL(&tmp);
 
        if (rvm_reg_gettype(arg2) != RVM_DTYPE_ARRAY || index < 0) {
                RVM_ABORT(cpu, RVM_E_ILLEGAL);
index 37c5748..e9e22d8 100644 (file)
@@ -98,13 +98,13 @@ static void rvm_op_binary_signed_signed(rvmcpu_t *cpu, ruint16 opid, rvmreg_t *r
 
 static void rvm_op_binary_double_signed(rvmcpu_t *cpu, ruint16 opid, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
 {
-       rvm_op_binary_double(cpu, opid, res, RVM_REG_GETD(arg1), RVM_REG_GETL(arg2));
+       rvm_op_binary_double(cpu, opid, res, RVM_REG_GETD(arg1), (double)RVM_REG_GETL(arg2));
 }
 
 
 void rvm_op_binary_signed_double(rvmcpu_t *cpu, ruint16 opid, rvmreg_t *res, const rvmreg_t *arg1, const rvmreg_t *arg2)
 {
-       rvm_op_binary_double(cpu, opid, res, RVM_REG_GETL(arg1), RVM_REG_GETD(arg2));
+       rvm_op_binary_double(cpu, opid, res, (double)RVM_REG_GETL(arg1), RVM_REG_GETD(arg2));
 }
 
 
@@ -132,7 +132,7 @@ static void rvm_op_binary_string_signed(rvmcpu_t *cpu, ruint16 opid, rvmreg_t *r
                RVM_ABORT(cpu, RVM_E_ILLEGAL);
 
        if (rvm_reg_gettype(&s) == RVM_DTYPE_DOUBLE) {
-               rvm_op_binary_double(cpu, opid, res, RVM_REG_GETD(&s), RVM_REG_GETL(arg2));
+               rvm_op_binary_double(cpu, opid, res, RVM_REG_GETD(&s), (double)RVM_REG_GETL(arg2));
        } else {
                rvm_op_binary_signed(cpu, opid, res, RVM_REG_GETL(&s), RVM_REG_GETL(arg2));
        }
@@ -156,7 +156,7 @@ static void rvm_op_binary_signed_string(rvmcpu_t *cpu, ruint16 opid, rvmreg_t *r
        if (rvm_reg_str2num(&s, arg2) < 0)
                RVM_ABORT(cpu, RVM_E_ILLEGAL);
        if (rvm_reg_gettype(&s) == RVM_DTYPE_DOUBLE) {
-               rvm_op_binary_double(cpu, opid, res, RVM_REG_GETL(arg1), RVM_REG_GETD(&s));
+               rvm_op_binary_double(cpu, opid, res, (double)RVM_REG_GETL(arg1), RVM_REG_GETD(&s));
        } else {
                rvm_op_binary_signed(cpu, opid, res, RVM_REG_GETL(arg1), RVM_REG_GETL(&s));
        }