public override void Eval(VM vm) { HeronValue initVal = initial.Eval(vm); VarDesc desc = new VarDesc(name); using (vm.CreateScope()) { vm.AddVar(desc, initVal); while (true) { HeronValue condVal = vm.Eval(condition); bool b = condVal.ToBool(); if (!b) { return; } vm.Eval(body); if (vm.ShouldExitScope()) { return; } vm.Eval(next); } } }
public void Add(VarDesc v) { int n = Count; vars.Add(v); values.Add(HeronValue.Null); lookup.Add(v.name, n); }
public void Add(VarDesc v, HeronValue x) { x = v.Coerce(x); int n = Count; vars.Add(v); values.Add(x); lookup.Add(v.name, n); }
public override void Eval(VM vm) { VarDesc desc = new VarDesc(name); foreach (HeronValue x in vm.EvalListAsDotNet(collection)) { using (vm.CreateScope()) { vm.AddVar(desc, x); vm.Eval(body); if (vm.ShouldExitScope()) { return; } } } }
public void ResolveTypes(ModuleDefn global, ModuleDefn m) { foreach (FieldInfo fi in GetInstanceFields()) { if (fi.FieldType.Equals(typeof(HeronType))) { HeronType t = fi.GetValue(this) as HeronType; fi.SetValue(this, t.Resolve(global, m)); } else if (fi.FieldType.Equals(typeof(VarDesc))) { VarDesc vd = fi.GetValue(this) as VarDesc; vd.ResolveTypes(global, m); } } foreach (Expression x in GetSubExpressions()) { x.ResolveAllTypes(global, m); } }
public void AddVar(VarDesc v, HeronValue x) { scopes.Peek().Add(v, x); }
public void AddVar(VarDesc v) { scopes.Peek().Add(v); }
/// <summary> /// Creates a new variable name in the current scope. /// </summary> /// <param name="s"></param> /// <param name="o"></param> public void AddVar(VarDesc v, HeronValue x) { frames.Peek().AddVar(v, x); }
public void AddVar(VarDesc v) { frames.Peek().AddVar(v); }
/// <summary> /// Adds a field. FieldDefn must not already exist. /// </summary> /// <param name="name"></param> /// <param name="val"></param> public void AddField(VarDesc v) { AssureFieldDoesntExist(v.name); fields.Add(v); }
/// <summary> /// Adds a field. FieldDefn must not already exist. /// </summary> /// <param name="name"></param> /// <param name="val"></param> public void AddField(VarDesc v, HeronValue val) { AssureFieldDoesntExist(v.name); fields.Add(v, val); }
public override void Eval(VM vm) { HeronValue initVal = initial.Eval(vm); VarDesc desc = new VarDesc(name); using (vm.CreateScope()) { vm.AddVar(desc, initVal); while (true) { HeronValue condVal = vm.Eval(condition); bool b = condVal.ToBool(); if (!b) return; vm.Eval(body); if (vm.ShouldExitScope()) return; vm.Eval(next); } } }
public override void Eval(VM vm) { VarDesc desc = new VarDesc(name); foreach (HeronValue x in vm.EvalListAsDotNet(collection)) { using (vm.CreateScope()) { vm.AddVar(desc, x); vm.Eval(body); if (vm.ShouldExitScope()) return; } } }