Пример #1
0
        public override TreeReference Compile(TreeContext context, SourceLocation location, TreeLocal operand)
        {
            var local = context.CreateLocal();
            var exprs = ImmutableArray.Create <TreeReference>(
                new TreeAssignNode(context, location,
                                   new TreeVariableNode(context, location, local),
                                   new TreeRelationalNode(context, location,
                                                          new TreeVariableNode(context, location, operand), TreeRelationalOperator.Equal,
                                                          new TreeLiteralNode(context, location, Value))));

            if (Alias is TreeLocal alias)
            {
                exprs = exprs.Add(
                    new TreeAssignNode(context, location,
                                       new TreeVariableNode(context, location, alias),
                                       new TreeVariableNode(context, location, operand)));
            }

            return(new TreeBlockNode(context, location, exprs.Add(
                                         new TreeVariableNode(context, location, local))));
        }