Example #1
0
    public bool ArgumentMatchesType(VsnArgument arg, VsnArgType type)
    {
        switch (type)
        {
        case VsnArgType.numberArg:
            return(arg.GetType() == typeof(VsnNumber) ||
                   arg.GetType() == typeof(VsnReference));

        case VsnArgType.stringArg:
            return(arg.GetType() == typeof(VsnString) ||
                   arg.GetType() == typeof(VsnReference));

        case VsnArgType.booleanArg:
            return(arg.GetType() == typeof(VsnBoolean) ||
                   arg.GetType() == typeof(VsnReference));

        case VsnArgType.operatorArg:
            return(arg.GetType() == typeof(VsnOperator));

        case VsnArgType.referenceArg:
            return(arg.GetType() == typeof(VsnReference) ||
                   arg.GetType() == typeof(VsnMetaReference));
        }
        return(false);
    }
    public bool EvaluateComparison(VsnArgument first, VsnArgument second)
    {
        if ((first.GetType() == typeof(VsnNumber) && second.GetType() == typeof(VsnNumber)) ||
            (first.GetType() == typeof(VsnReference) && second.GetType() == typeof(VsnNumber)) ||
            (first.GetType() == typeof(VsnNumber) && second.GetType() == typeof(VsnReference)))
        {
            return(CompareFloats(first.GetNumberValue(), second.GetNumberValue()));
        }

        if ((first.GetType() == typeof(VsnString) && second.GetType() == typeof(VsnString)) ||
            (first.GetType() == typeof(VsnReference) && second.GetType() == typeof(VsnString)) ||
            (first.GetType() == typeof(VsnString) && second.GetType() == typeof(VsnReference)))
        {
            return(CompareStrings(first.GetStringValue(), second.GetStringValue()));
        }

        return(CompareVariables(first, second));
    }