private bool BinaryOp(RhoAstNode node, EOperation op) { Generate(node.GetChild(0)); Generate(node.GetChild(1)); return(Append(op)); }
/// <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)); } }
private bool AppendChildOp(RhoAstNode node, EOperation op) => Generate(node.GetChild(0)) && Append(op);