Exemplo n.º 1
0
        PluginResult ForceContinue(ref ExpressionNode Node, Identifier DeclarationType = null,
                                   OverloadSelectionData OverloadData = new OverloadSelectionData(), ResolveNodeFlags Flags = ResolveNodeFlags.None)
        {
            if (Node is StrExpressionNode)
            {
                var StrNode = Node as StrExpressionNode;
                var Code    = StrNode.Code;

                Node = GetOrDeclareId(Code, !DoNotFail, DeclarationType, OverloadData);

                if (Node == null)
                {
                    if (!DoNotFail)
                    {
                        return(PluginResult.Failed);
                    }

                    Node = StrNode;
                    Node.InterrupterPlugin = -1;
                    Dependencies.Add(StrNode.Code);
                }
                else
                {
                    if (ResolveNode(ref Node) == PluginResult.Failed)
                    {
                        return(PluginResult.Failed);
                    }

                    return(PluginResult.Ready);
                }
            }
            else if (Node is IdExpressionNode)
            {
                var IdNode = Node as IdExpressionNode;
                var Id     = IdNode.Identifier.RealId;

                if (!(Id is Constructor))
                {
                    if ((Flags & ResolveNodeFlags.Member) == 0)
                    {
                        var Lang = State.Language;
                        if ((Lang.Flags & LangaugeFlags.AllowMemberFuncStaticRef) == 0 ||
                            !(IdNode.Identifier.RealId is Function))
                        {
                            if (IdNode.Identifier.IsInstanceIdentifier)
                            {
                                State.Messages.Add(MessageId.NonStatic, Node.Code);
                                return(PluginResult.Failed);
                            }
                        }
                    }
                    else
                    {
                        if (!IdNode.Identifier.IsInstanceIdentifier)
                        {
                            State.Messages.Add(MessageId.Static, Node.Code);
                            return(PluginResult.Failed);
                        }
                    }
                }
            }
            else if (Node is LinkingNode)
            {
                var LinkingNode = Node as LinkingNode;
                var LinkedNode  = LinkingNode.LinkedNode;

                LinkedNode.Node = ResolveNode(LinkedNode.Node, DeclarationType, OverloadData);
                if (LinkedNode.Node == null)
                {
                    return(PluginResult.Failed);
                }
            }
            else if (Node is OpExpressionNode)
            {
                var OpNode = Node as OpExpressionNode;
                var Ch     = OpNode.Children;
                var Op     = OpNode.Operator;

                if (Op == Operator.Tuple)
                {
                    var Failed        = false;
                    var TupleDeclType = DeclarationType != null ? DeclarationType.RealId as TupleType : null;
                    for (var i = 0; i < Ch.Length; i++)
                    {
                        var T = (Identifier)null;
                        if (TupleDeclType != null)
                        {
                            T = TupleDeclType.StructuredScope.IdentifierList[i].TypeOfSelf;
                        }

                        if ((Ch[i] = ResolveNode(Ch[i], T)) == null)
                        {
                            Failed = true;
                        }
                    }

                    if (Failed)
                    {
                        return(PluginResult.Failed);
                    }
                }
                else if (Op == Operator.Member)
                {
                    if (Ch[1] is StrExpressionNode)
                    {
                        var Res = ForceContinue_MemberNode(ref Node, OverloadData);
                        if (Res != PluginResult.Succeeded)
                        {
                            return(Res);
                        }
                    }

                    Ch[1] = ResolveNode(Ch[1], Flags: Flags | ResolveNodeFlags.Member);
                    if (Ch[1] == null)
                    {
                        return(PluginResult.Failed);
                    }
                }
                else if (Op == Operator.ScopeResolution)
                {
                    if (Ch[1] is StrExpressionNode)
                    {
                        var Res = ForceContinue_ScopeResolution(ref Node, OverloadData);
                        if (Res != PluginResult.Succeeded)
                        {
                            return(Res);
                        }
                    }

                    Ch[1] = ResolveNode(Ch[1], Flags: Flags | ResolveNodeFlags.Member);
                    if (Ch[1] == null)
                    {
                        return(PluginResult.Failed);
                    }
                }
                else
                {
                    throw new ApplicationException();
                }
            }
            else
            {
                throw new ApplicationException();
            }

            return(PluginResult.Succeeded);
        }
Exemplo n.º 2
0
        PluginResult ResolveNode(ref ExpressionNode Node, Identifier DeclarationType = null,
                                 OverloadSelectionData OverloadData = new OverloadSelectionData(), ResolveNodeFlags Flags = ResolveNodeFlags.None)
        {
            if (Node.InterrupterPlugin != -1)
            {
                if (Node.InterrupterPlugin != Array.IndexOf(Parent.Plugins, this))
                {
                    return(PluginResult.Succeeded);
                }

                var Res = ForceContinue(ref Node, DeclarationType, OverloadData, Flags);
                if (Res != PluginResult.Succeeded)
                {
                    return(Res);
                }

                if (Parent.FinishNode(ref Node, false) == PluginResult.Failed)
                {
                    return(PluginResult.Failed);
                }

                return(PluginResult.Ready);
            }

            return(PluginResult.Succeeded);
        }
Exemplo n.º 3
0
        ExpressionNode ResolveNode(ExpressionNode Node, Identifier DeclarationType = null,
                                   OverloadSelectionData OverloadData = new OverloadSelectionData(), ResolveNodeFlags Flags = ResolveNodeFlags.None)
        {
            var Res = ResolveNode(ref Node, DeclarationType, OverloadData, Flags);

            return(Res == PluginResult.Failed ? null : Node);
        }