Example #1
0
    public static string CompileExpression(string source)
    {
        var cflat         = new CFlat();
        var compileErrors = cflat.CompileExpression(source, TestHelper.CompilerMode);

        if (compileErrors.count > 0)
        {
            return("COMPILE ERROR: " + cflat.GetFormattedCompileErrors());
        }
        return(null);
    }
Example #2
0
    public static R RunExpression <R>(CFlat cflat, string source, out CallAssertion assertion)
        where R : struct, IMarshalable
    {
        var compileErrors = cflat.CompileExpression(source, CompilerMode);

        if (compileErrors.count > 0)
        {
            throw new CompileErrorException(cflat.GetFormattedCompileErrors());
        }

        assertion = new CallAssertion(source, cflat);
        var function = cflat.GetFunction <Empty, R>(string.Empty);

        if (!function.isSome)
        {
            throw new FunctionNotFoundException();
        }

        return(function.value.Call(cflat, new Empty()));
    }