Example #1
0
        public Constant GetOrAddConstant(Chunk chunk, ConstantType type, dynamic constant, out int constantIndex)
        {
            var current =
                chunk.Constants.FirstOrDefault(c => c.Type == type &&
                                               c.Data == constant);                      // type checking to prevent errors i guess

            if (current != null)
            {
                constantIndex = chunk.Constants.IndexOf(current);
                return(current);
            }

            Constant newConst = new Constant
            {
                Type = type,
                Data = constant
            };


            constantIndex = chunk.Constants.Count;

            chunk.Constants.Add(newConst);
            chunk.ConstantMap.Add(newConst, constantIndex);

            return(newConst);
        }
Example #2
0
            public ConstantHKS(LuaFile file, BinaryReaderEx br)
            {
                byte type = br.ReadByte();

                if (type == 0)
                {
                    Type = ConstantType.TypeNil;
                }
                else if (type == 1)
                {
                    Type      = ConstantType.TypeBoolean;
                    BoolValue = br.ReadBoolean();
                }
                else if (type == 3)
                {
                    NumberValue = br.ReadSingle();
                    Type        = ConstantType.TypeNumber;
                }
                else if (type == 4)
                {
                    StringValue = LuaFile.ReadLuaString(br, LuaVersion.Lua51HKS);
                    Type        = ConstantType.TypeString;
                }
                else
                {
                    throw new Exception("Unimplemented HKS type");
                }
            }
Example #3
0
 private void UpdateType(ConstantType type)
 {
     if (type > this.type)
     {
         this.type = type;
     }
 }
Example #4
0
        private static string GetConstantTypeName(ConstantType type)
        {
            switch (type.ParameterClass)
            {
            case ParameterClass.Scalar:
                return(type.ParameterType.GetDescription());

            case ParameterClass.Vector:
                return(type.ParameterType.GetDescription() + type.Columns);

            case ParameterClass.Struct:
                return("struct");

            case ParameterClass.MatrixColumns:
                return($"column_major {type.ParameterType.GetDescription()}{type.Rows}x{type.Columns}");

            case ParameterClass.MatrixRows:
                return($"row_major {type.ParameterType.GetDescription()}{type.Rows}x{type.Columns}");

            case ParameterClass.Object:
                switch (type.ParameterType)
                {
                case ParameterType.Sampler1D:
                case ParameterType.Sampler2D:
                case ParameterType.Sampler3D:
                case ParameterType.SamplerCube:
                    return("sampler");

                default:
                    throw new NotImplementedException();
                }
            }
            throw new NotImplementedException();
        }
Example #5
0
        private void Write(ConstantType type, string name, bool isStructMember = false)
        {
            string typeName = GetConstantTypeName(type);

            WriteIndent();
            Write("{0}", typeName);
            if (type.ParameterClass == ParameterClass.Struct)
            {
                WriteLine("");
                WriteLine("{");
                Indent++;
                foreach (var member in type.Members)
                {
                    Write(member.Type, member.Name, true);
                }
                Indent--;
                WriteIndent();
                Write("}");
            }
            Write(" {0}", name);
            if (type.Elements > 1)
            {
                Write("[{0}]", type.Elements);
            }
            if (isStructMember)
            {
                Write(";\n");
            }
        }
Example #6
0
        public ASNamespace(ASConstants constants, int nameIndex, ConstantType kind)
        {
            _constants = constants;
            NameIndex = nameIndex;

            NamespaceType = kind;
        }
Example #7
0
        string GetConstantString(ConstantType constant)
        {
            string retVal = "Unknown Value";

            if (constant.HasBoolean())
            {
                if ((bool)constant.GetBoolean().Value)
                {
                    retVal = "true";
                }
                else
                {
                    retVal = "false";
                }
            }
            else if (constant.HasFloat2())
            {
                retVal = constant.GetFloat2().ToString();
            }
            else if (constant.HasInteger())
            {
                retVal = constant.GetInteger().Value.ToString();
            }
            else if (constant.HasString2())
            {
                retVal = (string)constant.GetString2().Value;
            }

            return(retVal);
        }
