Beispiel #1
0
        public static string EvaluateAsName(IExpression expression, ValueEnvironment environment)
        {
            if (expression == null)
            {
                return(null);
            }

            if (expression is NameExpression)
            {
                return(((NameExpression)expression).Name);
            }

            if (expression is DotExpression)
            {
                DotExpression dot = (DotExpression)expression;

                return(EvaluateAsName(dot.Expression, environment) + "." + dot.Name);
            }

            object result = expression.Evaluate(environment);

            if (result == null)
            {
                return(null);
            }

            return(result.ToString());
        }
        public static Type GetType(ValueEnvironment environment, string name)
        {
            object obj = environment.GetValue(name);

            if (obj != null && obj is Type)
            {
                return((Type)obj);
            }

            return(GetType(name));
        }
Beispiel #3
0
        public void SetValue(string key, object value)
        {
            key = key.ToLower();

            if (this.values.ContainsKey(key))
            {
                this.values[key] = value;
                return;
            }

            ValueEnvironment environment = this.GetNonLocalEnvironmentContaining(key);

            if (environment != null)
            {
                environment.SetValue(key, value);
                return;
            }

            this.values[key] = value;
        }
Beispiel #4
0
 public Machine(ValueEnvironment environment)
 {
     this.environment = environment;
 }
Beispiel #5
0
 public ValueEnvironment(ValueEnvironment parent, ValueEnvironmentType type)
 {
     this.parent = parent;
     this.type   = type;
 }
Beispiel #6
0
 public ValueEnvironment(ValueEnvironment parent)
     : this(parent, ValueEnvironmentType.Normal)
 {
 }