예제 #1
0
        static Operation CompileExpression(Elm.Expression expression)
        {
            List <Operand> operands;

            switch (expression)
            {
            case Elm.Literal literal:
                operands = CompileLiteral(literal);
                break;

            case Elm.If @if:
                operands = CompileIf(@if);
                break;

            case Elm.Not not:
                operands = CompileNot(not);
                break;

            default:
                throw new NotImplementedException($"The {expression.GetType()} is not yet implemented.");
            }
            return(new Operation {
                SourceOperands = operands
            });
        }
예제 #2
0
        static Source TranslateExpression(Elm.Expression expression)
        {
            var cql    = Modeler.BuildSource("cql.scaly");
            var source = new Source
            {
                FileName = "",
                Usings   = new List <Namespace> {
                    new Namespace {
                        Path = "CQL"
                    }
                },
                Sources = new List <Source> {
                    cql
                },
            };

            if (source.Functions == null)
            {
                source.Functions = new List <Function>();
            }
            var main = Modeler.BuildSource("main.scaly").Functions[0];

            main.Routine.Operation = CompileExpression(expression);
            main.Source            = source;
            source.Functions.Add(main);
            return(source);
        }