         "81 (invalid)",         // 81
         "DoABC2",               // 82
         "83 (invalid)"          // 83
-	]
-	
-	
-	class Swf
-	{
-		private var bitPos:int
-		private var bitBuf:int
-		
-		private var data:ByteArray
-
-		function Swf(data:ByteArray)
-		{
-			this.data = data
-			infoPrint("size "+decodeRect())
-			infoPrint("frame rate "+(data.readUnsignedByte()<<8|data.readUnsignedByte()))
-			infoPrint("frame count "+data.readUnsignedShort())
-			decodeTags()			
-		}
-		
-		private function decodeTags()
-		{
-	        var type:int, h:int, length:int
-			var offset:int
-	
-	        while (data.position < data.length)
-	        {
-	            type = (h = data.readUnsignedShort()) >> 6;
-	
-	            if (((length = h & 0x3F) == 0x3F))
-	                length = data.readInt();
-
-				infoPrint(tagNames[type]+" "+length+"b "+int(100*length/data.length)+"%")
-				switch (type)
-				{
-				case 0: return
-				case stagDoABC2:
-					var pos1:int = data.position
-					data.readInt()
-					infoPrint("\nabc name "+readString())
-					length -= (data.position-pos1)
-					// fall through
-				case stagDoABC:
-					var data2 = new ByteArray
-					data2.endian = "littleEndian"
-					data.readBytes(data2,0,length)
-					new Abc(data2).dump("  ")
-					infoPrint("")
-					break 
-				default:
-					data.position += length
-				}
-	        }
-		}
-
-		private function readString():String
-		{
-			var s:String = ""
-			var c:int
-
-			while (c=data.readUnsignedByte())
-				s += String.fromCharCode(c)
-
-			return s
-		}
-		
-		private function syncBits() 
-		{
-			bitPos = 0
-		}
-		
-	    private function decodeRect():Rect
-	    {
-	        syncBits();
-	
-	        var rect:Rect = new Rect();
-	
-	        var nBits:int = readUBits(5)
-	        rect.xMin = readSBits(nBits);
-	        rect.xMax = readSBits(nBits);
-	        rect.yMin = readSBits(nBits);
-	        rect.yMax = readSBits(nBits);
-	
-	        return rect;
-	    }
-	    
-	    function readSBits(numBits:int):int
-	    {
-	        if (numBits > 32)
-	            throw new Error("Number of bits > 32");
-
-	        var num:int = readUBits(numBits);
-	        var shift:int = 32-numBits;
-	        // sign extension
-	        num = (num << shift) >> shift;
-	        return num;
-	    }
-	    
-		function readUBits(numBits:int):uint
-	    {
-	        if (numBits == 0)
-	        	return 0
-	
-	        var bitsLeft:int = numBits;
-	        var result:int = 0;
-	
-	        if (bitPos == 0) //no value in the buffer - read a byte
-	        {
-	            bitBuf = data.readUnsignedByte()
-	            bitPos = 8;
-	        }
-	
-	        while (true)
-	        {
-	            var shift:int = bitsLeft - bitPos;
-	            if (shift > 0)
-	            {
-	                // Consume the entire buffer
-	                result |= bitBuf << shift;
-	                bitsLeft -= bitPos;
-	
-	                // Get the next byte from the input stream
-	                bitBuf = data.readUnsignedByte();
-	                bitPos = 8;
-	            }
-	            else
-	            {
-	                // Consume a portion of the buffer
-	                result |= bitBuf >> -shift;
-	                bitPos -= bitsLeft;
-	                bitBuf &= 0xff >> (8 - bitPos); // mask off the consumed bits
-	
-	//                if (print) System.out.println("  read"+numBits+" " + result);
-	                return result;
-	            }
-	        }
-	    }
-    }
-
-	function help()
-	{
-		print(usage);
-		System.exit(1)
-	}
-
-	function processArg(arg:String)
-	{
-		if (arg == '-a')
-			doExtractAbc = true;
-		else if (arg == '-i')
-			doExtractInfo = true;
-		else 
-		{
-			print('Unknown option '+arg)
-			help()
-		}
-	} 
-
-	function nextAbcFname():String
-	{
-		var s = currentFname
-		if (currentFcount>0)
-			s = s.concat(currentFcount);
-		currentFcount++
-		return s+'.abc'
-	}   
-	
-	// main
-	var doExtractAbc = false
-	var doExtractInfo = false
-	var currentFname = ''
-	var currentFcount = 0
-	for each (var file in System.argv)
-	{
-		if (file.indexOf('-')==0) 
-		{
-			processArg(file)
-			continue
-		}
-		
-		var x;
-		if ((x = file.lastIndexOf(".swf")) != -1 || (x = file.lastIndexOf(".swc")) != -1)
-		    currentFname = file.substring(0,x);
-		else
-			currentFname = file;
-		var data:ByteArray = ByteArray.readFile(file)
-		data.endian = "littleEndian"
-		var version:uint = data.readUnsignedInt()
-		switch (version) {
-		case 46<<16|14:
-		case 46<<16|15:
-		case 46<<16|16:
-			var abc:Abc = new Abc(data)
-			abc.dump()
-			break
-		case 67|87<<8|83<<16|10<<24: // SWC10
-		case 67|87<<8|83<<16|9<<24: // SWC9
-		case 67|87<<8|83<<16|8<<24: // SWC8
-		case 67|87<<8|83<<16|7<<24: // SWC7
-		case 67|87<<8|83<<16|6<<24: // SWC6
-			var udata:ByteArray = new ByteArray
-			udata.endian = "littleEndian"
-			data.position = 8
-			data.readBytes(udata,0,data.length-data.position)
-			var csize:int = udata.length
-			udata.uncompress()
-			infoPrint("decompressed swf "+csize+" -> "+udata.length)
-			udata.position = 0
-		    /*var swf:Swf =*/ new Swf(udata)
-			break
-		case 70|87<<8|83<<16|10<<24: // SWC10
-		case 70|87<<8|83<<16|9<<24: // SWC9
-		case 70|87<<8|83<<16|8<<24: // SWC8
-		case 70|87<<8|83<<16|7<<24: // SWC7
-		case 70|87<<8|83<<16|6<<24: // SWC6
-		case 70|87<<8|83<<16|5<<24: // SWC5
-		case 70|87<<8|83<<16|4<<24: // SWC4
-			data.position = 8 // skip header and length
-		    /*var swf:Swf =*/ new Swf(data)
-			break
-		default:
-			print('unknown format '+version)
-			break
-		}
-	}
-
-	if (System.argv<2)
-		help();
+    ]
+    
+    
+    class Swf
+    {
+        private var bitPos:int
+        private var bitBuf:int
+        
+        private var data:ByteArray
+
+        function Swf(data:ByteArray)
+        {
+            this.data = data
+            infoPrint("size "+decodeRect())
+            infoPrint("frame rate "+(data.readUnsignedByte()<<8|data.readUnsignedByte()))
+            infoPrint("frame count "+data.readUnsignedShort())
+            decodeTags()            
+        }
+        
+        private function decodeTags()
+        {
+            var type:int, h:int, length:int
+            var offset:int
+    
+            while (data.position < data.length)
+            {
+                type = (h = data.readUnsignedShort()) >> 6;
+    
+                if (((length = h & 0x3F) == 0x3F))
+                    length = data.readInt();
+
+                infoPrint(tagNames[type]+" "+length+"b "+int(100*length/data.length)+"%")
+                switch (type)
+                {
+                case 0: return
+                case stagDoABC2:
+                    var pos1:int = data.position
+                    data.readInt()
+                    infoPrint("\nabc name "+readString())
+                    length -= (data.position-pos1)
+                    // fall through
+                case stagDoABC:
+                    var data2 = new ByteArray
+                    data2.endian = "littleEndian"
+                    data.readBytes(data2,0,length)
+                    new Abc(data2).dump("  ")
+                    infoPrint("")
+                    break 
+                default:
+                    data.position += length
+                }
+            }
+        }
+
+        private function readString():String
+        {
+            var s:String = ""
+            var c:int
+
+            while (c=data.readUnsignedByte())
+                s += String.fromCharCode(c)
+
+            return s
+        }
+        
+        private function syncBits() 
+        {
+            bitPos = 0
+        }
+        
+        private function decodeRect():Rect
+        {
+            syncBits();
+    
+            var rect:Rect = new Rect();
+    
+            var nBits:int = readUBits(5)
+            rect.xMin = readSBits(nBits);
+            rect.xMax = readSBits(nBits);
+            rect.yMin = readSBits(nBits);
+            rect.yMax = readSBits(nBits);
+    
+            return rect;
+        }
+        
+        function readSBits(numBits:int):int
+        {
+            if (numBits > 32)
+                throw new Error("Number of bits > 32");
+
+            var num:int = readUBits(numBits);
+            var shift:int = 32-numBits;
+            // sign extension
+            num = (num << shift) >> shift;
+            return num;
+        }
+        
+        function readUBits(numBits:int):uint
+        {
+            if (numBits == 0)
+                return 0
+    
+            var bitsLeft:int = numBits;
+            var result:int = 0;
+    
+            if (bitPos == 0) //no value in the buffer - read a byte
+            {
+                bitBuf = data.readUnsignedByte()
+                bitPos = 8;
+            }
+    
+            while (true)
+            {
+                var shift:int = bitsLeft - bitPos;
+                if (shift > 0)
+                {
+                    // Consume the entire buffer
+                    result |= bitBuf << shift;
+                    bitsLeft -= bitPos;
+    
+                    // Get the next byte from the input stream
+                    bitBuf = data.readUnsignedByte();
+                    bitPos = 8;
+                }
+                else
+                {
+                    // Consume a portion of the buffer
+                    result |= bitBuf >> -shift;
+                    bitPos -= bitsLeft;
+                    bitBuf &= 0xff >> (8 - bitPos); // mask off the consumed bits
+    
+    //                if (print) System.out.println("  read"+numBits+" " + result);
+                    return result;
+                }
+            }
+        }
+    }
+
+    function help()
+    {
+        print(usage);
+        System.exit(1)
+    }
+
+    function processArg(arg:String)
+    {
+        if (arg == '-a')
+            doExtractAbc = true;
+        else if (arg == '-i')
+            doExtractInfo = true;
+        else 
+        {
+            print('Unknown option '+arg)
+            help()
+        }
+    } 
+
+    function nextAbcFname():String
+    {
+        var s = currentFname
+        if (currentFcount>0)
+            s = s.concat(currentFcount);
+        currentFcount++
+        return s+'.abc'
+    }   
+    
+    // main
+    var doExtractAbc = false
+    var doExtractInfo = false
+    var currentFname = ''
+    var currentFcount = 0
+    for each (var file in System.argv)
+    {
+        if (file.indexOf('-')==0) 
+        {
+            processArg(file)
+            continue
+        }
+        
+        var x;
+        if ((x = file.lastIndexOf(".swf")) != -1 || (x = file.lastIndexOf(".swc")) != -1)
+            currentFname = file.substring(0,x);
+        else
+            currentFname = file;
+        var data:ByteArray = ByteArray.readFile(file)
+        data.endian = "littleEndian"
+        var version:uint = data.readUnsignedInt()
+        switch (version) {
+        case 46<<16|14:
+        case 46<<16|15:
+        case 46<<16|16:
+            var abc:Abc = new Abc(data)
+            abc.dump()
+            break
+        case 67|87<<8|83<<16|10<<24: // SWC10
+        case 67|87<<8|83<<16|9<<24: // SWC9
+        case 67|87<<8|83<<16|8<<24: // SWC8
+        case 67|87<<8|83<<16|7<<24: // SWC7
+        case 67|87<<8|83<<16|6<<24: // SWC6
+            var udata:ByteArray = new ByteArray
+            udata.endian = "littleEndian"
+            data.position = 8
+            data.readBytes(udata,0,data.length-data.position)
+            var csize:int = udata.length
+            udata.uncompress()
+            infoPrint("decompressed swf "+csize+" -> "+udata.length)
+            udata.position = 0
+            /*var swf:Swf =*/ new Swf(udata)
+            break
+        case 70|87<<8|83<<16|10<<24: // SWC10
+        case 70|87<<8|83<<16|9<<24: // SWC9
+        case 70|87<<8|83<<16|8<<24: // SWC8
+        case 70|87<<8|83<<16|7<<24: // SWC7
+        case 70|87<<8|83<<16|6<<24: // SWC6
+        case 70|87<<8|83<<16|5<<24: // SWC5
+        case 70|87<<8|83<<16|4<<24: // SWC4
+            data.position = 8 // skip header and length
+            /*var swf:Swf =*/ new Swf(data)
+            break
+        default:
+            print('unknown format '+version)
+            break
+        }
+    }
+
+    if (System.argv<2)
+        help();
 }
 

