Babel.Compiler.TypeCheckingVisitor.VisitIterCall C# (CSharp) Method

VisitIterCall() public method

public VisitIterCall ( IterCallExpression iter ) : void
iter IterCallExpression
return void
        public override void VisitIterCall(IterCallExpression iter)
        {
            if (currentLoop == null) {
                report.Error(iter.Location,
                             "iterator calls must appear inside loops");
                return;
            }
            TypeData receiverType;
            if (iter.Receiver != null) {
                iter.Receiver.Accept(this);
                receiverType = iter.Receiver.NodeType;
            }
            else {
                iter.TypeSpecifier.Accept(this);
                receiverType = iter.TypeSpecifier.NodeType;
            }
            if (receiverType == null) {
                report.Error(iter.Location, "no match for {0}", iter.Name);
                return;
            }
            iter.Arguments.Accept(this);
            try {
                MethodData method = receiverType.LookupMethod(iter.Name,
                                                              iter.Arguments,
                                                              iter.HasValue);
                SetupIter(iter, method, receiverType);
            }
            catch (LookupMethodException e) {
                string iterInfo = receiverType.FullName +
                    "::" + iter.Name;
                if (iter.Arguments.Length > 0) {
                    iterInfo += "(";
                    foreach (ModalExpression arg in iter.Arguments) {
                        if (arg != iter.Arguments.First)
                            iterInfo += ",";
                        iterInfo += arg.NodeType.FullName;
                    }
                    iterInfo += ")";
                }
                if (iter.HasValue)
                    iterInfo += ":_";
                report.Error(iter.Location,
                             "{0} for {1}", e.Message, iterInfo);
            }
        }