rm push/pop
This commit is contained in:
28
verify_ir.cm
28
verify_ir.cm
@@ -172,7 +172,7 @@ var check_slot_bounds = function(func) {
|
||||
if (pos < length(instr) - 2) {
|
||||
val = instr[pos]
|
||||
if (is_number(val) && (val < 0 || val >= nr_slots)) {
|
||||
push(errors, `slot_bounds: instr ${text(i)} op=${op} slot[${text(positions[j])}]=${text(val)} out of range 0..${text(nr_slots - 1)}`)
|
||||
errors[] = `slot_bounds: instr ${text(i)} op=${op} slot[${text(positions[j])}]=${text(val)} out of range 0..${text(nr_slots - 1)}`
|
||||
}
|
||||
}
|
||||
j = j + 1
|
||||
@@ -217,7 +217,7 @@ var check_jump_targets = function(func) {
|
||||
if (label_pos != null) {
|
||||
target = instr[label_pos + 1]
|
||||
if (is_text(target) && labels[target] != true) {
|
||||
push(errors, `jump_targets: instr ${text(i)} op=${op} target label "${target}" not found`)
|
||||
errors[] = `jump_targets: instr ${text(i)} op=${op} target label "${target}" not found`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -301,46 +301,46 @@ var check_type_consistency = function(func) {
|
||||
s2 = text(instr[2])
|
||||
t2 = slot_types[s2]
|
||||
if (t2 != null && t2 != T_INT && t2 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected int`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected int`
|
||||
}
|
||||
if (length(instr) >= 6) {
|
||||
s3 = text(instr[3])
|
||||
t3 = slot_types[s3]
|
||||
if (t3 != null && t3 != T_INT && t3 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src2 slot ${s3} has type ${t3}, expected int`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src2 slot ${s3} has type ${t3}, expected int`
|
||||
}
|
||||
}
|
||||
} else if (float_ops[op] == true && length(instr) >= 5) {
|
||||
s2 = text(instr[2])
|
||||
t2 = slot_types[s2]
|
||||
if (t2 != null && t2 != T_FLOAT && t2 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected float`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected float`
|
||||
}
|
||||
if (length(instr) >= 6) {
|
||||
s3 = text(instr[3])
|
||||
t3 = slot_types[s3]
|
||||
if (t3 != null && t3 != T_FLOAT && t3 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src2 slot ${s3} has type ${t3}, expected float`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src2 slot ${s3} has type ${t3}, expected float`
|
||||
}
|
||||
}
|
||||
} else if (text_ops[op] == true && length(instr) >= 5) {
|
||||
s2 = text(instr[2])
|
||||
t2 = slot_types[s2]
|
||||
if (t2 != null && t2 != T_TEXT && t2 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected text`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected text`
|
||||
}
|
||||
if (length(instr) >= 6) {
|
||||
s3 = text(instr[3])
|
||||
t3 = slot_types[s3]
|
||||
if (t3 != null && t3 != T_TEXT && t3 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src2 slot ${s3} has type ${t3}, expected text`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src2 slot ${s3} has type ${t3}, expected text`
|
||||
}
|
||||
}
|
||||
} else if (bool_ops[op] == true && length(instr) >= 5) {
|
||||
s2 = text(instr[2])
|
||||
t2 = slot_types[s2]
|
||||
if (t2 != null && t2 != T_BOOL && t2 != "unknown") {
|
||||
push(errors, `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected bool`)
|
||||
errors[] = `type_consistency: instr ${text(i)} op=${op} src1 slot ${s2} has type ${t2}, expected bool`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,7 +394,7 @@ var check_nop_consistency = function(func) {
|
||||
if (label_pos != null) {
|
||||
target = instr[label_pos + 1]
|
||||
if (is_text(target) && nops[target] == true) {
|
||||
push(errors, `nop_consistency: instr ${text(i)} op=${op} jumps to nop marker "${target}"`)
|
||||
errors[] = `nop_consistency: instr ${text(i)} op=${op} jumps to nop marker "${target}"`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,28 +415,28 @@ var verify_all = function(func, pass_name) {
|
||||
check_errors = check_slot_bounds(func)
|
||||
i = 0
|
||||
while (i < length(check_errors)) {
|
||||
push(all_errors, `${prefix}${fn_name}: ${check_errors[i]}`)
|
||||
all_errors[] = `${prefix}${fn_name}: ${check_errors[i]}`
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
check_errors = check_jump_targets(func)
|
||||
i = 0
|
||||
while (i < length(check_errors)) {
|
||||
push(all_errors, `${prefix}${fn_name}: ${check_errors[i]}`)
|
||||
all_errors[] = `${prefix}${fn_name}: ${check_errors[i]}`
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
check_errors = check_type_consistency(func)
|
||||
i = 0
|
||||
while (i < length(check_errors)) {
|
||||
push(all_errors, `${prefix}${fn_name}: ${check_errors[i]}`)
|
||||
all_errors[] = `${prefix}${fn_name}: ${check_errors[i]}`
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
check_errors = check_nop_consistency(func)
|
||||
i = 0
|
||||
while (i < length(check_errors)) {
|
||||
push(all_errors, `${prefix}${fn_name}: ${check_errors[i]}`)
|
||||
all_errors[] = `${prefix}${fn_name}: ${check_errors[i]}`
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user