Example #8
0
        static public ConstantType GetConstantFromValue(VariableType type, object value)
        {
            if (value == null)
            {
                Debug.LogError("Error null value in GetConstantFromValue");
                return(null);
            }

            ConstantType constantType = new ConstantType();

            switch (type)
            {
            case VariableType.BOOLEAN:
                constantType.AddBoolean(new SchemaBoolean((bool)value));
                break;

            case VariableType.FLOAT:
                constantType.AddFloat2(new SchemaDecimal((decimal)(float)value));
                break;

            case VariableType.INT:
                constantType.AddInteger(new SchemaLong((long)(int)value));
                break;

            case VariableType.STRING:
                constantType.AddString2(new SchemaString((string)value));
                break;
            }

            return(constantType);
        }
Example #9
0
 public Task <Tuple <bool, ConstantType, string> > SaveConstantType(ConstantType constantType)
 {
     return(Task.Run(() => {
         var msg = "";
         var succ = true;
         var entity = chargeContext.constantTypes.AsNoTracking().Where(p => p.ID.Equals(constantType.ID)).FirstOrDefault();
         if (entity != null)
         {
             chargeContext.constantTypes.Update(constantType);
         }
         else
         {
             var entity1 = chargeContext.constantTypes.AsNoTracking().Where(p => p.TypeCode.Equals(constantType.TypeCode) ||
                                                                            p.TypeName.Equals(constantType.TypeName)).FirstOrDefault();
             if (entity1 == null)
             {
                 chargeContext.constantTypes.Add(constantType);
             }
             else
             {
                 succ = false;
                 msg = "类型名称/代号已存在";
             }
         }
         chargeContext.SaveChanges();
         return new Tuple <bool, ConstantType, string>(succ, constantType, msg);
     }));
 }
Example #10
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgv.CurrentRow == null || dgv.CurrentRow.Index < 0)
                {
                    FrmTips.ShowTipsError(AppHelper.MainForm, "未选中任何行!", ContentAlignment.MiddleCenter, 1000);
                    return;
                }
                ConstantType entity = CGridHelper.GetCurrentData <ConstantType>(dgv);

                ConstantApi constantApi = new ConstantApi();
                var         resp        = constantApi.DeleteConstantType(entity.ID);
                //string sql = "DELETE ConstantType WHERE ID = @ID";
                //Hashtable hashtable = new Hashtable();
                //hashtable.Add("ID", entity.ID);
                //if (_mssqlHelper.ExcuteNonQuery(sql, hashtable) > 0)
                //{
                if (resp.Code == 1)
                {
                    FrmTips.ShowTipsSuccess(AppHelper.MainForm, "删除成功!", ContentAlignment.MiddleCenter, 1000);
                    CGridHelper.DeleteRow(dgv);
                }
                else
                {
                    FrmTips.ShowTipsError(AppHelper.MainForm, "删除失败!" + resp.Message, ContentAlignment.MiddleCenter, 1000);
                }
            }
            catch (Exception ex)
            {
                FrmTips.ShowTipsError(AppHelper.MainForm, "删除异常!" + ex.Message, ContentAlignment.MiddleCenter, 3000);
            }
        }
Example #11
0
        public Value MakeConstant(AiRuleEngine.VariableType type, object value)
        {
            Value        newValue    = new Value();
            ConstantType newConstant = new ConstantType();

            switch (type)
            {
            case AiRuleEngine.VariableType.BOOLEAN:
                newConstant.AddBoolean(new Altova.Types.SchemaBoolean((bool)value));
                break;

            case AiRuleEngine.VariableType.INT:
                newConstant.AddInteger(new Altova.Types.SchemaLong((long)(int)value));
                break;

            case AiRuleEngine.VariableType.FLOAT:
                newConstant.AddFloat2(new Altova.Types.SchemaDecimal((decimal)(float)value));
                break;

            case AiRuleEngine.VariableType.STRING:
                newConstant.AddString2(new Altova.Types.SchemaString((string)value));
                break;
            }

            newValue.AddConstant(newConstant);

            return(newValue);
        }
