Beispiel #1
0
        public Scope Copy()
        {
            Scope cp = new Scope(Parent == null ? null : Parent.Copy());

            foreach (var kvp in Variables)
                cp.Variables.Add(kvp.Key, kvp.Value.Copy());

            return cp;
        }
Beispiel #2
0
        public Value Evaluate(Scope scope)
        {
            // create child scope
            Scope child = new Scope(scope);
            Value final = new ForeverAlone();

            try
            {
                foreach (var ie in Body)
                    final = ie.Evaluate(child);
            }
            catch (Gb2 gb2)
            {
                return gb2.Value.Evaluate(scope);
            }

            return final;
        }
Beispiel #3
0
        public Value Evaluate(Scope scope)
        {
            foreach (var t in Tiers)
            {
                if (t.Item1 == null) // SHIT TIER
                    return t.Item2.Evaluate(scope);

                var res = t.Item1.Evaluate(scope);

                if (res.Type != GPLType.Bool)
                    throw new Exception("Non-boolean expression inside TIER list");

                if (((Bool)res).Value) // evaluated to true
                    return t.Item2.Evaluate(scope);
            }

            return new ForeverAlone(); // no conditions met true
        }
Beispiel #4
0
 public Value Evaluate(Scope scope)
 {
     return scope.Find(Identifier);
 }
Beispiel #5
0
 public override Value Evaluate(Scope scope)
 {
     return scope.Find(Name, Value.Evaluate(scope));
 }
Beispiel #6
0
 public virtual Value Evaluate(Scope scope)
 {
     return scope.Create(Name, new ForeverAlone());
 }
Beispiel #7
0
 public Scope(Scope parent)
 {
     this.Parent = parent;
     this.Variables = new Dictionary<string, Value>();
 }
Beispiel #8
0
 public Value Evaluate(Scope scope)
 {
     return this;
 }
Beispiel #9
0
 public Function(IExpression body, Scope scope, List<string> names)
 {
     this.Body = body;
     this.Execution = scope;
     this.Names = names;
 }