Exemple #1
0
        ///////////////////////////////////////////////////////////////////////

        #region IResolve Members
        public override ReturnCode GetVariableFrame(
            ref ICallFrame frame,
            ref string varName,
            ref VariableFlags flags,
            ref Result error
            )
        {
            INamespace @namespace = NamespaceOps.GetCurrent(
                base.Interpreter, frame);

            if (@namespace != null)
            {
                IResolve resolve = @namespace.Resolve;

                if (resolve != null)
                {
                    return(resolve.GetVariableFrame(
                               ref frame, ref varName, ref flags, ref error));
                }
            }

            return(NamespaceOps.GetVariableFrame(
                       base.Interpreter, ref frame, ref varName, ref flags,
                       ref error));
        }
Exemple #2
0
        ///////////////////////////////////////////////////////////////////////

        public bool HasFlags(
            VariableFlags hasFlags,
            bool all
            )
        {
            return(FlagOps.HasFlags(flags, hasFlags, all));
        }
Exemple #3
0
        ///////////////////////////////////////////////////////////////////////

        public override ReturnCode GetVariable(
            ICallFrame frame,
            string varName,
            string varIndex,
            ref VariableFlags flags,
            ref IVariable variable,
            ref Result error
            )
        {
            Interpreter interpreter = base.Interpreter;

            if (interpreter != null)
            {
                //
                // NOTE: Lookup the variable using the default semantics
                //       provided by the interpreter.  This resolver does
                //       not support namespaces.  At some point in the
                //       future, alternative resolvers may be used to
                //       support namespaces.
                //
                return(interpreter.GetVariable(
                           frame, varName, varIndex, ref flags,
                           ref variable, ref error));
            }
            else
            {
                error = "invalid interpreter";
            }

            return(ReturnCode.Error);
        }
Exemple #4
0
        ///////////////////////////////////////////////////////////////////////

        #region IResolve Members
        public override ReturnCode GetVariableFrame(
            ref ICallFrame frame,
            ref string varName,
            ref VariableFlags flags,
            ref Result error
            )
        {
            Interpreter interpreter = base.Interpreter;

            if (interpreter != null)
            {
                //
                // NOTE: This is used for legacy compatibility
                //       with the Eagle beta releases.
                //
                frame = interpreter.GetVariableFrame(
                    frame, ref varName, ref flags); /* EXEMPT */

                return(ReturnCode.Ok);
            }
            else
            {
                error = "invalid interpreter";
            }

            return(ReturnCode.Error);
        }
Exemple #5
0
        private void Validate(string name, VariableFlags flags)
        {
            Name  = name;
            Flags = flags;

            if (Name.Contains(' '))
            {
                Console.Error.WriteLine("Variable name contains space(s), this is not allowed: '{0}'", Name);
                return;
            }

            if (AllVariables.ContainsKey(Name))
            {
                Console.Error.WriteLine("Duplicate variable name detected: {0}", Name);
                return;
            }

            const VariableFlags core = VariableFlags.Client | VariableFlags.Server | VariableFlags.ClientOnly | VariableFlags.ServerOnly;

            switch (flags & core)
            {
            case VariableFlags.None:
                Console.Error.WriteLine("Variable {0} has no 'core' flag - must have one of Client, Server, ClientOnly and ServerOnly");
                return;

            case VariableFlags.Client:
            case VariableFlags.Server:
            case VariableFlags.ClientOnly:
            case VariableFlags.ServerOnly:
                break;

            default:
                Console.Error.WriteLine("Variable {0} has multiple 'core' flags - must have only one of Client, Server, ClientOnly and ServerOnly");
                return;
            }

#if SERVER
            if (HasFlags(VariableFlags.Client))
            {
                return;
            }
            else if (HasFlags(VariableFlags.ClientOnly))
            {
#if DEBUG
                Console.Error.WriteLine("Client-only variable {0} is defined on the server!", Name);
#endif
                return;
            }
#elif CLIENT
            if (HasFlags(VariableFlags.ServerOnly))
            {
#if DEBUG
                Console.Error.WriteLine("Server-only variable {0} is defined on the client!", Name);
#endif
                return;
            }
#endif

            AllVariables.Add(Name, this);
        }
