Exemplo n.º 1
0
 /// <summary>
 /// 创建字段信息
 /// </summary>
 private void buildFields()
 {
     foreach (FieldInfo field in baseType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
     {
         if ((fieldType = field.FieldType).IsPrimitive || fieldType.IsPointer || fieldType.IsEnum)
         {
             type.Type.Size += getMemorySize(fieldType);
         }
         else if (fieldType.IsValueType)
         {
             valueType = buildValueType(fieldType);
             if (valueType.Fields == null)
             {
                 type.Type.Size += valueType.Type.Size;
             }
             else
             {
                 type.Add(field);
             }
         }
         else
         {
             type.Add(field);
             if (!fieldType.IsValueType)
             {
                 type.Type.Size = fastCSharp.pub.MemoryBytes;
             }
         }
     }
 }
Exemplo n.º 2
0
 public Named(typeInfo info = default, ref ptr <TypeName> obj = default, Type orig = default, Type underlying = default, slice <ptr <Func> > methods = default)
 {
     this.info       = info;
     this.obj        = obj;
     this.orig       = orig;
     this.underlying = underlying;
     this.methods    = methods;
 }
Exemplo n.º 3
0
        // 立即提交
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   typ_name    = TextBox1.Text.Trim();
            string   description = Request.Form["description"];
            typeInfo typ         = new typeInfo();

            typ.name        = typ_name;
            typ.description = description;
            db.typeInfo.Add(typ);
            db.SaveChanges();
            Response.Write("<script>alert('成功添加一条记录!')</script>");
        }
Exemplo n.º 4
0
            /// <summary>
            /// 创建值类型
            /// </summary>
            /// <param name="type"></param>
            private typeInfo buildValueType(Type type)
            {
                typeInfo valueType;

                if (!types.TryGetValue(type, out valueType))
                {
                    valueType = new typeInfo {
                        Type = new type {
                            FullName = type.fullName()
                        }
                    };
                    foreach (FieldInfo field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))
                    {
                        if ((fieldType = field.FieldType).IsPrimitive || fieldType.IsPointer || fieldType.IsEnum)
                        {
                            valueType.Type.Size += getMemorySize(fieldType);
                        }
                        else if (fieldType.IsValueType)
                        {
                            valueType = buildValueType(fieldType);
                            if (valueType.Fields == null)
                            {
                                valueType.Type.Size += valueType.Type.Size;
                            }
                            else
                            {
                                valueType.Add(field);
                            }
                        }
                        else
                        {
                            valueType.Add(field);
                            if (!fieldType.IsValueType)
                            {
                                valueType.Type.Size = fastCSharp.pub.MemoryBytes;
                            }
                        }
                    }
                }
                return(valueType);
            }
Exemplo n.º 5
0
    static ArrayList addOpts(ArrayList prods, Hashtable nts)
    {
        ArrayList L = new ArrayList();

        foreach (production p in prods)
        {
            L.Add(p);
        }
        foreach (production p in prods)
        {
            foreach (string s in p.rule)
            {
                if (s.EndsWith("opt") && !nts.Contains(s))
                {
                    string     basename = s.Substring(0, s.LastIndexOf("opt"));
                    production q;
                    string     ty;
                    if (nts.Contains(basename))
                    {
                        ty = ((typeInfo)nts[basename]).ty;
                        string action = ((typeInfo)nts[basename]).action;
                        q = new production(s, new string[] {}, ty, action);
                        L.Add(q);
                        q = new production(s, new string[] { basename }, ty, "a1");
                        L.Add(q);
                        nts[s] = new typeInfo(ty, "");
                    }
                    else
                    {
                        ty = "InputElement";
                        q  = new production(s, new string[] {}, ty, "null");
                        L.Add(q);
                        q = new production(s, new string[] { basename }, ty, "a1");
                        L.Add(q);
                    }
                    nts[s] = new typeInfo(ty, "");
                }
            }
        }
        return(L);
    }
Exemplo n.º 6
0
 static Hashtable processTypes(Excel.Workbook wb, Hashtable T)
 {
     foreach (Excel.Worksheet ws in wb.Sheets)
     {
         if (ws.Name.EndsWith("types"))
         {
             Excel.Range nonterms = ws.get_Range("types_Nonterminal", missing);
             Excel.Range types    = ws.get_Range("types_type", missing);
             Excel.Range actions  = ws.get_Range("types_Default_Action", missing);
             for (int i = 1; i <= ws.UsedRange.Rows.Count; i++)
             {
                 string nt     = item(nonterms, i);
                 string ty     = item(types, i);
                 string action = item(actions, i);
                 if (nt != "")
                 {
                     T[nt] = new typeInfo(ty, action);
                 }
             }
         }
     }
     return(T);
 }
