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

            vars.Add(v);
            values.Add(HeronValue.Null);
            lookup.Add(v.name, n);
        }
Esempio n. 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);
        }
Esempio n. 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;
                    }
                }
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 8
0
 public void AddVar(VarDesc v, HeronValue x)
 {
     scopes.Peek().Add(v, x);
 }
Esempio n. 9
0
 public void AddVar(VarDesc v)
 {
     scopes.Peek().Add(v);
 }
Esempio n. 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);
 }
Esempio n. 11
0
 public void AddVar(VarDesc v)
 {
     frames.Peek().AddVar(v);
 }
Esempio n. 12
0
 /// <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);
 }
Esempio n. 13
0
 /// <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);
 }
Esempio n. 14
0
 public void AddVar(VarDesc v, HeronValue x)
 {
     scopes.Peek().Add(v, x);
 }
Esempio n. 15
0
 public void AddVar(VarDesc v)
 {
     scopes.Peek().Add(v);
 }
Esempio n. 16
0
 /// <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);
 }
Esempio n. 17
0
 /// <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);
 }
Esempio n. 18
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);
         }
     }
 }
Esempio n. 19
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;
         }
     }
 }
Esempio n. 20
0
 public void AddVar(VarDesc v)
 {
     frames.Peek().AddVar(v);
 }
Esempio n. 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);
 }