Exemple #1
0
        public void WriteConstantPool(ConstantPoolInfo value)
        {
            WriteU30(value.IntArrayLength);
            for (uint i = 1; i < value.IntArrayLength; i++)
            {
                WriteS32(value.GetIntAt(i));
            }

            WriteU30(value.UIntArrayLength);
            for (uint i = 1; i < value.UIntArrayLength; i++)
            {
                WriteU30(value.GetUIntAt(i));
            }

            WriteU30(value.DoubleArrayLength);
            for (uint i = 1; i < value.DoubleArrayLength; i++)
            {
                WriteDouble(value.GetDoubleAt(i));
            }

            WriteU30(value.StringArrayLength);
            for (uint i = 1; i < value.StringArrayLength; i++)
            {
                StringInfo stringInfo = value.GetStringAt(i);

                WriteString(stringInfo);
            }


            WriteU30(value.NamespaceArrayLength);
            for (uint i = 1; i < value.NamespaceArrayLength; i++)
            {
                var namespaceInfo = value.GetNamespaceAt(i);
                WriteByte((Byte)namespaceInfo.Kind);
                WriteU30(namespaceInfo.Name?.Index ?? 0);
            }

            WriteU30(value.NamespaceSetArrayLength);
            for (uint i = 1; i < value.NamespaceSetArrayLength; i++)
            {
                WriteU30Array((from n in value.GetNamespaceSetAt(i).NamespaceArray select n.Index).ToArray(), true);
            }

            WriteU30(value.MultinameArrayLength);
            for (uint i = 1; i < value.MultinameArrayLength; i++)
            {
                WriteMultinameInfo(value.GetMultinameAt(i));
            }
        }
Exemple #2
0
        public object GetValue(ConstantPoolInfo constantPoolInfo)
        {
            object result;

            switch (ValueKind)
            {
            case ValueKind.Int:
                result = constantPoolInfo.GetIntAt(ValueIndex);
                break;

            case ValueKind.UInt:
                result = constantPoolInfo.GetUIntAt(ValueIndex);
                break;

            case ValueKind.Double:
                result = constantPoolInfo.GetDoubleAt(ValueIndex);
                break;

            case ValueKind.Utf8:
                result = '"' + constantPoolInfo.GetStringAt(ValueIndex) + '"';
                break;

            case ValueKind.False:
                result = "false";
                break;

            case ValueKind.True:
                result = "true";
                break;

            case ValueKind.Null:
                result = "null";
                break;

            case ValueKind.Undefined:
                result = "undefined";
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(result);
        }
Exemple #3
0
 public object GetValue(ConstantPoolInfo cPool)
 {
     return(cPool.GetDoubleAt(DoubleIndex));
 }