Example #12
0
 internal NamedConstant(string name, string description, ConstantType type, object value)
 {
     Name        = name;
     Description = description;
     Type        = type;
     Value       = value;
 }
Example #13
0
            public Tuple <DataType, NodeStructure> Type(
                string name, ConstantType constantType, params dynamic[] constantParams
                )
            {
                DataType type = new DataType {
                    Name = name
                };

                registry.Registry.RegisterDataType(type);
                NodeStructure structure = null;

                if (constantType != ConstantType.None)
                {
                    structure = new NodeStructure {
                        Name           = name + "Constant",
                        ConstantType   = constantType,
                        ConstantParams = constantParams.Cast <string>().ToList(),
                        Inputs         = new List <Variable>(),
                        Outputs        = new List <Variable> {
                            new Variable(type, "value")
                        }
                    };
                    registry.Registry.RegisterNodeStructure(structure);
                }
                return(new Tuple <DataType, NodeStructure>(type, structure));
            }
Example #14
0
        public object GetValue(ConstantType type, int index)
        {
            switch (type)
            {
            case ConstantType.Null:
            case ConstantType.Undefined: return(null);

            case ConstantType.True: return(true);

            case ConstantType.False: return(false);

            case ConstantType.String: return(_strings[index]);

            case ConstantType.Double: return(_doubles[index]);

            case ConstantType.Integer: return(_integers[index]);

            case ConstantType.UInteger: return(_uintegers[index]);

            case ConstantType.Namespace:
            case ConstantType.PrivateNamespace:
            case ConstantType.PackageNamespace:
            case ConstantType.ExplicitNamespace:
            case ConstantType.ProtectedNamespace:
            case ConstantType.PackageInternalNamespace:
            case ConstantType.StaticProtectedNamespace: return(_namespaces[index]);

            default: throw new Exception("Invalid constant: " + type);
            }
        }
Example #15
0
 public QName(ASConstants constants, int nameIndex, int namespaceIndex, ConstantType multinameType)
 {
     _constants = constants;
     MultinameType = multinameType;
     NameIndex = nameIndex;
     NamespaceIndex = namespaceIndex;
 }
Example #16
0
        public override void OnNodeGUI()
        {
            GUILayout.Space(EditorGUIUtility.singleLineHeight);

            EditorGUI.BeginChangeCheck();
            EditorGUIUtility.labelWidth = 80;
            selectedConstantType        = (ConstantType)EditorGUILayout.EnumPopup("output mode", selectedConstantType);
            if (EditorGUI.EndChangeCheck())
            {
                UpdateConstantType();
            }

            switch (selectedConstantType)
            {
            case ConstantType.Int:
                outi = EditorGUILayout.IntField("Int", outi);
                break;

            case ConstantType.Float:
                outf = EditorGUILayout.FloatField("Float", outf);
                break;

            case ConstantType.Vector2:
                outv2 = EditorGUILayout.Vector2Field("Vec2", outv2);
                break;

            case ConstantType.Vector3:
                outv3 = EditorGUILayout.Vector3Field("Vec3", outv3);
                break;

            case ConstantType.Vector4:
                outv4 = EditorGUILayout.Vector4Field("Vec4", outv4);
                break;
            }
        }
Example #17
0
 public ConstantToken(string name, T realValue, ConstantType type, TokenPosition position)
     : base(position)
 {
     Name         = name;
     ConstantType = type;
     Value        = realValue;
 }
Example #18
0
 public QName(ASConstants constants, FlashReader reader, ConstantType multinameType)
 {
     _constants = constants;
     MultinameType = multinameType;
     NamespaceIndex = reader.Read7BitEncodedInt();
     NameIndex = reader.Read7BitEncodedInt();
 }
Example #19
0
        public ASNamespace(ASConstants constants, FlashReader reader)
        {
            _constants = constants;

            NamespaceType = (ConstantType)reader.ReadByte();
            NameIndex = reader.Read7BitEncodedInt();
        }
