示例#1
0
        /// <summary>
        /// Add at runtime a constant to a type
        /// </summary>
        /// <param name="typedesc">Type to modify</param>
        /// <param name="attributes">New const attributes</param>
        /// <param name="const_name">Const name</param>
        /// <param name="value">Const value</param>
        /// <remarks>Used by PDO_MYSQL</remarks>
        public void AddConstantToType(DTypeDesc typedesc, PhpMemberAttributes attributes, string const_name, object value)
        {
            Debug.Assert(typedesc != null);

            VariableName  name       = new VariableName(const_name);
            DConstantDesc const_desc = new DConstantDesc(typedesc, attributes, value);

            if (!typedesc.Constants.ContainsKey(name))
            {
                typedesc.Constants.Add(name, const_desc);
            }
        }
示例#2
0
        /// <summary>
        /// Returns 'FieldInfo' representing field in AutoGlobals for given global variable name.
        /// </summary>
        internal static FieldInfo GetFieldForVariable(VariableName name)
        {
            switch (name.ToString())
            {
            case AutoGlobals.GlobalsName:
                return(Fields.AutoGlobals.Globals);

            case AutoGlobals.CanvasName:
                return(Fields.AutoGlobals.Canvas);

            case AutoGlobals.AddrName:
                return(Fields.AutoGlobals.Addr);

            default:
                return(null);
            }
        }
示例#3
0
        public void Set(VariableName varName, bool isPhpReference)
        {
            Entry entry;

            if (variables.TryGetValue(varName, out entry))
            {
                entry.IsDirectlyUsed = true;

                if (allRef || isPhpReference)
                {
                    entry.IsPhpReference = true;
                }
            }
            else if (!varName.IsAutoGlobal)
            {
                variables.Add(varName, new Entry(varName, allRef || isPhpReference));
            }
        }
示例#4
0
        public bool AddParameter(VariableName paramName, bool isPassedByRef)
        {
            Entry entry;

            if (variables.TryGetValue(paramName, out entry))
            {
                // parameter with the same name specified twice
                if (entry.IsParameter)
                {
                    //return false;
                }
                else
                {
                    Debug.Fail(null);
                    return(true);
                }
            }

            // add variable entry
            variables[paramName] = new Entry(paramName, isPassedByRef, true);               // parameter can be specified twice in PHP, the last one is used
            return(true);
        }
示例#5
0
        /// <summary>
        /// Returns 'FieldInfo' representing field in AutoGlobals for given global variable name.
        /// </summary>
        internal static FieldInfo GetFieldForVariable(VariableName name)
        {
            switch (name.ToString())
            {
            case AutoGlobals.CookieName:
                return(Fields.AutoGlobals.Cookie);

            case AutoGlobals.EnvName:
                return(Fields.AutoGlobals.Env);

            case AutoGlobals.FilesName:
                return(Fields.AutoGlobals.Files);

            case AutoGlobals.GetName:
                return(Fields.AutoGlobals.Get);

            case AutoGlobals.GlobalsName:
                return(Fields.AutoGlobals.Globals);

            case AutoGlobals.PostName:
                return(Fields.AutoGlobals.Post);

            case AutoGlobals.RequestName:
                return(Fields.AutoGlobals.Request);

            case AutoGlobals.ServerName:
                return(Fields.AutoGlobals.Server);

            case AutoGlobals.SessionName:
                return(Fields.AutoGlobals.Session);

            case AutoGlobals.HttpRawPostDataName:
                return(Fields.AutoGlobals.HttpRawPostData);

            default:
                return(null);
            }
        }
示例#6
0
 public Entry(VariableName varName, bool isPhpReference)
     : this(varName, isPhpReference, false)
 {
 }
示例#7
0
 public bool Contains(VariableName name)
 {
     return(variables.ContainsKey(name));
 }
示例#8
0
 public Entry this[VariableName name]
 {
     get { return(variables[name]); }
 }