コード例 #1
0
ファイル: AliasData.cs プロジェクト: jdruin/F5Eagle
 public AliasData(
     string nameToken,
     Interpreter sourceInterpreter,
     Interpreter targetInterpreter,
     INamespace sourceNamespace,
     INamespace targetNamespace,
     IExecute target,
     ArgumentList arguments,
     OptionDictionary options,
     AliasFlags aliasFlags,
     int startIndex,
     long token
     )
 {
     this.kind              = IdentifierKind.AliasData;
     this.id                = AttributeOps.GetObjectId(this);
     this.nameToken         = nameToken;
     this.sourceInterpreter = sourceInterpreter;
     this.targetInterpreter = targetInterpreter;
     this.sourceNamespace   = sourceNamespace;
     this.targetNamespace   = targetNamespace;
     this.target            = target;
     this.arguments         = arguments;
     this.options           = options;
     this.aliasFlags        = aliasFlags;
     this.startIndex        = startIndex;
     this.token             = token;
 }
コード例 #2
0
        ///////////////////////////////////////////////////////////////////////

        public ReturnCode ToList(
            AliasFlags hasFlags,
            AliasFlags notHasFlags,
            bool hasAll,
            bool notHasAll,
            string pattern,
            bool noCase,
            ref StringList list,
            ref Result error
            )
        {
            StringList inputList;

            //
            // NOTE: If no flags were supplied, we do not bother filtering on
            //       them.
            //
            if ((hasFlags == AliasFlags.None) &&
                (notHasFlags == AliasFlags.None))
            {
                inputList = new StringList(this.Keys);
            }
            else
            {
                inputList = new StringList();

                foreach (KeyValuePair <string, _Wrappers.Alias> pair in this)
                {
                    IAlias alias = pair.Value as IAlias;

                    if (alias == null)
                    {
                        continue;
                    }

                    if (((hasFlags == AliasFlags.None) ||
                         FlagOps.HasFlags(
                             alias.AliasFlags, hasFlags, hasAll)) &&
                        ((notHasFlags == AliasFlags.None) ||
                         !FlagOps.HasFlags(
                             alias.AliasFlags, notHasFlags, notHasAll)))
                    {
                        inputList.Add(pair.Key);
                    }
                }
            }

            if (list == null)
            {
                list = new StringList();
            }

            return(GenericOps <string> .FilterList(
                       inputList, list, Index.Invalid, Index.Invalid,
                       ToStringFlags.None, pattern, noCase, ref error));
        }
コード例 #3
0
        ///////////////////////////////////////////////////////////////////////

        public static bool HasFlags(
            AliasFlags flags,
            AliasFlags hasFlags,
            bool all
            )
        {
            if (all)
            {
                return((flags & hasFlags) == hasFlags);
            }
            else
            {
                return((flags & hasFlags) != AliasFlags.None);
            }
        }
コード例 #4
0
        ///////////////////////////////////////////////////////////////////////

        #region IExecute Members
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            if (targetInterpreter == null)
            {
                result = "invalid interpreter";
                return(ReturnCode.Error);
            }

            ReturnCode   code;
            string       targetName      = null;
            ArgumentList targetArguments = null;

            code = targetInterpreter.GetAliasArguments(
                this, arguments, ref targetName, ref targetArguments,
                ref result);

            if (code == ReturnCode.Ok)
            {
                //
                // NOTE: Grab the target of the alias (this will be null if we
                //       are late-bound).
                //
                IExecute target     = null;
                bool     useUnknown = false;

                code = targetInterpreter.GetAliasTarget(this, targetName,
                                                        targetArguments, LookupFlags.Default, true, ref target,
                                                        ref useUnknown, ref result);

                //
                // NOTE: Do we have a valid target now (we may have already had
                //       one or we may have just succeeded in looking it up)?
                //
                if (code == ReturnCode.Ok)
                {
                    //
                    // NOTE: Create and push a new call frame to track the
                    //       activation of this alias.
                    //
                    string name = StringList.MakeList("alias", this.Name);

                    AliasFlags aliasFlags = this.AliasFlags;

                    ICallFrame frame = interpreter.NewTrackingCallFrame(name,
                                                                        CallFrameFlags.Alias);

                    interpreter.PushAutomaticCallFrame(frame);

                    ///////////////////////////////////////////////////////////

                    bool targetUsable;

                    if (useUnknown)
                    {
                        targetInterpreter.EnterUnknownLevel();
                    }

                    try
                    {
                        if (FlagOps.HasFlags(
                                aliasFlags, AliasFlags.Evaluate, true))
                        {
                            code = targetInterpreter.EvaluateScript(
                                targetArguments, 0, ref result);
                        }
                        else
                        {
                            //
                            // NOTE: Save the current engine flags and then
                            //       enable the external execution flags.
                            //
                            EngineFlags savedEngineFlags =
                                targetInterpreter.BeginExternalExecution();

                            code = targetInterpreter.Execute(
                                targetName, target, clientData,
                                targetArguments, ref result);

                            //
                            // NOTE: Restore the saved engine flags, masking
                            //       off the external execution flags as
                            //       necessary.
                            //
                            /* IGNORED */
                            targetInterpreter.EndAndCleanupExternalExecution(
                                savedEngineFlags);
                        }
                    }
                    finally
                    {
                        targetUsable = Engine.IsUsable(targetInterpreter);

                        if (useUnknown && targetUsable)
                        {
                            targetInterpreter.ExitUnknownLevel();
                        }
                    }

                    ///////////////////////////////////////////////////////////

                    //
                    // NOTE: Pop the original call frame that we pushed above
                    //       and any intervening scope call frames that may be
                    //       leftover (i.e. they were not explicitly closed).
                    //
                    /* IGNORED */
                    interpreter.PopScopeCallFramesAndOneMore();
                }
            }

            return(code);
        }