Example #20
0
        private Constant(Token codeToken, NmProgram program, ConstantType type, string literal)
        {
            Type      = type;
            Program   = program;
            CodeToken = codeToken;
            Literal   = literal;

            program.Constants.Add(this);
        }
Example #21
0
 public RTQName(ABCFile abc, ConstantType multinameType)
 {
     if (multinameType == ConstantType.RTQName ||
         multinameType == ConstantType.RTQNameA)
     {
         ABC = abc;
         MultinameType = multinameType;
     }
     else throw new Exception($"Invalid {nameof(RTQName)} type: " + multinameType);
 }
Example #22
0
 public MultinameL(ABCFile abc, ConstantType multinameType)
 {
     if (multinameType == ConstantType.MultinameL ||
         multinameType == ConstantType.MultinameLA)
     {
         ABC = abc;
         MultinameType = multinameType;
     }
     else throw new Exception($"Invalid {nameof(MultinameL)} type: " + multinameType);
 }
Example #23
0
 internal ExpressionContext(ExpressionType expressionType, ConstantType constantType, LocationFlags location, ObjectType objectType, string objectName, string propertyName, string dataSetName, bool parseExtended)
 {
     m_expressionType = expressionType;
     m_constantType   = constantType;
     m_location       = location;
     m_objectType     = objectType;
     m_objectName     = objectName;
     m_propertyName   = propertyName;
     m_dataSetName    = dataSetName;
     m_parseExtended  = parseExtended;
 }
Example #24
0
        void EvaluateAssignmentExpression(AssignmentExpression exp)
        {
            ConstantType val = EvaluateArithmeticExpression(exp.GetExpression());

            Variable variable;

            if (m_Context.GetState().GetVariable(exp.GetVariable().GetName().Value, out variable))
            {
                variable.SetValue(Variable.GetValueFromConstant(variable.GetVariableType(), val));
            }
        }
Example #25
0
 public ConstantBufferPropertyField(String name, ConstantType type, int offset)
 {
     this.type     = type;
     this.name     = name;
     byteOffset    = offset;
     isParam       = false;
     isScripted    = false;
     isGamma       = false;
     paramValue    = null;
     paramRangeMin = -Single.MaxValue;
     paramRangeMax = Single.MaxValue;
 }
Example #26
0
 public MultinameL(ABCFile abc, ConstantType multinameType)
 {
     if (multinameType == ConstantType.MultinameL ||
         multinameType == ConstantType.MultinameLA)
     {
         ABC           = abc;
         MultinameType = multinameType;
     }
     else
     {
         throw new Exception($"Invalid {nameof(MultinameL)} type: " + multinameType);
     }
 }
Example #27
0
 public Constant(ConstantType _constantType) : base()
 {
     constantType = _constantType;
     if (constantType == ConstantType.logarithmic)
     {
         value = 1.0;
     }
     else
     {
         value = 0;
     }
     init();
 }
Example #28
0
 public RTQName(ABCFile abc, ConstantType multinameType)
 {
     if (multinameType == ConstantType.RTQName ||
         multinameType == ConstantType.RTQNameA)
     {
         ABC           = abc;
         MultinameType = multinameType;
     }
     else
     {
         throw new Exception($"Invalid {nameof(RTQName)} type: " + multinameType);
     }
 }
Example #29
0
        float GetFloatOrIntValue(ConstantType constant)
        {
            if (GetConstantType(constant) == VariableType.FLOAT)
            {
                return((float)constant.GetFloat2().Value);
            }
            else if (GetConstantType(constant) == VariableType.INT)
            {
                return(constant.GetInteger().Value);
            }

            return(0);
        }
Example #30
0
 public Task <ResponseModel> SaveConstantType(ConstantType constantType)
 {
     return(Task.Run(async() =>
     {
         ResponseModel response = new ResponseModel();
         var type = await m_constantService.SaveConstantType(constantType);
         response.Code = type.Item1 ? 1 : 0;
         response.Message = type.Item3;
         response.Data = type.Item2;
         response.DataCount = 1;
         return response;
     }));
 }
