コード例 #1
0
ファイル: IDExpression.cs プロジェクト: ryancheung/PPather
        public override Value GetValue()
        {
            if (expression != null)
            {
                // know where it is
                expression.GetValue();
            }

            return(task.GetValueOfId(id));
        }
コード例 #2
0
ファイル: NodeTask.cs プロジェクト: ryancheung/PPather
        public virtual Value GetValueOfId(string def)
        {
            int dotIndex = def.IndexOf('.');

            if (dotIndex != -1)
            {
                // dot in name, search in named chilren tasks for it
                String cname = def.Substring(0, dotIndex);
                String cdef  = def.Substring(dotIndex + 1);

                foreach (NodeTask t in subTasks)
                {
                    if (t.name != null && t.name == cname)
                    {
                        Value v = t.GetValueOfId(cdef);
                        return(v);
                    }
                }
            }
            else
            {
                foreach (NodeDefinition d in definitions)
                {
                    if (d.IsNamed(def))
                    {
                        NodeExpression e   = d.GetExpression();
                        Value          val = e.GetValue();

                        //  PPather.WriteLine(" def: " + def + " got e " + e + " and val " + val);

                        return(val);
                    }
                }

                if (parent != null)
                {
                    Value e = parent.GetValueOfId(def);
                    return(e);
                }
            }

            Error("No definition of idenfifier " + def);
            return(null);
        }
コード例 #3
0
        public override Value GetValue()
        {
            Value v = e.GetValue();

            if (v.IsInt())
            {
                int i = -v.GetIntValue();
                v = new Value(i.ToString());
            }
            else if (v.IsFloat())
            {
                float f = -v.GetFloatValue();
                v = new Value(f.ToString());
            }
            else
            {
                Error("Negating non numerical value " + v);
            }

            return(v);
        }