local flow flags, see what works

This commit is contained in:
dcode
2019-03-17 01:35:44 +01:00
parent 2d76da9465
commit e63c6bd388
53 changed files with 13472 additions and 16033 deletions

View File

@ -80,7 +80,8 @@ import {
import {
FlowFlags,
Flow
Flow,
LocalFlags
} from "./flow";
import {
@ -2174,13 +2175,14 @@ export class Compiler extends DiagnosticEmitter {
}
if (initExpr) {
initializers.push(
this.compileAssignmentWithValue(declaration.name, initExpr)
this.module.createSetLocal(local.index, initExpr)
);
if (local.type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) {
flow.setLocalWrapped(local.index, !flow.canOverflow(initExpr, type));
if (!flow.canOverflow(initExpr, type)) flow.setLocalFlag(local.index, LocalFlags.WRAPPED);
else flow.unsetLocalFlag(local.index, LocalFlags.WRAPPED);
}
} else if (local.type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) {
flow.setLocalWrapped(local.index, true); // zero
flow.setLocalFlag(local.index, LocalFlags.WRAPPED);
}
}
}
@ -4778,12 +4780,14 @@ export class Compiler extends DiagnosticEmitter {
);
return module.createUnreachable();
}
let localIndex = (<Local>target).index;
if (type.is(TypeFlags.SHORT | TypeFlags.INTEGER)) {
flow.setLocalWrapped((<Local>target).index, !flow.canOverflow(valueWithCorrectType, type));
if (!flow.canOverflow(valueWithCorrectType, type)) flow.setLocalFlag(localIndex, LocalFlags.WRAPPED);
else flow.unsetLocalFlag(localIndex, LocalFlags.WRAPPED);
}
return tee
? module.createTeeLocal((<Local>target).index, valueWithCorrectType)
: module.createSetLocal((<Local>target).index, valueWithCorrectType);
? module.createTeeLocal(localIndex, valueWithCorrectType)
: module.createSetLocal(localIndex, valueWithCorrectType);
}
case ElementKind.GLOBAL: {
if (!this.compileGlobal(<Global>target)) return module.createUnreachable();