Exemple #6
0
        ///////////////////////////////////////////////////////////////////////

        internal StringList GetWatchpoints()
        {
            StringList result = new StringList();

            foreach (KeyValuePair <string, IVariable> pair in this)
            {
                IVariable variable = pair.Value;

                if (variable == null)
                {
                    continue;
                }

                VariableFlags flags = EntityOps.GetWatchpointFlags(
                    variable.Flags);

                if (flags != VariableFlags.None)
                {
                    //
                    // NOTE: Two element sub-list of name and watch types.
                    //
                    result.Add(new StringList(
                                   variable.Name, flags.ToString()).ToString());
                }
            }

            return(result);
        }
Exemple #7
0
 private VariableInfo(RegType registerType, int size, VariableClass @class, VariableFlags flags, string name)
 {
     this._registerType = registerType;
     this._size = (byte)size;
     this._class = @class;
     this._flags = flags;
     this._name = name;
 }
Exemple #8
0
        //private FieldDeclarationSyntax ParseConstantFieldDeclaration(SyntaxListBuilder<AnnotationSyntax> attributes, SyntaxListBuilder modifiers, SyntaxKind parentKind)
        //{
        //	var constToken = this.EatToken(SyntaxKind.ConstKeyword);
        //	modifiers.Add(constToken);

        //	var type = this.ParseType(false);

        //	var variables = this._pool.AllocateSeparated<VariableDeclaratorSyntax>();
        //	try
        //	{
        //		this.ParseVariableDeclarators(type, VariableFlags.Const, variables, parentKind);
        //		var semicolon = this.EatToken(SyntaxKind.SemicolonToken);
        //		return _syntaxFactory.FieldDeclaration(
        //			attributes,
        //			modifiers.ToTokenList(),
        //			_syntaxFactory.VariableDeclaration(type, variables),
        //			semicolon);
        //	}
        //	finally
        //	{
        //		this._pool.Free(variables);
        //	}
        //}



        private void ParseVariableDeclarators(TypeSyntax type, VariableFlags flags, SeparatedSyntaxListBuilder <VariableDeclaratorSyntax> variables, SyntaxKind parentKind)
        {
            // Although we try parse variable declarations in contexts where they are not allowed (non-interactive top-level or a namespace)
            // the reported errors should take into consideration whether or not one expects them in the current context.
            bool variableDeclarationsExpected = (parentKind != SyntaxKind.CompilationUnit);

            ParseVariableDeclarators(type, flags, variables, variableDeclarationsExpected);
        }
Exemple #9
0
 public Variable(string name, string defaultVal, VariableFlags flags, StringCallback callback)
 {
     Validate(name, flags);
     IsNumeric       = false;
     DefaultValue    = strVal = defaultVal;
     stringCallback  = callback;
     numericCallback = null;
 }
Exemple #10
0
 public Variable(string name, float defaultVal, VariableFlags flags, NumericCallback callback)
 {
     Validate(name, flags);
     IsNumeric       = true;
     numericVal      = defaultVal;
     DefaultValue    = strVal = defaultVal.ToString();
     stringCallback  = null;
     numericCallback = callback;
 }
Exemple #11
0
 public void Setup(VariableData vd, VariableFlags flags = 0, int inRegs = 0, int allocableRegs = 0)
 {
     VariableData  = vd;
     Flags         = flags;
     UsageCount    = 0;
     InRegIndex    = RegisterIndex.Invalid;
     OutRegIndex   = RegisterIndex.Invalid;
     InRegs        = inRegs;
     AllocableRegs = allocableRegs;
 }
Exemple #12
0
        ///////////////////////////////////////////////////////////////////////

        #region IResolve Members
        public virtual ReturnCode GetVariableFrame(
            ref ICallFrame frame,
            ref string varName,
            ref VariableFlags flags,
            ref Result error
            )
        {
            error = "not implemented";
            return(ReturnCode.Error);
        }