Exemplo n.º 7
0
            /// <summary>
            /// 创建数组
            /// </summary>
            /// <typeparam name="valueType"></typeparam>
            private void buildArray <valueType>()
            {
                if (!arrayType.IsInterface && !types.TryGetValue(arrayType, out type))
                {
                    types.Add(currentType = arrayType, type = new typeInfo {
                        Type = new type()
                    });
                    buildType();
                }
                value[] values = this.value.Values = new value[((valueType[])this.currentValue).Length];
                int     index  = 0;

                if (arrayType == typeof(string))
                {
                    foreach (string value in (string[])this.currentValue)
                    {
                        if (!string.IsNullOrEmpty(value))
                        {
                            values[index] = new value {
                                Type = new type {
                                    FullName = type.Type.FullName, Size = value.Length
                                }
                            };
                        }
                        ++index;
                    }
                }
                else if (depth < maxDepth)
                {
                    if (arrayType.IsClass || arrayType.IsInterface)
                    {
                        foreach (valueType value in (valueType[])this.currentValue)
                        {
                            if (value != null)
                            {
                                currentType = value.GetType();
                                if (currentType.IsClass || currentType.IsInterface)
                                {
                                    if (!this.values.TryGetValue(new objectReference {
                                        Value = value
                                    }, out values[index]))
                                    {
                                        this.values.Add(new objectReference {
                                            Value = this.currentValue = value
                                        }, values[index] = this.value = new value());
                                        buildValue();
                                    }
                                }
                                else
                                {
                                    this.currentValue = value;
                                    values[index]     = this.value = new value();
                                    buildValue();
                                }
                            }
                            ++index;
                        }
                    }
                    else
                    {
                        foreach (valueType value in (valueType[])this.currentValue)
                        {
                            this.currentValue = value;
                            currentType       = typeof(valueType);
                            values[index++]   = this.value = new value();
                            buildValue();
                        }
                    }
                }
            }
Exemplo n.º 8
0
 /// <summary>
 /// 创建对象值
 /// </summary>
 private void buildValue()
 {
     ++depth;
     if (!types.TryGetValue(currentType, out type))
     {
         types.Add(currentType, type = new typeInfo {
             Type = new type()
         });
         buildType();
     }
     this.value.Type = type.Type;
     if (type.Fields == null)
     {
         if (currentType == typeof(string))
         {
             this.value.Type = new type {
                 FullName = type.Type.FullName, Size = ((string)this.currentValue).Length
             };
         }
         else if (currentType.IsArray)
         {
             arrayType = currentType.GetElementType();
             if (arrayType.IsPrimitive || arrayType.IsPointer || arrayType.IsEnum)
             {
                 this.value.Type = new type {
                     FullName = this.value.Type.FullName, Size = ((Array)this.currentValue).Length
                 };
             }
             else
             {
                 if (!arrayBuilders.TryGetValue(arrayType, out arrayBuilder))
                 {
                     arrayBuilders.Add(arrayType, arrayBuilder = (Action)Delegate.CreateDelegate(typeof(Action), this, buildArrayMethod.MakeGenericMethod(arrayType)));
                 }
                 arrayBuilder();
             }
         }
     }
     else if (depth < maxDepth)
     {
         object currentValue = this.currentValue;
         value  value = this.value;
         int    count = type.Fields.Count, index = count;
         foreach (FieldInfo field in type.Fields.UnsafeArray)
         {
             if ((this.currentValue = field.GetValue(currentValue)) != null)
             {
                 if (value.Values == null)
                 {
                     value.Values = new value[count];
                 }
                 currentType = this.currentValue.GetType();
                 if (currentType.IsClass || currentType.IsInterface)
                 {
                     if (!values.TryGetValue(new objectReference {
                         Value = this.currentValue
                     }, out value.Values[count - index]))
                     {
                         values.Add(new objectReference {
                             Value = this.currentValue
                         }, value.Values[count - index] = this.value = new value());
                         buildValue();
                     }
                 }
                 else
                 {
                     value.Values[count - index] = this.value = new value();
                     buildValue();
                 }
             }
             if (--index == 0)
             {
                 break;
             }
         }
     }
     --depth;
 }