public override Expression VisitKeywordMessageSequence(Compiler.SemanticNodes.KeywordMessageSequenceNode node) { Expression expr = this.InlineMessageSend(node); if (expr != null) { return(expr); } this.SetCascadeReceiver(); this.SetResult(node.Message.Accept(this)); return(this.Receiver); }
private Expression InlineMessageSend(Compiler.SemanticNodes.KeywordMessageSequenceNode node) { if (this.CascadeReceiver != null) { return(null); } if (this.IsSuperSend) { return(null); } if ((node.Message.SelectorTokens.Count == 1) && (node.Message.Arguments.Count == 1)) { Compiler.SemanticNodes.BlockNode block = node.Message.Arguments[0].Primary as Compiler.SemanticNodes.BlockNode; if ((block != null) && (block.Arguments.Count == 0) && (node.Message.Arguments[0].Messages == null)) { if (node.Message.SelectorTokens[0].Value == "ifTrue:") { return(this.InlineIfTrueIfFalse(block, null)); } if (node.Message.SelectorTokens[0].Value == "ifFalse:") { return(this.InlineIfTrueIfFalse(null, block)); } if (node.Message.SelectorTokens[0].Value == "and:") { return(this.InlineAnd(block)); } if (node.Message.SelectorTokens[0].Value == "or:") { return(this.InlineOr(block)); } if (node.Message.SelectorTokens[0].Value == "timesRepeat:") { return(this.InlineTimesRepeat(block)); } } } else if ((node.Message.SelectorTokens.Count == 2) && (node.Message.Arguments.Count == 2)) { Compiler.SemanticNodes.BlockNode block1 = node.Message.Arguments[0].Primary as Compiler.SemanticNodes.BlockNode; Compiler.SemanticNodes.BlockNode block2 = node.Message.Arguments[1].Primary as Compiler.SemanticNodes.BlockNode; if ((block1 != null) && (block1.Arguments.Count == 0) && (node.Message.Arguments[0].Messages == null)) { if ((block2 != null) && (block2.Arguments.Count == 0) && (node.Message.Arguments[1].Messages == null)) { if ((node.Message.SelectorTokens[0].Value == "ifTrue:") && (node.Message.SelectorTokens[1].Value == "ifFalse:")) { return(this.InlineIfTrueIfFalse(block1, block2)); } if ((node.Message.SelectorTokens[0].Value == "ifFalse:") && (node.Message.SelectorTokens[1].Value == "ifTrue:")) { return(this.InlineIfTrueIfFalse(block2, block1)); } } } if ((block2 != null) && (block2.Arguments.Count == 1) && (node.Message.Arguments[1].Messages == null)) { if ((node.Message.SelectorTokens[0].Value == "to:") && (node.Message.SelectorTokens[1].Value == "do:")) { return(this.InlineToDo(node.Message.Arguments[0], block2)); } } } else if ((node.Message.SelectorTokens.Count == 3) && (node.Message.Arguments.Count == 3)) { Compiler.SemanticNodes.BlockNode block = node.Message.Arguments[2].Primary as Compiler.SemanticNodes.BlockNode; if ((block != null) && (block.Arguments.Count == 1) && (node.Message.Arguments[2].Messages == null)) { if ((node.Message.SelectorTokens[0].Value == "to:") && (node.Message.SelectorTokens[1].Value == "by:") && (node.Message.SelectorTokens[2].Value == "do:")) { return(this.InlineToByDo(node.Message.Arguments[0], node.Message.Arguments[1], block)); } } } return(null); }