protected override void Parse( System.IO.BinaryReader sourceStream, byte sourceVersion )
{
_functionName = Helper.SwfStrings.SwfString( sourceVersion, sourceStream );
_numParams = sourceStream.ReadUInt16();
_numRegister = sourceStream.ReadByte();
BitStream bits = new BitStream( sourceStream.BaseStream );
_PreloadParentFlag = ( 0 != bits.GetBits( 1 ) );
_PreloadRootFlag = ( 0 != bits.GetBits( 1 ) );
_SuppressSuperFlag = ( 0 != bits.GetBits( 1 ) );
_PreloadSuperFlag = ( 0 != bits.GetBits( 1 ) );
_SuppressArgumentsFlag = ( 0 != bits.GetBits( 1 ) );
_PreloadArgumentsFlag = ( 0 != bits.GetBits( 1 ) );
_SuppressThisFlag = ( 0 != bits.GetBits( 1 ) );
_PreloadThisFlag = ( 0 != bits.GetBits( 1 ) );
uint reserved = bits.GetBits( 7 );
_PreloadGlobalFlag = ( 0 != bits.GetBits( 1 ) );
if ( 0 != reserved )
{
throw new AVM1ExceptionByteCodeFormat( "ActionDefineFunction2 with reserved flags used" );
}
if ( _SuppressArgumentsFlag && _PreloadArgumentsFlag )
{
throw new AVM1ExceptionByteCodeFormat( "ActionDefineFunction2 Supress+Preload Arguments flag" );
}
if ( _SuppressSuperFlag && _PreloadSuperFlag )
{
throw new AVM1ExceptionByteCodeFormat( "ActionDefineFunction2 Supress+Preload Super flag" );
}
if ( _SuppressThisFlag && _PreloadThisFlag )
{
throw new AVM1ExceptionByteCodeFormat( "ActionDefineFunction2 Supress+Preload This flag" );
}
// TODO: make sure this is correct
_Parameters = new List<RegisterParam>();
for ( int i = 0; i < _numParams; i++ )
{
RegisterParam rp = new RegisterParam();
rp.Register = sourceStream.ReadByte();
rp.ParamName = Helper.SwfStrings.SwfString( sourceVersion, sourceStream );
_Parameters.Add( rp );
}
_codeSize = sourceStream.ReadUInt16();
//
// Please see comment at ActionDefineFunction
//
// _code = Helper.SwfCodeReader.GetCode( _codeSize, sourceStream, sourceTag, sourceFile );
}