Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
 public void Add(VarDesc v)
 {
     int n = Count;
     vars.Add(v);
     values.Add(HeronValue.Null);
     lookup.Add(v.name, n);
 }
Exemple #3
0
 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);
 }
Exemple #4
0
        public void Add(VarDesc v)
        {
            int n = Count;

            vars.Add(v);
            values.Add(HeronValue.Null);
            lookup.Add(v.name, n);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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;
                    }
                }
            }
        }
Exemple #7
0
        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);
            }
        }
Exemple #8
0
 public void AddVar(VarDesc v, HeronValue x)
 {
     scopes.Peek().Add(v, x);
 }
Exemple #9
0
 public void AddVar(VarDesc v)
 {
     scopes.Peek().Add(v);
 }
Exemple #10
0
 /// <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);
 }
Exemple #11
0
 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);
 }
Exemple #14
0
 public void AddVar(VarDesc v, HeronValue x)
 {
     scopes.Peek().Add(v, x);
 }
Exemple #15
0
 public void AddVar(VarDesc v)
 {
     scopes.Peek().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)
 {
     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;
         }
     }
 }
Exemple #20
0
 public void AddVar(VarDesc v)
 {
     frames.Peek().AddVar(v);
 }
Exemple #21
0
 /// <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);
 }