public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._recordType = dis.ReadUnsignedInt(); this._recordLength = dis.ReadUnsignedByte(); this._recordSpecificFields = dis.ReadUnsignedLong(); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._controlType = dis.ReadUnsignedByte(); this._communicationsChannelType = dis.ReadUnsignedByte(); this._sourceEntityID.Unmarshal(dis); this._sourceCommunicationsDeviceID = dis.ReadUnsignedByte(); this._sourceLineID = dis.ReadUnsignedByte(); this._transmitPriority = dis.ReadUnsignedByte(); this._transmitLineState = dis.ReadUnsignedByte(); this._command = dis.ReadUnsignedByte(); this._masterEntityID.Unmarshal(dis); this._masterCommunicationsDeviceID = dis.ReadUnsignedShort(); this._intercomParametersLength = dis.ReadUnsignedInt(); for (int idx = 0; idx < this.IntercomParametersLength; idx++) { IntercomCommunicationsParameters anX = new IntercomCommunicationsParameters(); anX.Unmarshal(dis); this._intercomParameters.Add(anX); } } catch (Exception e) { if (PduBase.TraceExceptions) { Trace.WriteLine(e); Trace.Flush(); } this.RaiseExceptionOccured(e); if (PduBase.ThrowExceptions) { throw e; } } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._munitionType.Unmarshal(dis); this._shotStartTime.Unmarshal(dis); this._commulativeShotTime = dis.ReadFloat(); this._ApertureEmitterLocation.Unmarshal(dis); this._apertureDiameter = dis.ReadFloat(); this._wavelength = dis.ReadFloat(); this._peakIrradiance = dis.ReadFloat(); this._pulseRepetitionFrequency = dis.ReadFloat(); this._pulseWidth = dis.ReadInt(); this._flags = dis.ReadInt(); this._pulseShape = dis.ReadByte(); this._padding1 = dis.ReadUnsignedByte(); this._padding2 = dis.ReadUnsignedInt(); this._padding3 = dis.ReadUnsignedShort(); this._numberOfDERecords = dis.ReadUnsignedShort(); for (int idx = 0; idx < this.NumberOfDERecords; idx++) { StandardVariableSpecification anX = new StandardVariableSpecification(); anX.Unmarshal(dis); this._dERecords.Add(anX); } ; } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._subprotocolNumber = dis.ReadUnsignedShort(); this._padding = dis.ReadUnsignedByte(); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._beamDataLength = dis.ReadUnsignedShort(); this._beamIDNumber = dis.ReadUnsignedByte(); this._pad2 = dis.ReadUnsignedShort(); this._fundamentalDataParameters.Unmarshal(dis); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._entityID.Unmarshal(dis); this._padding1 = dis.ReadByte(); this._numberOfArticulationParameters = dis.ReadUnsignedByte(); this._entityLinearVelocity.Unmarshal(dis); this._entityLocation.Unmarshal(dis); this._entityOrientation.Unmarshal(dis); this._entityAppearance = dis.ReadInt(); for (int idx = 0; idx < this.NumberOfArticulationParameters; idx++) { ArticulationParameter anX = new ArticulationParameter(); anX.Unmarshal(dis); this._articulationParameters.Add(anX); } } catch (Exception e) { if (PduBase.TraceExceptions) { Trace.WriteLine(e); Trace.Flush(); } this.RaiseExceptionOccured(e); if (PduBase.ThrowExceptions) { throw e; } } } }
public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._characterSet = dis.ReadUnsignedByte(); for (int idx = 0; idx < this._characters.Length; idx++) { this._characters[idx] = dis.ReadByte(); } } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._entityID.Unmarshal(dis); this._forceId = dis.ReadUnsignedByte(); this._numberOfArticulationParameters = dis.ReadByte(); this._entityType.Unmarshal(dis); this._alternativeEntityType.Unmarshal(dis); this._entityLinearVelocity.Unmarshal(dis); this._entityLocation.Unmarshal(dis); this._entityOrientation.Unmarshal(dis); this._entityAppearance = dis.ReadInt(); this._deadReckoningParameters.Unmarshal(dis); this._marking.Unmarshal(dis); this._capabilities = dis.ReadInt(); for (int idx = 0; idx < this.NumberOfArticulationParameters; idx++) { ArticulationParameter anX = new ArticulationParameter(); anX.Unmarshal(dis); this._articulationParameters.Add(anX); } ; } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._receivingEntityID.Unmarshal(dis); this._supplyingEntityID.Unmarshal(dis); this._numberOfSupplyTypes = dis.ReadUnsignedByte(); this._padding1 = dis.ReadShort(); this._padding2 = dis.ReadByte(); for (int idx = 0; idx < this.NumberOfSupplyTypes; idx++) { SupplyQuantity anX = new SupplyQuantity(); anX.Unmarshal(dis); this._supplies.Add(anX); } } catch (Exception e) { if (PduBase.TraceExceptions) { Trace.WriteLine(e); Trace.Flush(); } this.RaiseExceptionOccured(e); if (PduBase.ThrowExceptions) { throw e; } } } }
public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._recordID = dis.ReadUnsignedInt(); this._recordSetSerialNumber = dis.ReadUnsignedInt(); this._recordLength = dis.ReadUnsignedShort(); this._recordCount = dis.ReadUnsignedShort(); this._recordValues = dis.ReadUnsignedShort(); this._pad4 = dis.ReadUnsignedByte(); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._deadReckoningAlgorithm = dis.ReadUnsignedByte(); for (int idx = 0; idx < this._otherParameters.Length; idx++) { this._otherParameters[idx] = dis.ReadByte(); } this._entityLinearAcceleration.Unmarshal(dis); this._entityAngularVelocity.Unmarshal(dis); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._receivingEntityID.Unmarshal(dis); this._repairingEntityID.Unmarshal(dis); this._repairResult = dis.ReadUnsignedByte(); this._padding1 = dis.ReadShort(); this._padding2 = dis.ReadByte(); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._beamDataLength = dis.ReadUnsignedByte(); this._beamIDNumber = dis.ReadUnsignedByte(); this._beamParameterIndex = dis.ReadUnsignedShort(); this._fundamentalParameterData.Unmarshal(dis); this._beamFunction = dis.ReadUnsignedByte(); this._numberOfTrackJamTargets = dis.ReadUnsignedByte(); this._highDensityTrackJam = dis.ReadUnsignedByte(); this._pad4 = dis.ReadUnsignedByte(); this._jammingModeSequence = dis.ReadUnsignedInt(); for (int idx = 0; idx < this.NumberOfTrackJamTargets; idx++) { TrackJamTarget anX = new TrackJamTarget(); anX.Unmarshal(dis); this._trackJamTargets.Add(anX); } } catch (Exception e) { if (PduBase.TraceExceptions) { Trace.WriteLine(e); Trace.Flush(); } this.RaiseExceptionOccured(e); if (PduBase.ThrowExceptions) { throw e; } } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._emittingEntityID.Unmarshal(dis); this._eventID.Unmarshal(dis); this._stateUpdateIndicator = dis.ReadUnsignedByte(); this._numberOfSystems = dis.ReadUnsignedByte(); this._emissionsPadding = dis.ReadUnsignedShort(); this._systemDataLength = dis.ReadUnsignedByte(); this._numberOfBeams = dis.ReadUnsignedByte(); this._emissionsPadding2 = dis.ReadUnsignedShort(); this._emitterSystem.Unmarshal(dis); this._location.Unmarshal(dis); this._beamDataLength = dis.ReadUnsignedByte(); this._beamIdNumber = dis.ReadUnsignedByte(); this._beamParameterIndex = dis.ReadUnsignedShort(); this._fundamentalParameterData.Unmarshal(dis); } catch (Exception e) { if (PduBase.TraceExceptions) { Trace.WriteLine(e); Trace.Flush(); } this.RaiseExceptionOccured(e); if (PduBase.ThrowExceptions) { throw e; } } } }
public virtual void Unmarshal(DataInputStream dis) { if (dis != null) { try { this._entityKind = dis.ReadUnsignedByte(); this._domain = dis.ReadUnsignedByte(); this._country = dis.ReadUnsignedShort(); this._category = dis.ReadUnsignedByte(); this._subcategory = dis.ReadUnsignedByte(); this._specific = dis.ReadUnsignedByte(); this._extra = dis.ReadUnsignedByte(); } catch (Exception e) { #if DEBUG Trace.WriteLine(e); Trace.Flush(); #endif this.OnException(e); } } }
/// <exception cref="IOException"/> private static TypeAnnotation Parse(DataInputStream data, ConstantPool pool) { int targetType = data.ReadUnsignedByte(); int target = targetType << 24; switch (targetType) { case TypeAnnotation.Class_Type_Parameter: case TypeAnnotation.Method_Type_Parameter: case TypeAnnotation.Method_Parameter: { target |= data.ReadUnsignedByte(); break; } case TypeAnnotation.Super_Type_Reference: case TypeAnnotation.Class_Type_Parameter_Bound: case TypeAnnotation.Method_Type_Parameter_Bound: case TypeAnnotation.Throws_Reference: case TypeAnnotation.Catch_Clause: case TypeAnnotation.Expr_Instanceof: case TypeAnnotation.Expr_New: case TypeAnnotation.Expr_Constructor_Ref: case TypeAnnotation.Expr_Method_Ref: { target |= data.ReadUnsignedShort(); break; } case TypeAnnotation.Type_Arg_Cast: case TypeAnnotation.Type_Arg_Constructor_Call: case TypeAnnotation.Type_Arg_Method_Call: case TypeAnnotation.Type_Arg_Constructor_Ref: case TypeAnnotation.Type_Arg_Method_Ref: { data.SkipBytes(3); break; } case TypeAnnotation.Local_Variable: case TypeAnnotation.Resource_Variable: { data.SkipBytes(data.ReadUnsignedShort() * 6); break; } case TypeAnnotation.Field: case TypeAnnotation.Method_Return_Type: case TypeAnnotation.Method_Receiver: { break; } default: { throw new Exception("unknown target type: " + targetType); } } int pathLength = data.ReadUnsignedByte(); byte[] path = null; if (pathLength > 0) { path = new byte[2 * pathLength]; data.ReadFully(path); } AnnotationExprent annotation = StructAnnotationAttribute.ParseAnnotation(data, pool ); return(new TypeAnnotation(target, path, annotation)); }
/// <exception cref="IOException"/> public static Exprent ParseAnnotationElement(DataInputStream data, ConstantPool pool ) { int tag = data.ReadUnsignedByte(); switch (tag) { case 'e': { // enum constant string className = pool.GetPrimitiveConstant(data.ReadUnsignedShort()).GetString( ); string constName = pool.GetPrimitiveConstant(data.ReadUnsignedShort()).GetString( ); FieldDescriptor descr = FieldDescriptor.ParseDescriptor(className); return(new FieldExprent(constName, descr.type.value, true, null, descr, null)); } case 'c': { // class string descriptor = pool.GetPrimitiveConstant(data.ReadUnsignedShort()).GetString (); VarType type = FieldDescriptor.ParseDescriptor(descriptor).type; string value; switch (type.type) { case ICodeConstants.Type_Object: { value = type.value; break; } case ICodeConstants.Type_Byte: { value = typeof(byte).FullName; break; } case ICodeConstants.Type_Char: { value = typeof(char).FullName; break; } case ICodeConstants.Type_Double: { value = typeof(double).FullName; break; } case ICodeConstants.Type_Float: { value = typeof(float).FullName; break; } case ICodeConstants.Type_Int: { value = typeof(int).FullName; break; } case ICodeConstants.Type_Long: { value = typeof(long).FullName; break; } case ICodeConstants.Type_Short: { value = typeof(short).FullName; break; } case ICodeConstants.Type_Boolean: { value = typeof(bool).FullName; break; } case ICodeConstants.Type_Void: { value = typeof(void).FullName; break; } default: { throw new Exception("invalid class type: " + type.type); } } return(new ConstExprent(VarType.Vartype_Class, value, null)); } case '[': { // array List <Exprent> elements = new System.Collections.Generic.List <Exprent>(); int len = data.ReadUnsignedShort(); if (len > 0) { elements = new List <Exprent>(len); for (int i = 0; i < len; i++) { elements.Add(ParseAnnotationElement(data, pool)); } } VarType newType; if ((elements.Count == 0)) { newType = new VarType(ICodeConstants.Type_Object, 1, "java/lang/Object"); } else { VarType elementType = elements[0].GetExprType(); newType = new VarType(elementType.type, 1, elementType.value); } NewExprent newExpr = new NewExprent(newType, new System.Collections.Generic.List < Exprent>(), null); newExpr.SetDirectArrayInit(true); newExpr.SetLstArrayElements(elements); return(newExpr); } case '@': { // annotation return(ParseAnnotation(data, pool)); } default: { PrimitiveConstant cn = pool.GetPrimitiveConstant(data.ReadUnsignedShort()); switch (tag) { case 'B': { return(new ConstExprent(VarType.Vartype_Byte, cn.value, null)); } case 'C': { return(new ConstExprent(VarType.Vartype_Char, cn.value, null)); } case 'D': { return(new ConstExprent(VarType.Vartype_Double, cn.value, null)); } case 'F': { return(new ConstExprent(VarType.Vartype_Float, cn.value, null)); } case 'I': { return(new ConstExprent(VarType.Vartype_Int, cn.value, null)); } case 'J': { return(new ConstExprent(VarType.Vartype_Long, cn.value, null)); } case 'S': { return(new ConstExprent(VarType.Vartype_Short, cn.value, null)); } case 'Z': { return(new ConstExprent(VarType.Vartype_Boolean, cn.value, null)); } case 's': { return(new ConstExprent(VarType.Vartype_String, cn.value, null)); } default: { throw new Exception("invalid element type!"); } } break; } } }
static void LoadResToCache() { string loon_default_font = "lfcache"; IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication(); if (!isoStorage.FileExists(loon_default_font)) { IsolatedStorageFileStream outStream = isoStorage.CreateFile(loon_default_font); Stream gzip = null; try { gzip = new GZipInputStream(XNAConfig.LoadStream(LSystem.FRAMEWORK_IMG_NAME + "font.zip")); byte[] buffer = new byte[4096]; int charsRead; while ((charsRead = gzip.Read(buffer, 0, buffer.Length)) != 0) { outStream.Write(buffer, 0, charsRead); } outStream.Flush(); if (gzip != null) { gzip.Close(); gzip.Dispose(); gzip = null; } buffer = null; } catch (Exception) { if (outStream != null) { outStream.Close(); outStream.Dispose(); outStream = null; } if (gzip != null) { gzip.Close(); gzip.Dispose(); gzip = null; } IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(loon_default_font); } finally { if (outStream != null) { outStream.Close(); outStream = null; } } } Stream ins = null; try { ins = isoStorage.OpenFile(loon_default_font, FileMode.Open); DataInputStream resStream = new DataInputStream(ins); realsize = resStream.ReadUnsignedByte(); offy = resStream.ReadByte(); fontSpace = (realsize + offy) * 2; if (realsize > 0x10) { fontSpace *= 2; } int num = resStream.ReadInt(); int num2 = resStream.ReadByte(); byte[] bufferData = new byte[resStream.Available()]; resStream.Read(bufferData); fontData = bufferData; if (resStream != null) { resStream.Close(); resStream = null; } } catch (Exception) { fontData = null; if (ins != null) { ins.Close(); ins.Dispose(); ins = null; } LoadResToMemory(); } finally { if (ins != null) { ins.Close(); ins.Dispose(); ins = null; } } }
public override void Unmarshal(DataInputStream dis) { base.Unmarshal(dis); if (dis != null) { try { this._aggregateID.Unmarshal(dis); this._forceID = dis.ReadUnsignedByte(); this._aggregateState = dis.ReadUnsignedByte(); this._aggregateType.Unmarshal(dis); this._formation = dis.ReadUnsignedInt(); this._aggregateMarking.Unmarshal(dis); this._dimensions.Unmarshal(dis); this._orientation.Unmarshal(dis); this._centerOfMass.Unmarshal(dis); this._velocity.Unmarshal(dis); this._numberOfDisAggregates = dis.ReadUnsignedShort(); this._numberOfDisEntities = dis.ReadUnsignedShort(); this._numberOfSilentAggregateTypes = dis.ReadUnsignedShort(); this._numberOfSilentEntityTypes = dis.ReadUnsignedShort(); for (int idx = 0; idx < this.NumberOfDisAggregates; idx++) { AggregateID anX = new AggregateID(); anX.Unmarshal(dis); this._aggregateIDList.Add(anX); } for (int idx = 0; idx < this.NumberOfDisEntities; idx++) { EntityID anX = new EntityID(); anX.Unmarshal(dis); this._entityIDList.Add(anX); } this._pad2 = dis.ReadUnsignedByte(); for (int idx = 0; idx < this.NumberOfSilentAggregateTypes; idx++) { EntityType anX = new EntityType(); anX.Unmarshal(dis); this._silentAggregateSystemList.Add(anX); } for (int idx = 0; idx < this.NumberOfSilentEntityTypes; idx++) { EntityType anX = new EntityType(); anX.Unmarshal(dis); this._silentEntitySystemList.Add(anX); } this._numberOfVariableDatumRecords = dis.ReadUnsignedInt(); for (int idx = 0; idx < this.NumberOfVariableDatumRecords; idx++) { VariableDatum anX = new VariableDatum(); anX.Unmarshal(dis); this._variableDatumList.Add(anX); } } catch (Exception e) { if (PduBase.TraceExceptions) { Trace.WriteLine(e); Trace.Flush(); } this.RaiseExceptionOccured(e); if (PduBase.ThrowExceptions) { throw e; } } } }
/// <exception cref="System.IO.IOException"/> public static void Main(string[] args) { if (args.Length != 4) { logger.Info("Usage: MnistConverter dataFile labelFile outFile propsFile"); return; } DataInputStream xStream = IOUtils.GetDataInputStream(args[0]); DataInputStream yStream = IOUtils.GetDataInputStream(args[1]); PrintWriter oStream = new PrintWriter(new FileWriter(args[2])); PrintWriter pStream = new PrintWriter(new FileWriter(args[3])); int xMagic = xStream.ReadInt(); if (xMagic != 2051) { throw new Exception("Bad format of xStream"); } int yMagic = yStream.ReadInt(); if (yMagic != 2049) { throw new Exception("Bad format of yStream"); } int xNumImages = xStream.ReadInt(); int yNumLabels = yStream.ReadInt(); if (xNumImages != yNumLabels) { throw new Exception("x and y sizes don't match"); } logger.Info("Images and label file both contain " + xNumImages + " entries."); int xRows = xStream.ReadInt(); int xColumns = xStream.ReadInt(); for (int i = 0; i < xNumImages; i++) { int label = yStream.ReadUnsignedByte(); int[] matrix = new int[xRows * xColumns]; for (int j = 0; j < xRows * xColumns; j++) { matrix[j] = xStream.ReadUnsignedByte(); } oStream.Print(label); foreach (int k in matrix) { oStream.Print('\t'); oStream.Print(k); } oStream.Println(); } logger.Info("Converted."); xStream.Close(); yStream.Close(); oStream.Close(); // number from 1; column 0 is the class pStream.Println("goldAnswerColumn = 0"); pStream.Println("useClassFeature = true"); pStream.Println("sigma = 10"); // not optimized, but weak regularization seems appropriate when much data, few features for (int j_1 = 0; j_1 < xRows * xColumns; j_1++) { pStream.Println((j_1 + 1) + ".realValued = true"); } pStream.Close(); }
/// <exception cref="IOException"/> public ConstantPool(DataInputStream @in) { int size = @in.ReadUnsignedShort(); pool = new List <PooledConstant>(size); BitSet[] nextPass = new BitSet[] { new BitSet(size), new BitSet(size), new BitSet (size) }; // first dummy constant pool.Add(null); // first pass: read the elements for (int i = 1; i < size; i++) { byte tag = unchecked ((byte)@in.ReadUnsignedByte()); switch (tag) { case ICodeConstants.CONSTANT_Utf8: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Utf8, @in.ReadUTF())); break; } case ICodeConstants.CONSTANT_Integer: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Integer, (@in.ReadInt ()))); break; } case ICodeConstants.CONSTANT_Float: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Float, @in.ReadFloat())); break; } case ICodeConstants.CONSTANT_Long: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Long, @in.ReadLong())); pool.Add(null); i++; break; } case ICodeConstants.CONSTANT_Double: { pool.Add(new PrimitiveConstant(ICodeConstants.CONSTANT_Double, @in.ReadDouble())); pool.Add(null); i++; break; } case ICodeConstants.CONSTANT_Class: case ICodeConstants.CONSTANT_String: case ICodeConstants.CONSTANT_MethodType: { pool.Add(new PrimitiveConstant(tag, @in.ReadUnsignedShort())); nextPass[0].Set(i); break; } case ICodeConstants.CONSTANT_NameAndType: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort())); nextPass[0].Set(i); break; } case ICodeConstants.CONSTANT_Fieldref: case ICodeConstants.CONSTANT_Methodref: case ICodeConstants.CONSTANT_InterfaceMethodref: case ICodeConstants.CONSTANT_InvokeDynamic: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedShort(), @in.ReadUnsignedShort())); nextPass[1].Set(i); break; } case ICodeConstants.CONSTANT_MethodHandle: { pool.Add(new LinkConstant(tag, @in.ReadUnsignedByte(), @in.ReadUnsignedShort())); nextPass[2].Set(i); break; } } } // resolving complex pool elements foreach (BitSet pass in nextPass) { int idx = 0; while ((idx = pass.NextSetBit(idx + 1)) > 0) { pool[idx].ResolveConstant(this); } } // get global constant pool interceptor instance, if any available interceptor = DecompilerContext.GetPoolInterceptor(); }