Example #31
0
		public object Create(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options, out object resultNoSpecialNull, out bool canceled) {
			var data = new ConstantTypeVM(ownerModule, value, validConstants ?? DefaultConstants, true, true, options);
			var win = new ConstantTypeDlg();
			win.DataContext = data;
			win.Owner = ownerWindow ?? Application.Current.MainWindow;
			if (win.ShowDialog() != true) {
				canceled = true;
				resultNoSpecialNull = null;
				return null;
			}

			canceled = false;
			resultNoSpecialNull = data.ValueNoSpecialNull;
			return data.Value;
		}
Example #32
0
 public static int GetByteSizeOfType(ConstantType type)
 {
     switch (type)
     {
         case ConstantType.ConstantType_Float:
             return 4;
         case ConstantType.ConstantType_Int:
             return 4;
         case ConstantType.ConstantType_Float4:
             return 4*4;
         case ConstantType.ConstantType_Matrix44:
             return 4*4*4;
         default:
             throw new Exception("GetByteSizeOfType: unknown type!");
     }
 }
Example #33
0
 public static object GetDefaultObjectForType(ConstantType type)
 {
     switch(type)
     {
         case ConstantType.ConstantType_Float:
             return new Single();
         case ConstantType.ConstantType_Int:
             return new Int32();
         case ConstantType.ConstantType_Float4:
             return new Vector4();
         case ConstantType.ConstantType_Matrix44:
             return new Matrix();
         default:
             throw new Exception("GetDefaultObjectForType: unknown type!");
     }
 }
Example #34
0
        public static object GetDefaultObjectForType(ConstantType type)
        {
            switch (type)
            {
            case ConstantType.ConstantType_Float:
                return(new Single());

            case ConstantType.ConstantType_Float4:
                return(new Vector4());

            case ConstantType.ConstantType_Matrix44:
                return(new Matrix());

            default:
                throw new Exception("GetDefaultObjectForType: unknown type!");
            }
        }
Example #35
0
        public static int GetByteSizeOfType(ConstantType type)
        {
            switch (type)
            {
            case ConstantType.ConstantType_Float:
                return(4);

            case ConstantType.ConstantType_Float4:
                return(4 * 4);

            case ConstantType.ConstantType_Matrix44:
                return(4 * 4 * 4);

            default:
                throw new Exception("GetByteSizeOfType: unknown type!");
            }
        }
Example #36
0
        public static string ToCSharp(this ConstantType type)
        {
            switch (type)
            {
            case ConstantType.UInt32:
                return("uint");

            case ConstantType.UInt64:
                return("ulong");

            case ConstantType.Float32:
                return("float");

            default:
                throw new InvalidOperationException("Invalid value");
            }
        }
Example #37
0
        ConstantType EvaluateArithmeticExpression(ArithmeticExpression exp)
        {
            ConstantType retVal;

            if (exp.HasSubExpression())
            {
                retVal = EvalSubExpression(exp.GetSubExpression());
            }
            else
            {
                if (exp.GetValue().HasConstant())
                {
                    retVal = exp.GetValue().GetConstant();
                }
                else
                {
                    Variable currVar;
                    string   currName = exp.GetValue().GetVariable().GetName().Value;
                    retVal = new ConstantType();

                    if (m_Context.GetState().GetVariable(currName, out currVar))
                    {
                        if (currVar.GetVariableType() == VariableType.BOOLEAN)
                        {
                            retVal.AddBoolean(new SchemaBoolean((bool)currVar.GetValue()));
                        }
                        else if (currVar.GetVariableType() == VariableType.INT)
                        {
                            retVal.AddInteger(new SchemaLong((int)currVar.GetValue()));
                        }
                        else if (currVar.GetVariableType() == VariableType.FLOAT)
                        {
                            retVal.AddFloat2(new SchemaDecimal((decimal)(float)currVar.GetValue()));
                        }
                        else if (currVar.GetVariableType() == VariableType.STRING)
                        {
                            string value = (string)currVar.GetValue();
                            retVal.AddString2(new SchemaString(value));
                        }
                    }
                }
            }

            return(retVal);
        }
