Example #1
0
File: Scope.cs Project: haasn/-g-pl
        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;
        }
Example #2
0
File: Block.cs Project: haasn/-g-pl
        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;
        }
Example #3
0
File: Tier.cs Project: haasn/-g-pl
        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
        }
Example #4
0
File: Name.cs Project: haasn/-g-pl
 public Value Evaluate(Scope scope)
 {
     return scope.Find(Identifier);
 }
Example #5
0
 public override Value Evaluate(Scope scope)
 {
     return scope.Find(Name, Value.Evaluate(scope));
 }
Example #6
0
 public virtual Value Evaluate(Scope scope)
 {
     return scope.Create(Name, new ForeverAlone());
 }
Example #7
0
File: Scope.cs Project: haasn/-g-pl
 public Scope(Scope parent)
 {
     this.Parent = parent;
     this.Variables = new Dictionary<string, Value>();
 }
Example #8
0
File: Value.cs Project: haasn/-g-pl
 public Value Evaluate(Scope scope)
 {
     return this;
 }
Example #9
0
File: Value.cs Project: haasn/-g-pl
 public Function(IExpression body, Scope scope, List<string> names)
 {
     this.Body = body;
     this.Execution = scope;
     this.Names = names;
 }