예제 #1
0
파일: luareplace.c 프로젝트: ttgb/luadec
int checkProto(const Proto* fleft, const Proto* fright, int c) {
	char warnmessage[64];
	int diff = 0;
	*warnmessage = '\0';
	if (fleft->numparams != fright->numparams){
		diff++;
		strcat(warnmessage, "numparams ");
	}
	if (NUPS(fleft) != NUPS(fright)){
		diff++;
		strcat(warnmessage, "nups ");
	}
	if (fleft->is_vararg != fright->is_vararg){
		diff++;
		strcat(warnmessage, "is_vararg ");
	}
	if (diff > 0){
		if (c >= 0) {
			fprintf(stderr, "  warning! incompatible function %d : different %s", c, warnmessage);
		} else {
			fprintf(stderr, "  warning! incompatible function : different %s", warnmessage);
		}
	}
	return diff;
}
예제 #2
0
파일: luaopswap.c 프로젝트: fightx/luadec
int CompareAndGenOpcodes(const Proto* input_proto, const Proto* allopcodes_proto) {
    int diff = 0, count = 0;
    char errorstr[128] = { "cannot generate opcodes.txt. Cause protos to compare have" };
    if (!(input_proto->sizep > 0 && allopcodes_proto->sizep > 0)) {
        strcat(errorstr, " null function 0_0 .");
        fatal(errorstr);
    }
    input_proto = input_proto->p[0];
    allopcodes_proto = allopcodes_proto->p[0];
    if (!(input_proto && allopcodes_proto)) {
        strcat(errorstr, " null function 0_0 .");
        fatal(errorstr);
    }
    if (input_proto->numparams != allopcodes_proto->numparams) {
        diff++;
        strcat(errorstr, " different params size;");
    }
    if (NUPS(input_proto) != NUPS(allopcodes_proto)) {
        diff++;
        strcat(errorstr, " different upvalues size;");
    }
    if (input_proto->is_vararg != allopcodes_proto->is_vararg) {
        diff++;
        strcat(errorstr, " different is_vararg;");
    }
    if (input_proto->sizecode != allopcodes_proto->sizecode) {
        diff++;
        strcat(errorstr, " different code size;");
    }
    if (diff > 0) {
        fatal(errorstr);
    }
    diff = CompareAndGenOp2op(input_proto, allopcodes_proto);
    count = PrintOp2op();
    fprintf(stderr, " %d OpCodes swapped", count);
    return diff;
}