Exemple #13
0
        ///////////////////////////////////////////////////////////////////////

        #region IState Members (Optional)
        /// <summary>
        /// Optionally initializes any state information required by the
        /// command.
        /// </summary>
        /// <param name="interpreter">
        /// The interpreter context we are executing in.
        /// </param>
        /// <param name="clientData">
        /// The extra data supplied when this command was initially created, if
        /// any.
        /// </param>
        /// <param name="result">
        /// Upon success, this must contain the result of the command.
        /// Upon failure, this must contain an appropriate error message.
        /// </param>
        /// <returns>
        /// ReturnCode.Ok on success, ReturnCode.Error on failure.
        /// </returns>
        public override ReturnCode Initialize(
            Interpreter interpreter, /* in */
            IClientData clientData,  /* in */
            ref Result result        /* out */
            )
        {
            //
            // NOTE: We require a valid interpreter context.
            //
            if (interpreter == null)
            {
                result = "invalid interpreter";
                return(ReturnCode.Error);
            }

            //
            // NOTE: Does the variable we are interested in already exist?
            //       If so, skip adding it; unfortunately, this means that
            //       we cannot add the variable trace.
            //
            VariableFlags varFlags = VariableFlags.GlobalOnly;
            string        varName  = GetType().Name;

            if (interpreter.DoesVariableExist(
                    varFlags, varName) != ReturnCode.Ok)
            {
                //
                // NOTE: Grab the plugin that owns us.
                //
                IPlugin plugin = this.Plugin;

                //
                // NOTE: Add a variable that has our custom variable trace
                //       callback.
                //
                TraceList traces = new TraceList(
                    clientData, TraceFlags.None, plugin,
                    new TraceCallback[] { PluginTraceCallback }
                    );

                if (interpreter.AddVariable(
                        varFlags, varName, traces, true,
                        ref result) == ReturnCode.Ok)
                {
                    addedVariable = true;
                }
                else
                {
                    return(ReturnCode.Error);
                }
            }

            return(base.Initialize(interpreter, clientData, ref result));
        }
Exemple #14
0
        ///////////////////////////////////////////////////////////////////////

        internal Variable(
            ICallFrame frame,
            string name,
            VariableFlags flags,
            string qualifiedName,
            TraceList traces,
            EventWaitHandle @event
            )
            : this(frame, name, flags, qualifiedName, (string)null, @event)
        {
            this.traces = traces;
        }
Exemple #15
0
        public VariableAttributes Add(VariableData vd, VariableFlags flags, int newAllocable)
        {
            var va = _tmpList[VariableCount++];

            va.Setup(vd, flags, 0, newAllocable);
            va.UsageCount += 1;
            vd.Attributes  = va;

            RegisterContextVariable(vd);
            RegCount.Add(vd.Info.RegisterClass);
            return(va);
        }
Exemple #16
0
        ///////////////////////////////////////////////////////////////////////

        public void Reset(
            EventWaitHandle @event
            )
        {
            flags         = VariableFlags.None;
            qualifiedName = null;
            link          = null;
            linkIndex     = null;
            value         = null;
            arrayValue    = null;
            traces        = null; // BUGBUG: Is this correct (i.e. does Tcl do this)?
            this.@event   = @event;
        }
Exemple #17
0
        ///////////////////////////////////////////////////////////////////////

        public VariableFlags SetFlags(
            VariableFlags flags,
            bool set
            )
        {
            if (set)
            {
                return(this.flags |= flags);
            }
            else
            {
                return(this.flags &= ~flags);
            }
        }
Exemple #18
0
        ///////////////////////////////////////////////////////////////////////

        #region Private Constructors
        private Variable(
            ICallFrame frame,
            string name,
            VariableFlags flags,
            string qualifiedName,
            IVariable link,
            string linkIndex,
            EventWaitHandle @event
            )
            : this(frame, name, flags, qualifiedName, (string)null, @event)
        {
            this.link      = link;
            this.linkIndex = linkIndex;
        }
Exemple #19
0
        ///////////////////////////////////////////////////////////////////////

        public static bool HasFlags(
            VariableFlags flags,
            VariableFlags hasFlags,
            bool all
            )
        {
            if (all)
            {
                return((flags & hasFlags) == hasFlags);
            }
            else
            {
                return((flags & hasFlags) != VariableFlags.None);
            }
        }
