Beispiel #1
0
 public object this[string fullName] {
     get {
         HotloaderVariable var = p_GlobalClass.ResolveVariable(fullName);
         if (var == null)
         {
             return(null);
         }
         return(var.Value.Evaluate());
     }
 }
Beispiel #2
0
    public object GetValue(out HotloaderValueType type)
    {
        type = p_Type;

        //evaluation?
        HotloaderExpression eval = p_Raw as HotloaderExpression;

        if (eval != null)
        {
            return(eval.Evaluate(out type));
        }

        /*variable?*/
        if (p_Type == HotloaderValueType.VARIABLE)
        {
            //resolve the variable
            HotloaderVariable variable = p_Variable.Parent.ResolveVariable((string)p_Raw);
            if (variable == null)
            {
                variable = p_Globals.ResolveVariable((string)p_Raw);
            }
            if (variable == null)
            {
                throw new HotloaderParserException(
                          p_File,
                          p_Line,
                          p_Column,
                          String.Format(
                              "Variable \"{0}\" does not exist",
                              p_Raw));
            }

            //verify no cross-referencing
            if (variable == p_Variable)
            {
                throw new HotloaderParserException(
                          p_File,
                          p_Line,
                          p_Column,
                          "Cycle-dependancy found! Cannot self-reference");
            }

            //evaluate
            object value = variable.Value.Evaluate(out type);
            return(value);
        }

        //this should never happen.
        return(p_Raw);
    }