Example #38
0
 VariableType GetConstantType(ConstantType constant)
 {
     if (constant.HasBoolean())
     {
         return(VariableType.BOOLEAN);
     }
     else if (constant.HasFloat2())
     {
         return(VariableType.FLOAT);
     }
     else if (constant.HasInteger())
     {
         return(VariableType.INT);
     }
     else
     {
         return(VariableType.STRING);
     }
 }
Example #39
0
        public static bool IsValidMultiname(ConstantType multinameType)
        {
            switch (multinameType)
            {
                default: return false;

                case ConstantType.QName:
                case ConstantType.QNameA:
                case ConstantType.RTQName:
                case ConstantType.RTQNameA:
                case ConstantType.RTQNameL:
                case ConstantType.RTQNameLA:
                case ConstantType.Multiname:
                case ConstantType.MultinameA:
                case ConstantType.MultinameL:
                case ConstantType.MultinameLA:
                case ConstantType.Typename: return true;
            }
        }
Example #40
0
        static public ConstantType GetConstantFromValue(object value)
        {
            if (value == null)
            {
                Debug.LogError("Error null value in GetConstantFromValue");
                return(null);
            }

            ConstantType constantType = new ConstantType();

            if (value.GetType() == typeof(bool))
            {
                constantType.AddBoolean(new SchemaBoolean((bool)value));
            }
            else if (value.GetType() == typeof(float))
            {
                constantType.AddFloat2(new SchemaDecimal((decimal)(float)value));
            }
            else if (value.GetType() == typeof(int))
            {
                long longValue = (long)(int)value;
                constantType.AddInteger(new SchemaLong(longValue));
            }
            else if (value.GetType() == typeof(string))
            {
                constantType.AddString2(new SchemaString((string)value));
            }
            else
            {
                string objectString;

                if (ObjectToString(value, out objectString))
                {
                    constantType.AddString2(new SchemaString(objectString));
                }
                else
                {
                    constantType.AddString2(new SchemaString(value.GetType().ToString()));
                }
            }

            return(constantType);
        }
        /// <summary>
        /// Gets constant display text.
        /// </summary>
        /// <param name="constantType">
        /// The constant type.
        /// </param>
        /// <param name="isTooltip">
        /// determines whether to return the tooltip text.
        /// </param>
        /// <returns>
        /// The display text.
        /// </returns>
        public static string GetConstantDisplayText(ConstantType constantType, bool isTooltip)
        {
            switch (constantType)
            {
                //case ConstantType.Null:
                //    return isTooltip ? "Literal" : "Empty";
                case ConstantType.NewLine:
                    return isTooltip ? "Literal Text" : "New Line";
                case ConstantType.True:
                    return isTooltip ? "Literal Logical" : "True";
                case ConstantType.False:
                    return isTooltip ? "Literal Logical" : "False";
                case ConstantType.Comma:
                    return isTooltip ? "Comma (not a literal)" : " , ";
                case ConstantType.EmptyString:
                    return isTooltip ? "Literal" : "Empty string";
            }

            return "Unknown";
        }
 public static ExpressionBase New(ConstantType type)
 {
     return new ConstantExpression(type);
 }
Example #43
0
 /// <summary>
 /// Initializes a new instance of <see cref="Constant"/> AST node.
 /// </summary>
 /// <param name="value">The value of the constant.</param>
 /// <param name="type">The type of the constant.</param>
 public Constant(string value, ConstantType type)
 {
     this.value = value;
     this.type = type;
 }
Example #44
0
 public static Token Constant(ConstantType type)
 {
     return new Token(TokenType.Constant, type);
 }
Example #45
0
 public ConstantBufferPropertyField(String name, ConstantType type, int offset)
 {
     this.type = type;
     this.name = name;
     byteOffset = offset;
     isParam = false;
     isScripted = false;
     isGamma = false;
     paramValue = null;
     paramRangeMin = -Single.MaxValue;
     paramRangeMax = Single.MaxValue;
 }