Exemple #20
0
        ///////////////////////////////////////////////////////////////////////////////////////

        #region IExecute Members
        public override ReturnCode Execute(
            Interpreter interpreter,
            IClientData clientData,
            ArgumentList arguments,
            ref Result result
            )
        {
            ReturnCode code = ReturnCode.Ok;

            if (interpreter != null)
            {
                if (arguments != null)
                {
                    if (arguments.Count == 2)
                    {
                        VariableFlags flags    = VariableFlags.NoElement;
                        IVariable     variable = null;

                        code = interpreter.GetVariableViaResolversWithSplit(
                            arguments[1], ref flags, ref variable, ref result);

                        if (code == ReturnCode.Ok)
                        {
                            result = StringList.MakeList(
                                flags, variable.Flags);
                        }
                    }
                    else
                    {
                        result = "wrong # args: should be \"getf varName\"";
                        code   = ReturnCode.Error;
                    }
                }
                else
                {
                    result = "invalid argument list";
                    code   = ReturnCode.Error;
                }
            }
            else
            {
                result = "invalid interpreter";
                code   = ReturnCode.Error;
            }

            return(code);
        }
Exemple #21
0
        private void UnuseBefore(RegisterClass @class)
        {
            var list  = VaList[(int)@class];
            var count = Count.Get(@class);

            const VariableFlags checkFlags = VariableFlags.XReg | VariableFlags.RMem | VariableFlags.RFunc | VariableFlags.RCall | VariableFlags.RConv;

            for (var i = 0; i < count; i++)
            {
                var va = list[i];

                if ((va.Flags & checkFlags) == VariableFlags.WReg)
                {
                    Translator.Unuse(va.VariableData, @class);
                }
            }
        }
Exemple #22
0
        private void DoIntegratedToggled(object source, ToggledArgs args)
        {
            Node               node   = d_treeview.NodeStore.FindPath(args.Path);
            VariableFlags      flags  = node.Variable.Flags;
            CellRendererToggle toggle = (CellRendererToggle)source;

            if (!toggle.Active)
            {
                flags |= VariableFlags.Integrated;
            }
            else
            {
                flags &= ~VariableFlags.Integrated;
            }

            d_actions.Do(new Undo.ModifyVariable(d_wrapper, node.Variable, flags));
        }
        private void ParseDeclaration(bool isFinal, out TypeSyntax type, SeparatedSyntaxListBuilder <VariableDeclaratorSyntax> variables)
        {
            type = this.ParseType(false);

            VariableFlags flags = VariableFlags.Local;

            if (isFinal)
            {
                flags |= VariableFlags.Final;
            }

            var saveTerm = this._termState;

            this._termState |= TerminatorState.IsEndOfDeclarationClause;
            this.ParseVariableDeclarators(type, flags, variables, variableDeclarationsExpected: true);
            this._termState = saveTerm;
        }
Exemple #24
0
        ///////////////////////////////////////////////////////////////////////

        #region Public Methods
        public VariableFlags GetFlags(
            string key,
            VariableFlags @default
            )
        {
            if ((key != null) && (elementFlags != null))
            {
                VariableFlags value;

                if (elementFlags.TryGetValue(key, out value))
                {
                    return(value);
                }
            }

            return(@default);
        }
Exemple #25
0
        private static VariableFlags GetOriginalVariableFlags(CSharp.Syntax.VariableDeclaratorSyntax old)
        {
            var           parent = GetOldParent(old);
            var           mods   = GetOriginalModifiers(parent);
            VariableFlags flags  = default(VariableFlags);


            if (mods.Any(SyntaxKind.FinalKeyword))
            {
                flags |= VariableFlags.Final;
            }

            if (parent != null && (parent.Kind == SyntaxKind.VariableDeclaration || parent.Kind == SyntaxKind.LocalDeclarationStatement))
            {
                flags |= VariableFlags.Local;
            }

            return(flags);
        }
Exemple #26
0
        public VariableRegistryItem(object defaultValue, object max = null, object min = null, string title = "", string remark = "", VariableFlags flags = VariableFlags.None)
        {
            this.Value   = defaultValue;
            this.Default = defaultValue;

            if (this.Value != null && max != null && this.Value.GetType() == max.GetType())
            {
                this.Max = max;
            }

            if (this.Value != null && min != null && this.Value.GetType() == min.GetType())
            {
                this.Min = min;
            }

            this.Title  = title;
            this.Remark = remark;
            this.Flags  = flags;
        }
