private MachineState(RootEnvironment rootEnv, int nArgs, int nLocals, InnerMachineState innerState) { RootEnv = rootEnv; this.nArgs = nArgs; this.nLocals = nLocals; this.innerState = new LogicVar <InnerMachineState>(innerState); }
// New empty stack and bottom args and locals state public MachineState(RootEnvironment rootEnv, int nArgs, int nLocals) { RootEnv = rootEnv; this.nArgs = nArgs; this.nLocals = nLocals; innerState = new LogicVar <InnerMachineState>(new InnerMachineState(nArgs, nLocals)); }
public void Unify(LogicVar <T> other, Action <T, T, BoolRef> unifyValues, BoolRef changed) { var thislv = Follow(); other = other.Follow(); if (thislv.id == other.id) { return; } if (thislv.value != null && other.value != null) { unifyValues(thislv.value, other.value, changed); other.value = null; other.chained = thislv; } else if (thislv.value != null) { other.chained = thislv; } else { thislv.chained = other; } }
private LogicVar <T> Follow() { if (chained == null) { return(this); } var lv = chained; while (lv.chained != null) { lv = lv.chained; } chained = lv; return(lv); }
public LogicVar(T value) { id = nextId++; chained = null; this.value = value; }
public LogicVar() { id = nextId++; chained = null; value = null; }