Example #46
0
 public QName(ASConstants constants, ConstantType multinameType) :
     this(constants, 0, 0, multinameType)
 { }
Example #47
0
 public MultinameL(ASConstants constants, ConstantType multinameType) :
     this(constants, 0, multinameType)
 { }
Example #48
0
		void SetSelectedItem(ConstantType ct) {
			if (ConstantTypeEnumList.Has(ct))
				ConstantTypeEnumList.SelectedItem = ct;
			else
				ConstantTypeEnumList.SelectedIndex = 0;
		}
Example #49
0
 public Constant(ConstantType t, object val)
 {
     Type = t;
     Value = val;
 }
 public ConstantExpression(ConstantType type)
 {
     Type = type;
 }
Example #51
0
 public RTQNameL(ConstantType multinameType)
 {
     MultinameType = multinameType;
 }
Example #52
0
 public MultinameL(ABCFile abc, FlashReader reader, ConstantType multinameType)
     : this(abc, multinameType)
 {
     NamespaceSetIndex = reader.Read7BitEncodedInt();
 }
Example #53
0
 public MultinameL(ASConstants constants, int namespaceSetIndex, ConstantType multinameType)
 {
     _constants = constants;
     MultinameType = multinameType;
     NamespaceSetIndex = namespaceSetIndex;
 }
Example #54
0
 public RTQName(ABCFile abc, FlashReader reader, ConstantType multinameType)
     : this(abc, multinameType)
 {
     ObjNameIndex = reader.Read7BitEncodedInt();
 }
Example #55
0
		TypeSig GetType(ConstantType ct) {
			switch (ct) {
			case ConstantType.Object:	return ownerModule.CorLibTypes.Object;
			case ConstantType.Boolean:	return ownerModule.CorLibTypes.Boolean;
			case ConstantType.Char:		return ownerModule.CorLibTypes.Char;
			case ConstantType.SByte:	return ownerModule.CorLibTypes.SByte;
			case ConstantType.Byte:		return ownerModule.CorLibTypes.Byte;
			case ConstantType.Int16:	return ownerModule.CorLibTypes.Int16;
			case ConstantType.UInt16:	return ownerModule.CorLibTypes.UInt16;
			case ConstantType.Int32:	return ownerModule.CorLibTypes.Int32;
			case ConstantType.UInt32:	return ownerModule.CorLibTypes.UInt32;
			case ConstantType.Int64:	return ownerModule.CorLibTypes.Int64;
			case ConstantType.UInt64:	return ownerModule.CorLibTypes.UInt64;
			case ConstantType.Single:	return ownerModule.CorLibTypes.Single;
			case ConstantType.Double:	return ownerModule.CorLibTypes.Double;
			case ConstantType.String:	return ownerModule.CorLibTypes.String;
			case ConstantType.Enum:		return new ValueTypeSig(EnumType);
			case ConstantType.Type:		return new ClassSig(ownerModule.CorLibTypes.GetTypeRef("System", "Type"));

			case ConstantType.ObjectArray:	return new SZArraySig(ownerModule.CorLibTypes.Object);
			case ConstantType.BooleanArray:	return new SZArraySig(ownerModule.CorLibTypes.Boolean);
			case ConstantType.CharArray:	return new SZArraySig(ownerModule.CorLibTypes.Char);
			case ConstantType.SByteArray:	return new SZArraySig(ownerModule.CorLibTypes.SByte);
			case ConstantType.ByteArray:	return new SZArraySig(ownerModule.CorLibTypes.Byte);
			case ConstantType.Int16Array:	return new SZArraySig(ownerModule.CorLibTypes.Int16);
			case ConstantType.UInt16Array:	return new SZArraySig(ownerModule.CorLibTypes.UInt16);
			case ConstantType.Int32Array:	return new SZArraySig(ownerModule.CorLibTypes.Int32);
			case ConstantType.UInt32Array:	return new SZArraySig(ownerModule.CorLibTypes.UInt32);
			case ConstantType.Int64Array:	return new SZArraySig(ownerModule.CorLibTypes.Int64);
			case ConstantType.UInt64Array:	return new SZArraySig(ownerModule.CorLibTypes.UInt64);
			case ConstantType.SingleArray:	return new SZArraySig(ownerModule.CorLibTypes.Single);
			case ConstantType.DoubleArray:	return new SZArraySig(ownerModule.CorLibTypes.Double);
			case ConstantType.StringArray:	return new SZArraySig(ownerModule.CorLibTypes.String);
			case ConstantType.EnumArray:	return new SZArraySig(new ValueTypeSig(EnumType));
			case ConstantType.TypeArray:	return new SZArraySig(new ClassSig(ownerModule.CorLibTypes.GetTypeRef("System", "Type")));
			}

			Debug.Fail(string.Format("Unknown constant type: {0}", ct));
			return ownerModule.CorLibTypes.Object;
		}
