Beispiel #1
0
        private bool BinaryOp(RhoAstNode node, EOperation op)
        {
            Generate(node.GetChild(0));
            Generate(node.GetChild(1));

            return(Append(op));
        }
Beispiel #2
0
        /// <summary>
        /// Generate executable pi-code from given node.
        /// </summary>
        private bool Generate(RhoAstNode node)
        {
            if (node == null)
            {
                return(InternalFail("Unexpected empty RhoAstNode"));
            }

            switch (node.Type)
            {
            case ERhoAst.Suspend:
                return(Append(EOperation.Suspend));

            case ERhoAst.Pathname:
                return(Token(node));

            case ERhoAst.Assignment:
                Generate(node.GetChild(0));
                AppendQuoted(node.GetChild(1));
                return(Append(EOperation.Store));

            case ERhoAst.IndexOp:
                return(BinaryOp(node, EOperation.At));

            case ERhoAst.Call:
                return(Call(node));

            case ERhoAst.GetMember:
                return(GetMember(node));

            case ERhoAst.Conditional:
                return(If(node));

            case ERhoAst.Block:
                return(PushNew() && Block(node) && Append(Pop()));

            case ERhoAst.List:
                return(List(node));

            case ERhoAst.For:
                return(For(node));

            case ERhoAst.Program:
                return(Block(node));

            default:
                return(Token(node));
            }
        }
Beispiel #3
0
 private bool AppendChildOp(RhoAstNode node, EOperation op)
 => Generate(node.GetChild(0)) && Append(op);