Esempio n. 1
0
    public override object Evaluate(UnityELEvaluator context)
    {
        object amount      = Rhs.Evaluate(context);
        float  floatAmount = TypeCoercer.CoerceToType <float>(this, amount);

        float floatCurrent = 0;

        // If the value doesn't already exists (and we can detect that) we start with zero.
        bool readCurrentValue = true;

        if (Lhs is ExistsSupport)
        {
            readCurrentValue = ((ExistsSupport)Lhs).Exists(context);
        }
        if (readCurrentValue)
        {
            object current = Lhs.Evaluate(context);
            floatCurrent = TypeCoercer.CoerceToType <float>(this, current);
        }

        float result = ExponentToken.FastExponent(floatCurrent, floatAmount);

        ((AssignableToken)Lhs).Assign(context, result);

        return(result);
    }
Esempio n. 2
0
    public void TestTokenProperties()
    {
        IntegerToken  lhs    = new IntegerToken(1);
        IntegerToken  rhs    = new IntegerToken(2);
        ExponentToken result = new ExponentToken(0, lhs, rhs);

        Assert.AreEqual(lhs, result.Lhs);
        Assert.AreEqual(rhs, result.Rhs);
    }