Example #56
0
		public ConstantTypeVM(ModuleDef ownerModule, object value, ConstantType[] validConstants, bool allowNullString, bool arraysCanBeNull, TypeSigCreatorOptions options = null) {
			if (options == null) {
				IList<ConstantType> clist = validConstants;
				if (clist.IndexOf(ConstantType.Type) >= 0 ||
					clist.IndexOf(ConstantType.TypeArray) >= 0 ||
					clist.IndexOf(ConstantType.ObjectArray) >= 0) {
					throw new ArgumentNullException();
				}
			}
			this.arraysCanBeNull = arraysCanBeNull;
			var list = validConstants.Select(a => typeToEnumVM[a]);
			this.constantTypeEnumListVM = new EnumListVM(list, (a, b) => OnConstantChanged());
			this.boolean = new BooleanVM(a => FieldUpdated());
			this.@char = new CharVM(a => FieldUpdated());
			this.@sbyte = new SByteVM(a => FieldUpdated());
			this.@byte = new ByteVM(a => FieldUpdated());
			this.int16 = new Int16VM(a => FieldUpdated());
			this.uint16 = new UInt16VM(a => FieldUpdated());
			this.int32 = new Int32VM(a => FieldUpdated());
			this.uint32 = new UInt32VM(a => FieldUpdated());
			this.int64 = new Int64VM(a => FieldUpdated());
			this.uint64 = new UInt64VM(a => FieldUpdated());
			this.single = new SingleVM(a => FieldUpdated());
			this.@double = new DoubleVM(a => FieldUpdated());
			this.@string = new StringVM(a => FieldUpdated(), allowNullString);
			this.@enum = new EnumDataFieldVM(ownerModule, a => FieldUpdated());
			this.type = new TypeSigVM(a => FieldUpdated(), options);
			this.objectArray = new ObjectListDataFieldVM(ownerModule, a => FieldUpdated(), options);
			this.booleanArray = new BooleanListDataFieldVM(a => FieldUpdated());
			this.charArray = new CharListDataFieldVM(a => FieldUpdated());
			this.sbyteArray = new SByteListDataFieldVM(a => FieldUpdated());
			this.byteArray = new ByteListDataFieldVM(a => FieldUpdated());
			this.int16Array = new Int16ListDataFieldVM(a => FieldUpdated());
			this.uint16Array = new UInt16ListDataFieldVM(a => FieldUpdated());
			this.int32Array = new Int32ListDataFieldVM(a => FieldUpdated());
			this.uint32Array = new UInt32ListDataFieldVM(a => FieldUpdated());
			this.int64Array = new Int64ListDataFieldVM(a => FieldUpdated());
			this.uint64Array = new UInt64ListDataFieldVM(a => FieldUpdated());
			this.singleArray = new SingleListDataFieldVM(a => FieldUpdated());
			this.doubleArray = new DoubleListDataFieldVM(a => FieldUpdated());
			this.stringArray = new StringListDataFieldVM(a => FieldUpdated());
			this.enumArray = new EnumListDataFieldVM(ownerModule, a => FieldUpdated());
			this.typeArray = new TypeSigListDataFieldVM(a => FieldUpdated(), options);
			this.Value = value;
		}