/* -*- tab-width: 4 -*- */
/* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1


package abcdump
{
    import flash.utils.ByteArray
    import avmplus.System

    include "abc-constants.as"
    
    var usage = [
    "Displays the contents of abc or swf files",
    "",
    "Usage:",
    "",
    "    abcdump [options] file ...",
    "",
    "Each file can be an ABC or SWF/SWC format file",
    "",
    "Options:",
    "",
    " -a   Extract the ABC blocks from the SWF/SWC, but do not",
    "      otherwise display their contents.  The file names are",
    "      of the form file<n>.abc where \"file\" is the name",
    "      of the input file minus the .swf/.swc extension;",
    "      and <n> is omitted if it is 0.",
    "",
    " -i   Print information about the ABC, but do not dump the",
    "      byte code.",
    ].join("\n");

    const TAB = "  "
    
    var totalSize:int
    var opSizes:Array = new Array(256)

    function dumpPrint(s) {
        if (!(doExtractAbc || doExtractInfo))
            print(s);
    }

    function infoPrint(s) {
        if (doExtractInfo || !doExtractAbc)
            print(s);
    }

    class Multiname
    {
        var nsset:Array
        var name:String
        function Multiname(nsset:Array, name:String)
        {
            this.nsset = nsset
            this.name = name
        }
        
        public function toString()
        {
            return /*'{' + nsset + '}::' + */name
        }
    }
    
    class TypeName
    {
        var name;
        var types:Array;