Exemple #27
0
        ///////////////////////////////////////////////////////////////////////

        public override ReturnCode GetVariable(
            ICallFrame frame,
            string varName,
            string varIndex,
            ref VariableFlags flags,
            ref IVariable variable,
            ref Result error
            )
        {
            IResolve resolve = null;
            string   tail    = null;

            INamespace @namespace = GetNamespaceForVariable(
                frame, varName, ref resolve, ref tail, ref error);

            if (@namespace != null)
            {
                if (resolve != null)
                {
                    return(resolve.GetVariable(
                               frame, tail, varIndex, ref flags, ref variable,
                               ref error));
                }
                else
                {
                    Interpreter interpreter = base.Interpreter;

                    if (!NamespaceOps.IsGlobal(interpreter, @namespace))
                    {
                        frame = @namespace.VariableFrame;

                        return(base.GetVariable(
                                   frame, tail, varIndex, ref flags, ref variable,
                                   ref error));
                    }
                }
            }

            return(base.GetVariable(
                       frame, varName, varIndex, ref flags, ref variable,
                       ref error));
        }
Exemple #28
0
        internal void Merge(VariableRegistryItem variableRegistryItem)
        {
            this.Default = variableRegistryItem.Default;
            this.Title   = variableRegistryItem.Title;
            this.Remark  = variableRegistryItem.Remark;
            this.Min     = variableRegistryItem.Min;
            this.Max     = variableRegistryItem.Max;
            Type typ         = this.Value.GetType();
            Type defaultType = variableRegistryItem.Default.GetType();

            if (!defaultType.Equals(typ) && this.Value.GetType().Equals(typeof(long)) && TypeUtils.IsNumericType(defaultType))
            {
                this.Value = Convert.ChangeType(this.Value, defaultType);
            }
            else if (this.Value == null && !defaultType.Equals(typ))
            {
                this.Value = variableRegistryItem.Default;
            }
            this.Flags = variableRegistryItem.Flags;
        }
Exemple #29
0
        private void ParseVariableDeclarators(TypeSyntax type, VariableFlags flags, SeparatedSyntaxListBuilder <VariableDeclaratorSyntax> variables, bool variableDeclarationsExpected)
        {
            variables.Add(this.ParseVariableDeclarator(type, flags, isFirst: true));

            while (true)
            {
                if (this.CurrentToken.Kind == SyntaxKind.SemicolonToken)
                {
                    break;
                }
                else if (this.CurrentToken.Kind == SyntaxKind.CommaToken)
                {
                    variables.AddSeparator(this.EatToken(SyntaxKind.CommaToken));
                    variables.Add(this.ParseVariableDeclarator(type, flags, isFirst: false));
                }
                else if (!variableDeclarationsExpected || this.SkipBadVariableListTokens(variables, SyntaxKind.CommaToken) == PostSkipAction.Abort)
                {
                    break;
                }
            }
        }
Exemple #30
0
        ///////////////////////////////////////////////////////////////////////

        private Variable(
            ICallFrame frame,
            string name,
            VariableFlags flags,
            string qualifiedName,
            object value,
            EventWaitHandle @event
            )
        {
            this.kind          = IdentifierKind.Variable;
            this.id            = Guid.Empty;
            this.name          = name;
            this.frame         = frame;
            this.flags         = flags & ~VariableFlags.NonInstanceMask;
            this.qualifiedName = qualifiedName;
            this.link          = null;
            this.linkIndex     = null;
            this.value         = value;
            this.arrayValue    = null; // TODO: For arrays, create this?
            this.traces        = null;
            this.@event        = @event;
        }
Exemple #31
0
        ///////////////////////////////////////////////////////////////////////

        internal TraceInfo(
            ITrace trace,
            BreakpointType breakpointType,
            ICallFrame frame,
            IVariable variable,
            string name,
            string index,
            VariableFlags flags,
            object oldValue,
            object newValue,
            ElementDictionary oldValues,
            ElementDictionary newValues,
            StringList list,
            bool cancel,
            bool postProcess,
            ReturnCode returnCode
            )
        {
            Update(
                trace, breakpointType, frame, variable, name, index, flags,
                oldValue, newValue, oldValues, newValues, list, cancel,
                postProcess, returnCode);
        }